runtime: add a source-built tools-memory availability fixture #896

Manually merged
github merged 3 commits from gh-pr/896/head into gh-pr/896/base 2026-11-26 22:26:39 +00:00
Owner

@⁠Holastor on GitHub · 2026-11-23 16:20 UTC · original
Holastor:xmem/tools-mem-available-fixture → main · +212 −0 · 7 files · 3 commits · merged 2026-11-23 17:03 UTC

Refs #870.

Overview

Following the binding of default allocator (#879) and physical pages (#880, #887), startup preflight mapping reaches xmem.dll!XMemIsToolsMemAvailable.

Per community evidence and the maintainer's note in #870, this PR provides an independent, source-built caller and controlled recording-provider fixture testing the contract without changing the production XMem shim:

  • cpu_tools_mem_caller.exe (tests/cpu/tools_mem_caller.asm): tiny standalone MASM executable that imports XMemIsToolsMemAvailable by name from xmem.dll, executes repeated calls to verify consistency, and branches cleanly on the BOOL result without stack or register corruption.
  • cpu_tools_mem_provider / cpu_tools_mem_provider_devkit (tests/cpu/tools_mem_provider.cpp / .def): controlled recording provider providing XMemIsToolsMemAvailable under both modes:
    • Mode FALSE (desktop policy / retail without tools partition): returns FALSE (0), caller takes the title fallback path (exit code 42), and provider records exactly 2 calls.
    • Mode TRUE (console devkit with tools partition): returns TRUE (1), caller takes the devkit path (exit code 84), and provider records exactly 2 calls.
  • pe_map comparison and negative controls (tests/cpu/tools_mem_check.py):
    • Both native (Windows loader) and pe_map (custom in-process loader) produce identical exit codes across both modes.
    • Map-time refusal before entry is verified when xmem.dll is missing, returning STATUS["unresolved"] with diagnostic unresolved import xmem.dll!XMemIsToolsMemAvailable.

Verification

Environment: Windows 11 x64, MSVC 19.51, CMake/Ninja, Python 3.11 (out/pe-env).

Dev preset

cmake --build --preset dev --target cpu_tools_mem_caller cpu_tools_mem_provider cpu_tools_mem_provider_devkit pe_map
ctest --preset dev --no-tests=error -R '^cpu_native_tools_mem$' -V

Output:

caller imports: {'xmem.dll': ['XMemIsToolsMemAvailable']}
mode FALSE (desktop without tools partition): native and mapped exit 42, 2 calls recorded
mode TRUE (console devkit with tools partition): native and mapped exit 84, 2 calls recorded
negative control: map time refusal before entry: unresolved import xmem.dll!XMemIsToolsMemAvailable
1/1 Test #275: cpu_native_tools_mem .............   Passed    0.16 sec

Release preset

cmake --build --preset release --target cpu_tools_mem_caller cpu_tools_mem_provider cpu_tools_mem_provider_devkit pe_map
ctest --preset release --no-tests=error -R '^cpu_native_tools_mem$' -V

Output:

caller imports: {'xmem.dll': ['XMemIsToolsMemAvailable']}
mode FALSE (desktop without tools partition): native and mapped exit 42, 2 calls recorded
mode TRUE (console devkit with tools partition): native and mapped exit 84, 2 calls recorded
negative control: map time refusal before entry: unresolved import xmem.dll!XMemIsToolsMemAvailable
1/1 Test #275: cpu_native_tools_mem .............   Passed    0.16 sec

Documentation & pure-Python checks

python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
python -B tests/form_coverage_check.py
git diff --check

All passed:

  • docs_links_check.py: Checked 13 Markdown files and 180 links.
  • bidi_controls_check.py: Checked 719 tracked source, script and build/CI files: no bidirectional controls.
  • form_coverage_check.py: form coverage checks passed.
  • git diff --check: 0 issues.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact test command and result for dev and release presets.
  • I considered a negative control or failure case for the new fixture.
  • I updated docs/experiments.md with the new capability and reproduction commands.
  • I did not include game files, dumps, distribution links or secrets.
**@⁠Holastor** on GitHub · 2026-11-23 16:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/896) `Holastor:xmem/tools-mem-available-fixture` → `main` · +212 −0 · 7 files · 3 commits · merged 2026-11-23 17:03 UTC Refs #870. ## Overview Following the binding of default allocator (#879) and physical pages (#880, #887), startup preflight mapping reaches `xmem.dll!XMemIsToolsMemAvailable`. Per community evidence and the maintainer's note in #870, this PR provides an independent, source-built caller and controlled recording-provider fixture testing the contract without changing the production XMem shim: - **`cpu_tools_mem_caller.exe`** (`tests/cpu/tools_mem_caller.asm`): tiny standalone MASM executable that imports `XMemIsToolsMemAvailable` by name from `xmem.dll`, executes repeated calls to verify consistency, and branches cleanly on the `BOOL` result without stack or register corruption. - **`cpu_tools_mem_provider` / `cpu_tools_mem_provider_devkit`** (`tests/cpu/tools_mem_provider.cpp` / `.def`): controlled recording provider providing `XMemIsToolsMemAvailable` under both modes: - **Mode FALSE** (desktop policy / retail without tools partition): returns `FALSE` (`0`), caller takes the title fallback path (exit code `42`), and provider records exactly 2 calls. - **Mode TRUE** (console devkit with tools partition): returns `TRUE` (`1`), caller takes the devkit path (exit code `84`), and provider records exactly 2 calls. - **`pe_map` comparison and negative controls** (`tests/cpu/tools_mem_check.py`): - Both native (Windows loader) and `pe_map` (custom in-process loader) produce identical exit codes across both modes. - Map-time refusal before entry is verified when `xmem.dll` is missing, returning `STATUS["unresolved"]` with diagnostic `unresolved import xmem.dll!XMemIsToolsMemAvailable`. ## Verification Environment: Windows 11 x64, MSVC 19.51, CMake/Ninja, Python 3.11 (`out/pe-env`). ### Dev preset ```powershell cmake --build --preset dev --target cpu_tools_mem_caller cpu_tools_mem_provider cpu_tools_mem_provider_devkit pe_map ctest --preset dev --no-tests=error -R '^cpu_native_tools_mem$' -V ``` Output: ``` caller imports: {'xmem.dll': ['XMemIsToolsMemAvailable']} mode FALSE (desktop without tools partition): native and mapped exit 42, 2 calls recorded mode TRUE (console devkit with tools partition): native and mapped exit 84, 2 calls recorded negative control: map time refusal before entry: unresolved import xmem.dll!XMemIsToolsMemAvailable 1/1 Test #275: cpu_native_tools_mem ............. Passed 0.16 sec ``` ### Release preset ```powershell cmake --build --preset release --target cpu_tools_mem_caller cpu_tools_mem_provider cpu_tools_mem_provider_devkit pe_map ctest --preset release --no-tests=error -R '^cpu_native_tools_mem$' -V ``` Output: ``` caller imports: {'xmem.dll': ['XMemIsToolsMemAvailable']} mode FALSE (desktop without tools partition): native and mapped exit 42, 2 calls recorded mode TRUE (console devkit with tools partition): native and mapped exit 84, 2 calls recorded negative control: map time refusal before entry: unresolved import xmem.dll!XMemIsToolsMemAvailable 1/1 Test #275: cpu_native_tools_mem ............. Passed 0.16 sec ``` ### Documentation & pure-Python checks ```powershell python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py python -B tests/form_coverage_check.py git diff --check ``` All passed: - `docs_links_check.py`: Checked 13 Markdown files and 180 links. - `bidi_controls_check.py`: Checked 719 tracked source, script and build/CI files: no bidirectional controls. - `form_coverage_check.py`: form coverage checks passed. - `git diff --check`: 0 issues. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact test command and result for dev and release presets. - [x] I considered a negative control or failure case for the new fixture. - [x] I updated `docs/experiments.md` with the new capability and reproduction commands. - [x] I did not include game files, dumps, distribution links or secrets.
Refs #870. Adds an independent source-built caller and controlled recording
provider fixture for xmem.dll!XMemIsToolsMemAvailable, verifying both BOOL
outcomes (desktop-without-tools-partition FALSE fallback and devkit TRUE)
under both the native Windows loader and pe_map, along with map-time refusal
on missing provider.
Reuse the startup wrapper and the per-process record and compare approach demonstrated by triggered02 in R0Y00/Xbox2Windows#900.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:26:38 +00:00
github manually merged commit 165337663e into gh-pr/896/base 2026-11-26 22:26:39 +00:00
Author
Owner

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

