runtime: answer XStoreCreateContext offline under the fake user #1463

Merged
SimSalabimse merged 3 commits from upstream-pr/1470 into main 2026-11-24 13:57:42 +00:00
SimSalabimse commented 2026-11-24 12:12:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-24T12:12:55Z.


Change

With X2W_RUNTIME_PROXY=1 and X2W_FAKE_USER=1, store-interface method 3
(XStoreCreateContext on provider 0dd112ac) writes one offline context
handle for the local user and returns success. It no longer falls through to
E_FAIL. Other store methods are not answered, and any other family that is
still passed the local user handle still returns 0x80004005.

The layout is the public GDK call (user, context out) at vtable slot 3, after
QueryInterface, AddRef and Release. The offline success matches the
VIctory runtime notes already cited in runtime_proxy.cpp: one context, and
catalog, licence and purchase calls left unanswered.

tests/startup_stub_check.py drives a store scenario on the source-built
consumer. The answered call prints the context handle. The same call with the
provider id mutated prints store refused 80004005 and leaves the output
unchanged. No system xgameruntime.dll is required.

Refs #1147

Verification

Commit ac0b5c8a on x2w-store-method-3, rebased onto origin/main
(c694231a). MSVC 19.42. Both presets reconfigured during the build and built
startup_stub_consumer.

ctest --preset dev --no-tests=error -R '^startup_stubs$' -V

Passed (1.86 s). Exports, trap exits, the none and physical controls, the
dstorage control, dstorage page-array control: exit=0 ok and
store context: exit=0 ok all passed.

ctest --preset release --no-tests=error -R '^startup_stubs$' -V

Passed (0.89 s), with the same page-array and store context: exit=0 ok lines.

No system xgameruntime.dll was installed. These checks do not load it.

Evidence and follow-up

The new case is source-built. It compiles runtime_proxy.cpp into the
existing stub consumer and calls the same forward path the GameInput
stand-in uses. There is no new binary fixture and no game data.

Assumption: method 3 of XStoreImpl (0dd112ac-7c24-448c-b92b-3960fb5bd30c)
is XStoreCreateContext, from the public GDK signature and the public runtime
class layout (first method after IUnknown). A null context pointer returns
0x80070057 and is not written. A user other than the local user is not
answered by this change.

Other store methods (catalog, licence, purchase) still hit the existing
E_FAIL fallback when they carry the local user handle. That is left for a
later change.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Grok Build).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6581508749 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1470). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-24T12:12:55Z. --- ## Change With `X2W_RUNTIME_PROXY=1` and `X2W_FAKE_USER=1`, store-interface method 3 (`XStoreCreateContext` on provider `0dd112ac`) writes one offline context handle for the local user and returns success. It no longer falls through to `E_FAIL`. Other store methods are not answered, and any other family that is still passed the local user handle still returns `0x80004005`. The layout is the public GDK call (user, context out) at vtable slot 3, after `QueryInterface`, `AddRef` and `Release`. The offline success matches the VIctory runtime notes already cited in `runtime_proxy.cpp`: one context, and catalog, licence and purchase calls left unanswered. `tests/startup_stub_check.py` drives a `store` scenario on the source-built consumer. The answered call prints the context handle. The same call with the provider id mutated prints `store refused 80004005` and leaves the output unchanged. No system `xgameruntime.dll` is required. Refs #1147 ## Verification Commit `ac0b5c8a` on `x2w-store-method-3`, rebased onto `origin/main` (`c694231a`). MSVC 19.42. Both presets reconfigured during the build and built `startup_stub_consumer`. `ctest --preset dev --no-tests=error -R '^startup_stubs$' -V` Passed (1.86 s). Exports, trap exits, the `none` and `physical` controls, the dstorage control, `dstorage page-array control: exit=0 ok` and `store context: exit=0 ok` all passed. `ctest --preset release --no-tests=error -R '^startup_stubs$' -V` Passed (0.89 s), with the same page-array and `store context: exit=0 ok` lines. No system `xgameruntime.dll` was installed. These checks do not load it. ## Evidence and follow-up The new case is source-built. It compiles `runtime_proxy.cpp` into the existing stub consumer and calls the same `forward` path the GameInput stand-in uses. There is no new binary fixture and no game data. Assumption: method 3 of `XStoreImpl` (`0dd112ac-7c24-448c-b92b-3960fb5bd30c`) is `XStoreCreateContext`, from the public GDK signature and the public runtime class layout (first method after `IUnknown`). A null context pointer returns `0x80070057` and is not written. A user other than the local user is not answered by this change. Other store methods (catalog, licence, purchase) still hit the existing `E_FAIL` fallback when they carry the local user handle. That is left for a later change. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Grok Build).
tedin7 commented 2026-11-24 13:00:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:57:36Z.

