Return build 19041 XMem free-page counters within the 48-byte output #223

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

@⁠bambermf on GitHub · 2026-11-23 05:56 UTC · original
bambermf:port/xmem-19041-page-statistics → main · +101 −0 · 2 files · 1 commits · closed without merging

Library / area — XMem, build 19041 free-page statistics.

Exports changed — XMemGetFreePageStatistics. XMem has no separate exports.txt entry for this function.

Source of behaviour — Fortnite's xmem.dll 10.0.19041.3948, RVA 0x63d0, inspected with headless IDA MCP. I ran the original x64 routine in Unicorn with controlled partition queries. I then exercised the port through the built Windows DLL with the real NT memory manager. The Windows query class, request layout and current-partition pseudo-handle were checked against the System Informer header. The Rust implementation follows the console routine.

What was wrong

The emulator wrote seven 64-bit fields to an output buffer that this build defines as six. Its values came from host memory totals in bytes. The console queries the title partition for per-node page counts. A single-node console writes the first three results twice.

The change

Query the existing title partition or, where the title uses normal PC memory, the Windows current-memory-partition pseudo-handle. Sum the counter pairs and weight the last pair by 512 as the console does. Copy all six results only after a successful query. Map NT errors through RtlNtStatusToDosError. Build selection uses the existing console OS configuration.

Measurements

The original routine received rows containing consecutive numbers starting at zero, supplied by the emulated kernel call. Guard words surrounded the six output slots.

Case Original return Original output
One node 1 (3, 7, 7691) repeated twice, both guards untouched
Two nodes 1 (3, 7, 7691), (21, 25, 16925), both guards untouched
STATUS_INVALID_HANDLE 0 all output and guard words untouched

On this single-node Windows host, a call through the rebuilt DLL returned 1 and two identical triples with both guards intact. An invalid-handle query mapped to Windows error 6. The native two-node path was not exercised on physical hardware. The implementation makes the console's one- or two-node request and propagates a rejection from a host whose topology requires a larger request.

Tests

  • 60 XMem unit tests and four integration tests passed on Windows x64, release profile.
  • The new cases cover page-count arithmetic, failure and last-error propagation, and the write extent through the DLL export.
  • Local PR gate passed. Only Rust source and tests are included.
**@⁠bambermf** on GitHub · 2026-11-23 05:56 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/223) `bambermf:port/xmem-19041-page-statistics` → `main` · +101 −0 · 2 files · 1 commits · closed without merging **Library / area** — XMem, build 19041 free-page statistics. **Exports changed** — XMemGetFreePageStatistics. XMem has no separate exports.txt entry for this function. **Source of behaviour** — Fortnite's xmem.dll 10.0.19041.3948, RVA 0x63d0, inspected with headless IDA MCP. I ran the original x64 routine in Unicorn with controlled partition queries. I then exercised the port through the built Windows DLL with the real NT memory manager. The Windows query class, request layout and current-partition pseudo-handle were checked against the [System Informer header](https://github.com/winsiderss/systeminformer/blob/master/phnt/include/ntmmapi.h). The Rust implementation follows the console routine. ### What was wrong The emulator wrote seven 64-bit fields to an output buffer that this build defines as six. Its values came from host memory totals in bytes. The console queries the title partition for per-node page counts. A single-node console writes the first three results twice. ### The change Query the existing title partition or, where the title uses normal PC memory, the Windows current-memory-partition pseudo-handle. Sum the counter pairs and weight the last pair by 512 as the console does. Copy all six results only after a successful query. Map NT errors through RtlNtStatusToDosError. Build selection uses the existing console OS configuration. ### Measurements The original routine received rows containing consecutive numbers starting at zero, supplied by the emulated kernel call. Guard words surrounded the six output slots. | Case | Original return | Original output | |---|---:|---| | One node | 1 | (3, 7, 7691) repeated twice, both guards untouched | | Two nodes | 1 | (3, 7, 7691), (21, 25, 16925), both guards untouched | | STATUS_INVALID_HANDLE | 0 | all output and guard words untouched | On this single-node Windows host, a call through the rebuilt DLL returned 1 and two identical triples with both guards intact. An invalid-handle query mapped to Windows error 6. The native two-node path was not exercised on physical hardware. The implementation makes the console's one- or two-node request and propagates a rejection from a host whose topology requires a larger request. ### Tests - 60 XMem unit tests and four integration tests passed on Windows x64, release profile. - The new cases cover page-count arithmetic, failure and last-error propagation, and the write extent through the DLL export. - Local PR gate passed. Only Rust source and tests are included.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:14:37 +00:00
github-bot closed this pull request 2026-11-26 06:14:37 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 07:49 UTC · original

Applied in 84987a6 (merged in 451fe11) with your authorship kept, thanks. The code shipped in the r32g release (6a1a4b1), which passed its Trackmania control run.

**@⁠omonkeyz** on GitHub · 2026-11-23 07:49 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/223#issuecomment-7094734160) Applied in 84987a6 (merged in 451fe11) with your authorship kept, thanks. The code shipped in the r32g release (6a1a4b1), which passed its Trackmania control run.

Pull request closed

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