cpu: record the D3D12ConfigureVirtualMemoryX call shape under Windows and pe_map #891

Manually merged
github merged 2 commits from gh-pr/891/head into gh-pr/891/base 2026-11-26 22:26:15 +00:00
Owner

@⁠lukaslw-lab on GitHub · 2026-11-23 16:13 UTC · original
lukaslw-lab:gpu/configure-virtual-memory → main · +339 −0 · 7 files · 2 commits · merged 2026-11-23 16:41 UTC

Change

Adds the source-built recording fixture R0Y00 asked for on #874. No d3d12_xs.dll export: what the call has to change on Windows is still open. Refs #874, #870.

  • tests/cpu/configure_vm.asm: two EXEs reproduce the main executable's call. Each passes a 32-byte zero-filled block with one DWORD sample at +4 (3 or 4), with canaries on both sides. Each then makes two XMemVirtualAlloc(NULL, size, 0x20402000, …) reservations whatever the HRESULT was (16 GiB for 3, 24 GiB for 4).
  • tests/cpu/configure_vm_recorder.cpp: stand-ins named d3d12_xs.dll and xmem.dll, in their own configure_vm build directory. They only log each call and return a chosen HRESULT. They implement nothing.
  • docs/experiments.md: the observed call shape and the open questions: what the DWORD means, what the other 28 bytes are for, and what effect is required.

This complements draft #888, which implements XMemVirtualAlloc in xmem_shim. This PR touches no shim. Once both land, the recorded reservation arguments match the shapes #888 accepts.

Verification

Commit 6eb3341 on Windows 10 22H2 (build 19045), Visual Studio 2026 18.12 (MSVC 19.52), Windows SDK 10.0.26100, CMake 4.3.1, Python 3.13.7.

ctest --preset dev --no-tests=error -R '^(cpu_native_configure_vm|d3d12_xs_shim_.*|cpu_native_shim_startup|docs_links)$'
7 total: 7 passed, 0 skipped, 0 failed

The same command with --preset release gave 7 passed, 0 skipped, 0 failed. tests/bidi_controls_check.py and tests/docs_links_check.py passed.

cpu_native_configure_vm output (Release, sample 4; sample 3 is the same with 400000000):

sample 4 success: exit 0x0 under both loaders
sample 4 failure HRESULT: exit 0x8007000e under both loaders
sample 4 write inside block: exit 0x1 under both loaders
sample 4 write after block: exit 0x2 under both loaders
sample 4: D3D12ConfigureVirtualMemoryX 0000000004000000000000000000000000000000000000000000000000000000 | XMemVirtualAlloc 0 600000000 20402000 21 4 | XMemVirtualAlloc 0 600000000 20402000 3 801

Evidence and follow-up

  • Fixture: source-built (MASM, C++, Python), MIT. The call shape comes from a static read of the call site (file reads only, nothing executed) and is described in #874. No title bytes are included.
  • Controls: with either stand-in missing, pe_map stops at that import before the entry point. Stand-in writes inside or after the block are caught. A failure HRESULT reaches the exit code unchanged.
  • Mutations: three EXE mutations make the test fail. They removed a canary check, dropped the failure HRESULT, and moved the configuration call after the reservations.
  • Follow-up:
    • Identify which Windows-side change and later operation would make a production shim meaningful.
    • Run the same EXEs against the real xmem.dll once #888 lands.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: prepared with Claude Code; the commands and results above were run on the author's PC.

🤖 Generated with Claude Code