Review: COMMENTED


Reviewed at commit c26c3733a435b5a827953911ebbda616dbfa029b:

Code & Diff Audit

  • src/startup_stubs/api_trace.h and src/startup_stubs/runtime_proxy.cpp: answering XStoreCreateContext (0x0dd112ac slot 3) only when args[0] == local_user_handle is clean, validates out(args[1], 8) with 0x80070057 (E_INVALIDARG), and writes store_context_handle.
  • tests/startup_stub_consumer.cpp & tests/startup_stub_check.py: exercises the positive path under X2W_RUNTIME_PROXY=1 and X2W_FAKE_USER=1, mutated provider ID refusal (0x80004005 without modifying the output buffer), and null output pointer (0x80070057). Minor note: store_method3_check() does not include a negative control for a non-local user handle (args[0] != local_user_handle), though the guard in area_call() is straightforward.
  • Merge conflict: git merge-tree --write-tree origin/main HEAD reports a content merge conflict in docs/startup-runtime.md against current origin/main that needs a rebase/merge resolution.

Verification

  • Linux checks: tests/docs_links_check.py (16 files, 330 links), tests/bidi_controls_check.py (1,207 files), and git diff --check origin/main..HEAD all passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): startup_stubs 1/1 passed (0.49s; build 26.27s).
    • Release /O2 (--preset release): startup_stubs 1/1 passed (0.57s; build 39.97s).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6039586738 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1470#pullrequestreview-6039586738). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T12:57:36Z. **Review:** COMMENTED --- Reviewed at commit `c26c3733a435b5a827953911ebbda616dbfa029b`: ### Code & Diff Audit - `src/startup_stubs/api_trace.h` and `src/startup_stubs/runtime_proxy.cpp`: answering `XStoreCreateContext` (`0x0dd112ac` slot 3) only when `args[0] == local_user_handle` is clean, validates `out(args[1], 8)` with `0x80070057` (`E_INVALIDARG`), and writes `store_context_handle`. - `tests/startup_stub_consumer.cpp` & `tests/startup_stub_check.py`: exercises the positive path under `X2W_RUNTIME_PROXY=1` and `X2W_FAKE_USER=1`, mutated provider ID refusal (`0x80004005` without modifying the output buffer), and null output pointer (`0x80070057`). Minor note: `store_method3_check()` does not include a negative control for a non-local user handle (`args[0] != local_user_handle`), though the guard in `area_call()` is straightforward. - **Merge conflict**: `git merge-tree --write-tree origin/main HEAD` reports a content merge conflict in `docs/startup-runtime.md` against current `origin/main` that needs a rebase/merge resolution. ### Verification - **Linux checks**: `tests/docs_links_check.py` (16 files, 330 links), `tests/bidi_controls_check.py` (1,207 files), and `git diff --check origin/main..HEAD` all passed. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`): `startup_stubs` **1/1 passed** (`0.49s`; build `26.27s`). - Release `/O2` (`--preset release`): `startup_stubs` **1/1 passed** (`0.57s`; build `39.97s`).
upstream-sync closed this pull request 2026-11-24 14:02:48 +00:00
SimSalabimse commented 2026-11-24 14:03:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-24T13:24:46Z.


@tedin7 Thanks for the review. The docs/startup-runtime.md conflict was already resolved in ac0b5c8a (rebased onto c694231a).

Added the non-local user control in 6a87f6a0: store_method3_check() now calls XStoreCreateContext with local_user_handle ^ 1 and requires 0x80004005 with the output left at 0x1111111111111111. area_call() now refuses a non-local user explicitly instead of falling through to the real method.

Retested on Windows 11 26200, MSVC 19.42: startup_stubs passes in dev (1.15 s) and release (0.79 s), ctest exit 0 for both.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7132792232 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1470#issuecomment-7132792232). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-24T13:24:46Z. --- @tedin7 Thanks for the review. The docs/startup-runtime.md conflict was already resolved in ac0b5c8a (rebased onto c694231a). Added the non-local user control in 6a87f6a0: store_method3_check() now calls XStoreCreateContext with local_user_handle ^ 1 and requires 0x80004005 with the output left at 0x1111111111111111. area_call() now refuses a non-local user explicitly instead of falling through to the real method. Retested on Windows 11 26200, MSVC 19.42: startup_stubs passes in dev (1.15 s) and release (0.79 s), ctest exit 0 for both. AI-Assisted
R0Y00 commented 2026-11-24 14:03:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T13:51:17Z.


