tests: record the XMemIsToolsMemAvailable caller's branch #904

Closed
rasptum wants to merge 1 commit from upstream-pr/911 into main
rasptum commented 2026-11-23 16:52:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T16:52:36Z.


Refs #870

Fixture-only slice for xmem.dll!XMemIsToolsMemAvailable, per R0Y00's 16:04Z note on #870. It adds no production XMem edit: src/xmem_shim.* is untouched and stays behind #880/#892.

What it adds

  • tests/cpu/tools_mem_caller.asm: a source-built EXE without a C runtime. It imports XMemIsToolsMemAvailable by name from xmem.dll and starts through exe_startup.asm. It calls three times, requires the same answer (0 or 1) each time, then records its branch as the exit code: 0x7100 for FALSE (continue without tools memory), 0x7101 for TRUE, 0xF00 + step on a failed step.
  • tests/cpu/tools_mem_provider.cpp + .def: a test-only recording provider built as xmem.dll in its own build folder. It is not the desktop shim. TOOLS_MEM_RESULT = 0, 1 or flip picks the answer, and every call appends query <n> <result> to TOOLS_MEM_RECORD. If unconfigured, it returns 2. tools_mem_provider_missing.def builds the same provider without the export.
  • tests/cpu/tools_mem_caller_check.py, CTest cpu_native_xmem_tools_mem_caller: checks the import table with pefile, then runs each case under the Windows loader and under pe_map_image + pe_map_run in a child process.
  • A separate CMake block and a separate docs/experiments.md subsection.

Expected vs observed

The PE import table lists xmem.dll!XMemIsToolsMemAvailable by name, not by ordinal. The mapped resolver requests exactly that name and cpu_exe_io.dll!finish_exe.

Case Windows pe_map Record (both)
FALSE: desktop without a tools partition (proposed desktop policy) 0x7100 0x7100 query 1 0, query 2 0, query 3 0
TRUE 0x7101 0x7101 query 1 1, query 2 1, query 3 1
Control: answer alternates 0xf02 0xf02 query 1 0, query 2 1
Control: provider unconfigured (returns 2) 0xf01 0xf01 query 1 2
Control: provider without the export 0xc0000139 status 5, unresolved import xmem.dll!XMemIsToolsMemAvailable, not started empty, 0 calls

Swapping the outcome changes the recorded branch under both loaders (0x7100 vs 0x7101). Repeated FALSE calls return the same value and the provider's call count matches the record. Observed as expected in dev and release. No capability skips.

Mutation (one-off, not in CI): with the caller's comparison after the second call removed, the test failed. Both loaders exited 0x7100 instead of 0xf02 for the alternating provider.

Scope and hypotheses

  • FALSE for a desktop without a tools partition is proposed desktop policy. It follows triggered02's evidence from the public reimplementation (omonkeyz/xbox-emulator f89e410, crates/compat/xmem/src/stats.rs:330-355).
  • That reimplementation checks a console mode before its partition lookup. This fixture does not settle the console ordering. It also does not show that any real startup caller continues on FALSE: the caller is synthetic, and its two branches are labels.
  • The signature BOOL XMemIsToolsMemAvailable(void) is an assumption. The caller passes no arguments.
  • The #870 binding boundary does not move. The desktop xmem.dll still lacks this export.

Environment and commands

Commit 270359e, based on origin/main 3dfe3a9. Windows 10 Pro 10.0.19045.6466, MSVC 19.44.35207 x64 (VS 2022 Build Tools), CMake/Ninja. Source-built inputs only.

cmake --preset dev
cmake --build --preset dev --target pe_map cpu_tools_mem_caller cpu_tools_mem_provider cpu_tools_mem_provider_missing cpu_exe_io
ctest --preset dev --no-tests=error -R '^cpu_native_xmem_tools_mem_caller$' -V

The same three commands with release: both 1/1 passed. tests/form_coverage_check.py, tests/docs_links_check.py and tests/bidi_controls_check.py passed.

