runtime: answer XStoreCreateContext offline under the fake user #1470

Manually merged
github merged 3 commits from gh-pr/1470/head into gh-pr/1470/base 2026-11-26 23:09:43 +00:00
Owner

@⁠SimSalabimse on GitHub · 2026-11-24 12:12 UTC · original
SimSalabimse:x2w-store-method-3 → main · +91 −5 · 6 files · 3 commits · merged 2026-11-24 13:57 UTC

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

**@⁠SimSalabimse** on GitHub · 2026-11-24 12:12 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1470) `SimSalabimse:x2w-store-method-3` → `main` · +91 −5 · 6 files · 3 commits · merged 2026-11-24 13:57 UTC ## 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).
XStoreCreateContext for the local user writes one context handle instead of
E_FAIL. A mutated provider still fails, covered by startup_stubs.

Refs #1147
XStoreCreateContext now returns 0x80004005 for a user other than the local
one and leaves the output buffer unchanged. startup_stubs calls that case.

Refs #1147
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:09:42 +00:00
github manually merged commit d8af3c18eb into gh-pr/1470/base 2026-11-26 23:09:43 +00:00
Author
Owner

@⁠SimSalabimse on GitHub · 2026-11-24 13:24 UTC · original

@⁠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

**@⁠SimSalabimse** on GitHub · 2026-11-24 13:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1470#issuecomment-7132792232) @⁠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
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 13:51 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-24 13:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1470#issuecomment-7133435516) 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.
Author
Owner

@⁠ChazY11 on GitHub · 2026-11-24 15:27 UTC · original

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.

**@⁠ChazY11** on GitHub · 2026-11-24 15:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1470#issuecomment-7136062086) ## 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.
Author
Owner

@⁠SimSalabimse on GitHub · 2026-11-24 17:38 UTC · original

@⁠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)

**@⁠SimSalabimse** on GitHub · 2026-11-24 17:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1470#issuecomment-7139481602) @⁠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)
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 12:57 UTC · original · reviewed

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).
**@⁠tedin7** on GitHub · 2026-11-24 12:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1470#pullrequestreview-6039586738) · **reviewed** 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`).
This discussion has been locked. Commenting is limited to contributors.
No description provided.