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

Merged
Holastor merged 3 commits from upstream-pr/896 into main 2026-11-23 17:03:28 +00:00
Holastor commented 2026-11-23 16:20:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T16:20:28Z.


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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6563707934 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/896). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T16:20:28Z. --- 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.
upstream-sync closed this pull request 2026-11-24 06:45:18 +00:00
R0Y00 commented 2026-11-24 06:49:18 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7107278762 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/896#issuecomment-7107278762). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T16:31:58Z. --- 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 commented 2026-11-24 06:49:19 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7107529851 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/896#issuecomment-7107529851). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T16:41:43Z. --- 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.
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!889
No description provided.