Five unrelated commits (CPU fuzz tooling, an LDS shader lowering) merged into main during the final retest. git merge-tree with the current origin/main is clean, and none of those commits touch these files.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6564309194 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/911). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-23T16:52:36Z. --- Refs #870 Fixture-only slice for `xmem.dll!XMemIsToolsMemAvailable`, per R0Y00's 16:04Z note on #870. It adds no production XMem edit: `src/xmem_shim.*` is untouched and stays behind #880/#892. ## What it adds - `tests/cpu/tools_mem_caller.asm`: a source-built EXE without a C runtime. It imports `XMemIsToolsMemAvailable` by name from `xmem.dll` and starts through `exe_startup.asm`. It calls three times, requires the same answer (0 or 1) each time, then records its branch as the exit code: `0x7100` for FALSE (continue without tools memory), `0x7101` for TRUE, `0xF00 + step` on a failed step. - `tests/cpu/tools_mem_provider.cpp` + `.def`: a test-only recording provider built as `xmem.dll` in its own build folder. It is not the desktop shim. `TOOLS_MEM_RESULT` = `0`, `1` or `flip` picks the answer, and every call appends `query <n> <result>` to `TOOLS_MEM_RECORD`. If unconfigured, it returns 2. `tools_mem_provider_missing.def` builds the same provider without the export. - `tests/cpu/tools_mem_caller_check.py`, CTest `cpu_native_xmem_tools_mem_caller`: checks the import table with `pefile`, then runs each case under the Windows loader and under `pe_map_image` + `pe_map_run` in a child process. - A separate CMake block and a separate `docs/experiments.md` subsection. ## Expected vs observed The PE import table lists `xmem.dll!XMemIsToolsMemAvailable` by name, not by ordinal. The mapped resolver requests exactly that name and `cpu_exe_io.dll!finish_exe`. | Case | Windows | `pe_map` | Record (both) | | --- | --- | --- | --- | | FALSE: desktop without a tools partition (proposed desktop policy) | `0x7100` | `0x7100` | `query 1 0`, `query 2 0`, `query 3 0` | | TRUE | `0x7101` | `0x7101` | `query 1 1`, `query 2 1`, `query 3 1` | | Control: answer alternates | `0xf02` | `0xf02` | `query 1 0`, `query 2 1` | | Control: provider unconfigured (returns 2) | `0xf01` | `0xf01` | `query 1 2` | | Control: provider without the export | `0xc0000139` | status 5, `unresolved import xmem.dll!XMemIsToolsMemAvailable`, not started | empty, 0 calls | Swapping the outcome changes the recorded branch under both loaders (`0x7100` vs `0x7101`). Repeated FALSE calls return the same value and the provider's call count matches the record. Observed as expected in dev and release. No capability skips. Mutation (one-off, not in CI): with the caller's comparison after the second call removed, the test failed. Both loaders exited `0x7100` instead of `0xf02` for the alternating provider. ## Scope and hypotheses - FALSE for a desktop without a tools partition is **proposed desktop policy**. It follows triggered02's evidence from the public reimplementation (omonkeyz/xbox-emulator `f89e410`, `crates/compat/xmem/src/stats.rs:330-355`). - That reimplementation checks a console mode before its partition lookup. This fixture does **not** settle the console ordering. It also does **not** show that any real startup caller continues on FALSE: the caller is synthetic, and its two branches are labels. - The signature `BOOL XMemIsToolsMemAvailable(void)` is an assumption. The caller passes no arguments. - The #870 binding boundary does not move. The desktop `xmem.dll` still lacks this export. ## Environment and commands Commit `270359e`, based on `origin/main` `3dfe3a9`. Windows 10 Pro 10.0.19045.6466, MSVC 19.44.35207 x64 (VS 2022 Build Tools), CMake/Ninja. Source-built inputs only. ```powershell cmake --preset dev cmake --build --preset dev --target pe_map cpu_tools_mem_caller cpu_tools_mem_provider cpu_tools_mem_provider_missing cpu_exe_io ctest --preset dev --no-tests=error -R '^cpu_native_xmem_tools_mem_caller$' -V ``` The same three commands with `release`: both 1/1 passed. `tests/form_coverage_check.py`, `tests/docs_links_check.py` and `tests/bidi_controls_check.py` passed. Five unrelated commits (CPU fuzz tooling, an LDS shader lowering) merged into `main` during the final retest. `git merge-tree` with the current `origin/main` is clean, and none of those commits touch these files. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:45:22 +00:00
rasptum commented 2026-11-24 06:49:20 +00:00 (Migrated from github.com)

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


Closing as a duplicate. This slice was released on #870 and R0Y00 named #896 the single landing PR for the XMemIsToolsMemAvailable fixture. This PR was opened by mistake after that decision. Sorry for the noise. If anything here is useful to #896 (for example the repeated-call or swapped-outcome controls), happy to pass it along there.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7107908043 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/911#issuecomment-7107908043). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-23T16:56:28Z. --- Closing as a duplicate. This slice was released on #870 and R0Y00 named #896 the single landing PR for the XMemIsToolsMemAvailable fixture. This PR was opened by mistake after that decision. Sorry for the noise. If anything here is useful to #896 (for example the repeated-call or swapped-outcome controls), happy to pass it along there. AI-assisted (Claude Code).

Pull request closed

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!904
No description provided.