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

Merged
lukaslw-lab merged 2 commits from upstream-pr/891 into main 2026-11-23 16:41:40 +00:00
lukaslw-lab commented 2026-11-23 16:13:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-23T16:13:42Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6563577549 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/891). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-23T16:13:42Z. --- ## 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)
upstream-sync closed this pull request 2026-11-24 06:45:16 +00:00
R0Y00 commented 2026-11-24 06:49:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T16:27:53Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7107173918 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/891#issuecomment-7107173918). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T16:27:53Z. --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!884
No description provided.