Preserve the statistics buffer on invalid 19041 XMem pool queries #219

Closed
github-bot wants to merge 1 commit from gh-pr/219/head into gh-pr/219/base
Owner

@⁠bambermf on GitHub · 2026-11-23 05:36 UTC · original
bambermf:fix/xmem-legacy-stats-invalid-type → main · +31 −0 · 1 files · 1 commits · closed without merging

Library / area: XMem, allocation statistics on OS build 19041.

Exports changed (exports.txt rows): none. The change is in the existing XMemGetAllocationStatistics export.

Source of the behaviour: headless IDA analysis of Fortnite's XMem 10.0.19041.3948. I also executed the original getter instructions in Unicorn with a stand-in for SetLastError and a seeded pool for the valid control. The emulator measurements call the release DLL export in separate processes for each OS build.

What was wrong

With a correctly sized output and an invalid memory type, upstream returned success and zeroed the statistics fields. The original 19041 getter returned failure and preserved the caller's buffer.

Measurements

Memory type, alternate pool, output size Original 19041 Fixed emulator, 19041
16, false, 32 0, error 87, buffer preserved same
0xffffffff, true, 32 0, error 87, buffer preserved same
16, false, 31 0, error 24, buffer preserved same
11, false, 32 1, error 0, statistics written same

The change

For build 19041, return ERROR_INVALID_PARAMETER when the pool index is invalid. The output size check still runs first. The same export probes on the emulator's 22000 profile confirmed its previous behavior.

Tests

The regression failed on main f6ae886 (returned 1) and passed on this branch. It runs with the 19041 profile in an isolated process and checks the entire output buffer. Serial release XMem tests passed: 56 unit tests and 3 integration tests. No console files or binaries are included.

**@⁠bambermf** on GitHub · 2026-11-23 05:36 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/219) `bambermf:fix/xmem-legacy-stats-invalid-type` → `main` · +31 −0 · 1 files · 1 commits · closed without merging **Library / area:** XMem, allocation statistics on OS build 19041. **Exports changed (exports.txt rows):** none. The change is in the existing `XMemGetAllocationStatistics` export. **Source of the behaviour:** headless IDA analysis of Fortnite's XMem 10.0.19041.3948. I also executed the original getter instructions in Unicorn with a stand-in for SetLastError and a seeded pool for the valid control. The emulator measurements call the release DLL export in separate processes for each OS build. ### What was wrong With a correctly sized output and an invalid memory type, upstream returned success and zeroed the statistics fields. The original 19041 getter returned failure and preserved the caller's buffer. ### Measurements | Memory type, alternate pool, output size | Original 19041 | Fixed emulator, 19041 | |---|---|---| | 16, false, 32 | 0, error 87, buffer preserved | same | | 0xffffffff, true, 32 | 0, error 87, buffer preserved | same | | 16, false, 31 | 0, error 24, buffer preserved | same | | 11, false, 32 | 1, error 0, statistics written | same | ### The change For build 19041, return ERROR_INVALID_PARAMETER when the pool index is invalid. The output size check still runs first. The same export probes on the emulator's 22000 profile confirmed its previous behavior. ### Tests The regression failed on main `f6ae886` (returned 1) and passed on this branch. It runs with the 19041 profile in an isolated process and checks the entire output buffer. Serial release XMem tests passed: 56 unit tests and 3 integration tests. No console files or binaries are included.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:14:28 +00:00
github-bot closed this pull request 2026-11-26 06:14:28 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 05:44 UTC · original

Applied in 9475037 (merged in 1dc9fff) with your authorship kept, thanks.

**@⁠omonkeyz** on GitHub · 2026-11-23 05:44 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/219#issuecomment-7092678095) Applied in 9475037 (merged in 1dc9fff) with your authorship kept, thanks.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.