runtime: export XMemTransferMemory with an explicit desktop refusal #977

Merged
Holastor merged 1 commit from upstream-pr/984 into main 2026-11-23 20:22:55 +00:00
Holastor commented 2026-11-23 19:49:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T19:49:47Z.


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.

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

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T19:57:34Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112353323 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/984#issuecomment-7112353323). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T19:57:34Z. --- 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.
Holastor commented 2026-11-24 06:49:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T20:06:58Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112582445 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/984#issuecomment-7112582445). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T20:06:58Z. --- 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.
Jess-Doit commented 2026-11-24 06:49:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-23T20:14:18Z.


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).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112778279 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/984#issuecomment-7112778279). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-23T20:14:18Z. --- 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://github.com/R0Y00/Xbox2Windows/issues/870#issuecomment-7110673477) 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).
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!977
No description provided.