Maintainer update at d8af3c18 matches the full provider GUID. Windows Release source-built store control accepts the local context for that provider and refuses the same first GUID word with a different suffix, a foreign user, and a missing output pointer. Commerce and licensing remain outside the fixture scope.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7133435516 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1470#issuecomment-7133435516). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T13:51:17Z. --- Maintainer update at d8af3c18 matches the full provider GUID. Windows Release source-built store control accepts the local context for that provider and refuses the same first GUID word with a different suffix, a foreign user, and a missing output pointer. Commerce and licensing remain outside the fixture scope.
ChazY11 commented 2026-11-24 16:03:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T15:27:36Z.


Both halves of the offline answer are covered — the user check and the handle itself

Independent reviewer, not the author. Reviewed the current head; nothing pushed to the branch. Mutations were made
locally in src/startup_stubs/runtime_proxy.cpp, reverted between each; working tree is clean.

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^startup_stubs$' -V
store context: exit=0 ok        -> startup_stubs PASSED (3.00 s)

xgameruntime_contracts and xgameruntime_preflight_stub_refused also pass on this head; I ran them because they share
the shim surface.

Mutation 1 — the non-local user is no longer refused

-            if (args[0] != local_user_handle) {
+            if (false) {
store context: exit=7 MISMATCH
-> 0x0 (local user)   for 0x5832575500000001   (the local user)
-> 0x80004005         ... left as before
-> 0x5832575500000000 -> 0x0   the non-local user now gets a context

The fixture prints the call trace and catches it, so "only the local user is answered" is asserted rather than described.
Note the trace also shows the non-local handle differing only in the last word, which is exactly the case a sloppy
pointer comparison would miss.

Mutation 2 — the answer writes a zero handle instead of the context

-            *reinterpret_cast<u64*>(args[1]) = store_context_handle;
+            *reinterpret_cast<u64*>(args[1]) = 0;
store context: exit=4 MISMATCH

So the returned handle is checked, not only the HRESULT: a success with a null context is still a failure here.

What I did not drive

The E_INVALIDARG path for an unwritable output buffer. Forcing it means passing a bad pointer through the proxy, which
would fault in the test process rather than exercise the guard, so I left it — if there is a way you test it that I am
missing, say so and I will run it.

Verdict

Reviewed the current head. Builds clean, the consumer passes, and two independent mutations are caught with distinct exit
codes (7 and 4). No objection from me.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7136062086 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1470#issuecomment-7136062086). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T15:27:36Z. --- ## Both halves of the offline answer are covered — the user check and the handle itself Independent reviewer, not the author. Reviewed the current head; nothing pushed to the branch. Mutations were made locally in `src/startup_stubs/runtime_proxy.cpp`, reverted between each; working tree is clean. Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100. ```powershell cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R '^startup_stubs$' -V ``` ```text store context: exit=0 ok -> startup_stubs PASSED (3.00 s) ``` `xgameruntime_contracts` and `xgameruntime_preflight_stub_refused` also pass on this head; I ran them because they share the shim surface. ### Mutation 1 — the non-local user is no longer refused ```diff - if (args[0] != local_user_handle) { + if (false) { ``` ```text store context: exit=7 MISMATCH -> 0x0 (local user) for 0x5832575500000001 (the local user) -> 0x80004005 ... left as before -> 0x5832575500000000 -> 0x0 the non-local user now gets a context ``` The fixture prints the call trace and catches it, so "only the local user is answered" is asserted rather than described. Note the trace also shows the non-local handle differing only in the last word, which is exactly the case a sloppy pointer comparison would miss. ### Mutation 2 — the answer writes a zero handle instead of the context ```diff - *reinterpret_cast<u64*>(args[1]) = store_context_handle; + *reinterpret_cast<u64*>(args[1]) = 0; ``` ```text store context: exit=4 MISMATCH ``` So the returned handle is checked, not only the `HRESULT`: a success with a null context is still a failure here. ### What I did not drive The `E_INVALIDARG` path for an unwritable output buffer. Forcing it means passing a bad pointer through the proxy, which would fault in the test process rather than exercise the guard, so I left it — if there is a way you test it that I am missing, say so and I will run it. ### Verdict Reviewed the current head. Builds clean, the consumer passes, and two independent mutations are caught with distinct exit codes (7 and 4). No objection from me.
SimSalabimse commented 2026-11-24 18:02:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-24T17:38:03Z.


@ChazY11 Thanks for the independent review and the two mutations. I don't drive the E_INVALIDARG path either: a bad output pointer faults before the guard can be observed, so it is only covered by reading the code.

AI-assisted (Grok Build)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139481602 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1470#issuecomment-7139481602). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-24T17:38:03Z. --- @ChazY11 Thanks for the independent review and the two mutations. I don't drive the E_INVALIDARG path either: a bad output pointer faults before the guard can be observed, so it is only covered by reading the code. AI-assisted (Grok Build)
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!1463
No description provided.