**@⁠lukaslw-lab** on GitHub · 2026-11-23 16:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/891) `lukaslw-lab:gpu/configure-virtual-memory` → `main` · +339 −0 · 7 files · 2 commits · merged 2026-11-23 16:41 UTC ## Change Adds the source-built recording fixture R0Y00 asked for on #874. No `d3d12_xs.dll` export: what the call has to change on Windows is still open. Refs #874, #870. - `tests/cpu/configure_vm.asm`: two EXEs reproduce the main executable's call. Each passes a 32-byte zero-filled block with one DWORD sample at `+4` (3 or 4), with canaries on both sides. Each then makes two `XMemVirtualAlloc(NULL, size, 0x20402000, …)` reservations whatever the HRESULT was (16 GiB for 3, 24 GiB for 4). - `tests/cpu/configure_vm_recorder.cpp`: stand-ins named `d3d12_xs.dll` and `xmem.dll`, in their own `configure_vm` build directory. They only log each call and return a chosen HRESULT. They implement nothing. - `docs/experiments.md`: the observed call shape and the open questions: what the DWORD means, what the other 28 bytes are for, and what effect is required. This complements draft #888, which implements `XMemVirtualAlloc` in `xmem_shim`. This PR touches no shim. Once both land, the recorded reservation arguments match the shapes #888 accepts. ## Verification Commit `6eb3341` on Windows 10 22H2 (build 19045), Visual Studio 2026 18.12 (MSVC 19.52), Windows SDK 10.0.26100, CMake 4.3.1, Python 3.13.7. ctest --preset dev --no-tests=error -R '^(cpu_native_configure_vm|d3d12_xs_shim_.*|cpu_native_shim_startup|docs_links)$' 7 total: 7 passed, 0 skipped, 0 failed The same command with `--preset release` gave 7 passed, 0 skipped, 0 failed. `tests/bidi_controls_check.py` and `tests/docs_links_check.py` passed. `cpu_native_configure_vm` output (Release, sample 4; sample 3 is the same with `400000000`): sample 4 success: exit 0x0 under both loaders sample 4 failure HRESULT: exit 0x8007000e under both loaders sample 4 write inside block: exit 0x1 under both loaders sample 4 write after block: exit 0x2 under both loaders sample 4: D3D12ConfigureVirtualMemoryX 0000000004000000000000000000000000000000000000000000000000000000 | XMemVirtualAlloc 0 600000000 20402000 21 4 | XMemVirtualAlloc 0 600000000 20402000 3 801 ## Evidence and follow-up - **Fixture:** source-built (MASM, C++, Python), MIT. The call shape comes from a static read of the call site (file reads only, nothing executed) and is described in #874. No title bytes are included. - **Controls:** with either stand-in missing, `pe_map` stops at that import before the entry point. Stand-in writes inside or after the block are caught. A failure HRESULT reaches the exit code unchanged. - **Mutations:** three EXE mutations make the test fail. They removed a canary check, dropped the failure HRESULT, and moved the configuration call after the reservations. - **Follow-up:** - Identify which Windows-side change and later operation would make a production shim meaningful. - Run the same EXEs against the real `xmem.dll` once #888 lands. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. _AI-assisted: prepared with Claude Code; the commands and results above were run on the author's PC._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Two source-built EXEs reproduce the main executable's call (#874): a 32-byte
block with one DWORD sample at +4, then two XMemVirtualAlloc reservations.
Recording stand-ins named d3d12_xs.dll and xmem.dll log each call and return a
chosen HRESULT. Both loaders must log the same calls in order, propagate a
failure HRESULT, and catch writes inside or after the block. No shim export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:26:12 +00:00
github manually merged commit 9adf97c8f0 into gh-pr/891/base 2026-11-26 22:26:15 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 16:27 UTC · original

Review follow-up at 9adf97c. The original native EXE timed out locally after three successful comparisons even though it had a bounded body. The fixture now reuses the existing shared termination wrapper for the same image. Native runs start the test worker before process exit, and mapped runs return the original result to the host. Debug and Release each passed both input samples, failure propagation, both mutations and the missing-provider controls. The recorder still contains no production shim behavior. Fresh CI is running.

**@⁠R0Y00** on GitHub · 2026-11-23 16:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/891#issuecomment-7107173918) Review follow-up at `9adf97c`. The original native EXE timed out locally after three successful comparisons even though it had a bounded body. The fixture now reuses the existing shared termination wrapper for the same image. Native runs start the test worker before process exit, and mapped runs return the original result to the host. Debug and Release each passed both input samples, failure propagation, both mutations and the missing-provider controls. The recorder still contains no production shim behavior. Fresh CI is running.
This discussion has been locked. Commenting is limited to contributors.
No description provided.