runtime: export XMemTransferMemory with an explicit desktop refusal #984

Manually merged
github merged 1 commit from gh-pr/984/head into gh-pr/984/base 2026-11-26 22:33:03 +00:00
Owner

@⁠Holastor on GitHub · 2026-11-23 19:49 UTC · original
Holastor:xmem/transfer-runtime-export → main · +146 −3 · 5 files · 1 commits · merged 2026-11-23 20:22 UTC

Export XMemTransferMemory from xmem.dll (assigned ordinal @13) with a narrow desktop refusal semantics and verification of state preservation.

Following the merged prerequisite and failure-chain fixtures (#935 and #955), this runtime export resolves the missing import (xmem.dll!XMemTransferMemory) identified during runtime import binding preflight in #870.

Behavior

  1. Narrow desktop refusal:
    • On a no-tools desktop runtime (XMemIsToolsMemAvailable() == FALSE per #896), returns FALSE with ERROR_NOT_SUPPORTED (50).
    • Without independent evidence for runtime parameter validation returning ERROR_INVALID_PARAMETER (87), all calls take this narrow refusal. Never reports unbacked ownership transfer.
  2. Memory and accounting preservation:
    • Invoking XMemTransferMemory under existing caller sequences (including partition 1, 2 MiB / 16 MiB counts, and variant inputs) leaves heap allocations, GPU graphics allocations, era_query registration, physical page grants, tools memory status, and working-set statistics untouched.
  3. Evidence vs resolution distinction:
    • Resolving this export allows PE import binding (IAT resolution) to succeed at load time, resolving the status 5 missing export blocker.
    • This load-time resolution is strictly distinguished from establishing that an application's startup sequence can proceed past an unsupported transfer.
  4. Export and ordinal:
    • Exported as XMemTransferMemory @13 in src/xmem_shim.def.

Verification

cmake --build --preset dev --target xmem_shim xmem_shim_check
ctest --preset dev --no-tests=error -R '^xmem_shim_' -V
test 24: xmem_shim_exports ................... Passed (13 exports verified)
test 29: xmem_shim_transfer_memory ........... Passed (8 cases, memory_accounting_intact=1)
100% tests passed, 0 tests failed out of 12 (0.48 sec)

Release build:

cmake --build --preset release --target xmem_shim xmem_shim_check
ctest --preset release --no-tests=error -R '^xmem_shim_' -V
100% tests passed, 0 tests failed out of 12 (0.39 sec)

Documentation and hygiene checks:

.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
.\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py

All passed.

Refs #870.

**@⁠Holastor** on GitHub · 2026-11-23 19:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/984) `Holastor:xmem/transfer-runtime-export` → `main` · +146 −3 · 5 files · 1 commits · merged 2026-11-23 20:22 UTC Export `XMemTransferMemory` from `xmem.dll` (assigned ordinal `@13`) with a narrow desktop refusal semantics and verification of state preservation. Following the merged prerequisite and failure-chain fixtures (#935 and #955), this runtime export resolves the missing import (`xmem.dll!XMemTransferMemory`) identified during runtime import binding preflight in #870. ### Behavior 1. **Narrow desktop refusal**: - On a no-tools desktop runtime (`XMemIsToolsMemAvailable() == FALSE` per #896), returns `FALSE` with `ERROR_NOT_SUPPORTED` (50). - Without independent evidence for runtime parameter validation returning `ERROR_INVALID_PARAMETER` (87), all calls take this narrow refusal. Never reports unbacked ownership transfer. 2. **Memory and accounting preservation**: - Invoking `XMemTransferMemory` under existing caller sequences (including partition 1, 2 MiB / 16 MiB counts, and variant inputs) leaves heap allocations, GPU graphics allocations, `era_query` registration, physical page grants, tools memory status, and working-set statistics untouched. 3. **Evidence vs resolution distinction**: - Resolving this export allows PE import binding (IAT resolution) to succeed at load time, resolving the status 5 missing export blocker. - This load-time resolution is strictly distinguished from establishing that an application's startup sequence can proceed past an unsupported transfer. 4. **Export and ordinal**: - Exported as `XMemTransferMemory @13` in `src/xmem_shim.def`. ### Verification ```powershell cmake --build --preset dev --target xmem_shim xmem_shim_check ctest --preset dev --no-tests=error -R '^xmem_shim_' -V ``` ``` test 24: xmem_shim_exports ................... Passed (13 exports verified) test 29: xmem_shim_transfer_memory ........... Passed (8 cases, memory_accounting_intact=1) 100% tests passed, 0 tests failed out of 12 (0.48 sec) ``` Release build: ```powershell cmake --build --preset release --target xmem_shim xmem_shim_check ctest --preset release --no-tests=error -R '^xmem_shim_' -V ``` ``` 100% tests passed, 0 tests failed out of 12 (0.39 sec) ``` Documentation and hygiene checks: ```powershell .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py .\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py ``` All passed. Refs #870.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:33:02 +00:00
github manually merged commit 88e454d465 into gh-pr/984/base 2026-11-26 22:33:03 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 19:57 UTC · original

Thanks for keeping the no-tools path a real refusal. #935 and #955 establish the recorder's inputs and the caller's failure path. They do not establish partition 1, 2 MiB alignment, or the 16 MiB cap as runtime validation rules. Please cite independent evidence for any input that must return 87. With only the current evidence, use a narrow desktop refusal and verify it leaves memory/accounting unchanged under the existing caller sequence. Also distinguish a resolved import that refuses transfer from evidence that the startup path can proceed past the call.

**@⁠R0Y00** on GitHub · 2026-11-23 19:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/984#issuecomment-7112353323) Thanks for keeping the no-tools path a real refusal. #935 and #955 establish the recorder's inputs and the caller's failure path. They do not establish partition 1, 2 MiB alignment, or the 16 MiB cap as runtime validation rules. Please cite independent evidence for any input that must return 87. With only the current evidence, use a narrow desktop refusal and verify it leaves memory/accounting unchanged under the existing caller sequence. Also distinguish a resolved import that refuses transfer from evidence that the startup path can proceed past the call.
Author
Owner

@⁠Holastor on GitHub · 2026-11-23 20:06 UTC · original

Thanks @⁠R0Y00, that makes total sense. Updated in commit 88e454d:

  1. Narrow desktop refusal:

    • Removed the speculative parameter validation checks for partition 1, 2 MiB alignment, and 16 MiB cap returning ERROR_INVALID_PARAMETER (87), as #935 and #955 establish the recorder's inputs and failure paths rather than production runtime parameter validation rules.
    • Replaced with a narrow desktop refusal: on a no-tools desktop runtime, XMemTransferMemory unconditionally sets ERROR_NOT_SUPPORTED and returns FALSE.
  2. Memory and accounting preservation verification:

    • Extended tests/xmem_shim_check.cpp (xmem_shim_transfer_memory) to verify that calling XMemTransferMemory across existing caller sequences (including partition 1, 2 MiB and 16 MiB counts, as well as variant inputs) leaves:
      • existing heap allocations intact with unmodified bytes;
      • existing GPU allocations registered with era_query intact with unmodified bytes;
      • physical page grants intact and cleanly freeable;
      • tools-memory availability query untouched (FALSE);
      • working-set statistics unchanged.
  3. Distinguishing import resolution from startup progression:

    • Updated docs/experiments.md and the PR summary to explicitly distinguish that resolving the missing export allows PE import binding to succeed at load time (clearing the status 5 unresolved import), but does not establish that the startup path can proceed past an unsupported transfer.

Both dev and release presets build and pass 12/12 xmem_shim_* tests locally, and all repository hygiene checks pass.

**@⁠Holastor** on GitHub · 2026-11-23 20:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/984#issuecomment-7112582445) Thanks @⁠R0Y00, that makes total sense. Updated in commit `88e454d`: 1. **Narrow desktop refusal**: - Removed the speculative parameter validation checks for partition 1, 2 MiB alignment, and 16 MiB cap returning `ERROR_INVALID_PARAMETER` (87), as #935 and #955 establish the recorder's inputs and failure paths rather than production runtime parameter validation rules. - Replaced with a narrow desktop refusal: on a no-tools desktop runtime, `XMemTransferMemory` unconditionally sets `ERROR_NOT_SUPPORTED` and returns `FALSE`. 2. **Memory and accounting preservation verification**: - Extended `tests/xmem_shim_check.cpp` (`xmem_shim_transfer_memory`) to verify that calling `XMemTransferMemory` across existing caller sequences (including partition 1, 2 MiB and 16 MiB counts, as well as variant inputs) leaves: - existing heap allocations intact with unmodified bytes; - existing GPU allocations registered with `era_query` intact with unmodified bytes; - physical page grants intact and cleanly freeable; - tools-memory availability query untouched (`FALSE`); - working-set statistics unchanged. 3. **Distinguishing import resolution from startup progression**: - Updated `docs/experiments.md` and the PR summary to explicitly distinguish that resolving the missing export allows PE import binding to succeed at load time (clearing the status 5 unresolved import), but does not establish that the startup path can proceed past an unsupported transfer. Both `dev` and `release` presets build and pass 12/12 `xmem_shim_*` tests locally, and all repository hygiene checks pass.
Author
Owner

@⁠Jess-Doit on GitHub · 2026-11-23 20:14 UTC · original

Independent Windows 10 check of 88e454d (22H2 19045.6456, MSVC 19.44 x64, Release). Eight focused XMem tests passed, including xmem_shim_transfer_memory and xmem_shim_mapped_pages.

The same binding-only probe as the #870 checkpoint bound 217 imports in two runs and stopped with status 5 at d3d12_xs.dll!D3D12ConfigureVirtualMemoryX. Withholding only XMemTransferMemory reproduced the prior 174-import stop at that name. The probe stops at import binding, before executable initialization or calling the transfer function.

AI-assisted (Codex).

**@⁠Jess-Doit** on GitHub · 2026-11-23 20:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/984#issuecomment-7112778279) Independent Windows 10 check of `88e454d` (22H2 19045.6456, MSVC 19.44 x64, Release). Eight focused XMem tests passed, including `xmem_shim_transfer_memory` and `xmem_shim_mapped_pages`. The same binding-only probe as the [#870 checkpoint](https://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/870) bound 217 imports in two runs and stopped with status 5 at `d3d12_xs.dll!D3D12ConfigureVirtualMemoryX`. Withholding only `XMemTransferMemory` reproduced the prior 174-import stop at that name. The probe stops at import binding, before executable initialization or calling the transfer function. AI-assisted (Codex).
This discussion has been locked. Commenting is limited to contributors.
No description provided.