I reviewed 8e85283b alongside the #874 fixture. Please reuse the existing source-built EXE finish wrapper: this fixture still returns straight from the native /ENTRY, the same shape that hung under the Windows loader in #891. Preserve the mapped return and use the live-worker control for the native path. The two call counters are currently read only from the mapped process, so please label them as mapped counts unless the native subprocess records its own. The two providers establish the caller's behavior with controlled FALSE and TRUE returns. Please scope the documentation to those results until there is separate evidence for actual console or production-shim behavior.

**@⁠R0Y00** on GitHub · 2026-11-23 16:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/896#issuecomment-7107278762) I reviewed 8e85283b alongside the #874 fixture. Please reuse the existing source-built EXE finish wrapper: this fixture still returns straight from the native /ENTRY, the same shape that hung under the Windows loader in #891. Preserve the mapped return and use the live-worker control for the native path. The two call counters are currently read only from the mapped process, so please label them as mapped counts unless the native subprocess records its own. The two providers establish the caller's behavior with controlled FALSE and TRUE returns. Please scope the documentation to those results until there is separate evidence for actual console or production-shim behavior.
Author
Owner

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

The shared candidate is now 1a5148e. Thanks to Holastor for the repeated-query check and to triggered02 for the independent per-process record-and-compare evidence in #900. The same source-built EXE now uses the shared startup wrapper in both modes. Windows native launch exits with a live worker and pe_map returns to its host. The controlled providers produce exit 42 or 84 with two matching queries checked inside each process. With the trace export still supplied, withholding just XMemIsToolsMemAvailable fails at import resolution before entry. Independently passed cpu_native_tools_mem in Debug and Release on Windows x64. The production shim is unchanged.

**@⁠R0Y00** on GitHub · 2026-11-23 16:41 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/896#issuecomment-7107529851) The shared candidate is now 1a5148e. Thanks to Holastor for the repeated-query check and to triggered02 for the independent per-process record-and-compare evidence in #900. The same source-built EXE now uses the shared startup wrapper in both modes. Windows native launch exits with a live worker and pe_map returns to its host. The controlled providers produce exit 42 or 84 with two matching queries checked inside each process. With the trace export still supplied, withholding just XMemIsToolsMemAvailable fails at import resolution before entry. Independently passed cpu_native_tools_mem in Debug and Release on Windows x64. The production shim is unchanged.
This discussion has been locked. Commenting is limited to contributors.
No description provided.