Skip to content

xgameruntime: serve XStoreImpl (offline store) through QueryApiImpl - #3550

Closed
romainveurrier wants to merge 3 commits into
ItsNotRexed:mainfrom
romainveurrier:rt/xstoreimpl
Closed

romainveurrier wants to merge 3 commits into
ItsNotRexed:mainfrom
romainveurrier:rt/xstoreimpl

Conversation

@romainveurrier

@romainveurrier romainveurrier commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Item: new RT item, claimed in #3381 (claim).

Why

A GDK title links the XStore* functions statically (xgameruntime.lib). Each thunk asks QueryApiImpl for XStoreImpl and calls one slot with the function's own arguments after this, the mechanism docs/runtime_imports.md measures on the package's DLLs. QueryApiImpl refused the class outright, so every store call failed with "class not provided" before the title could even create a store context.

What

runtime/shims/xgameruntime_store.cpp, in its own file, hooked into QueryApiImpl with one line, like #3363 (XUserImpl). The two PRs touch adjacent lines there, so whichever lands second needs a one-line rebase.

  • Sources: class and interface ids and the slot order come from xgameruntime-docs (facts only). Signatures, enum values and error codes come from Microsoft's public GDK reference (the XStore pages), each checked on its page. No GDK header or library code is used.
  • Interfaces: the class id doubles as IXStoreImpl's; IXStoreImpl2–6 answer with the same 84-slot vtable (3 + 67 + 1 + 2 + 4 + 5 + 2).
  • Licenses: never claimed. Offline, nothing can establish that the player owns the game or its content, and answering "licensed" without entitlement evidence would be a license-check workaround (thanks @kacper-serewis). So:
    • XStoreQueryGameLicenseAsync, XStoreAcquireLicenseForPackageAsync and XStoreAcquireLicenseForDurablesAsync (and their Results) fail before starting, like the other store-service calls below.
    • No license handle is ever handed out, so XStoreIsLicenseValid is false for anything, and license-lost registration refuses anything that isn't a license.
  • What it does answer (none of it grants anything):
    • A store context can be created and closed.
    • Empty add-on licenses, product listings (a query that enumerates nothing and has no further page) and package updates.
    • License-changed registration hands out tokens.
    • XStoreQueryPackageIdentifier is E_GAMEPACKAGE_NO_PACKAGE_IDENTIFIER.
  • Not available offline: every call that needs the store service or a store UI fails before starting with HRESULT_FROM_WIN32(ERROR_NETWORK_UNREACHABLE), so no XAsyncBlock is left waiting. That covers the license queries above, XStoreCanAcquireLicenseFor*, purchases, consumables, collection and purchase ids, license tokens, rate-and-review, redeem, gifting, product pages and downloads.
  • Unknown slots: the docs' three unknown slots (46–48) answer E_NOTIMPL and log once. IXStoreImpl2's undocumented XStoreIsAvailabilityPurchasable (70) is read as a bool and answers false.
  • Handles: context and product-query handles are validated by lookup in a live map, never dereferenced, so a closed or foreign pointer is refused without touching memory and a double close does nothing.

Not measured yet: no package DLL calls an XStore* slot (libHttpClient.GDK.dll only holds the GUID table), so the slot order rests on xgameruntime-docs until the executable's first boot. docs/runtime_imports.md says so.

Tests

xgameruntime_store_test (30 checks) gets the class through rt::shims::find("xgameruntime.dll", "QueryApiImpl") and calls the served slots with the documented arguments.

  • Ids: every interface id is parsed from its text as xgameruntime-docs prints it, so mistyped GUID bytes would fail.
  • Licenses: the game-license query fails and leaves the title's buffer untouched; package and durable license acquisition fail for known-looking, empty and unknown ids; XStoreIsLicenseValid is false for null, a context and arbitrary memory.
  • Other calls: add-on and update counts, product query enumeration, registrations, the offline failures, the unknown slots.
  • Handles: the open-handle count is back to 0 at the end, and a double close does nothing.

Tested

Fedora 44, clang-cl 22.1.8 with xwin (SDK 10.0.26100), /W4: no warnings in the new files.

  • Under Wine 11.21: xgameruntime and xgameruntime_store pass.
  • Full suite: the only failures don't involve this change:
    • device_proxy also fails on main.
    • winhttp_offline is intermittent (HANDLE_CLOSING timing): it passed 1 of 3 runs of the same binary, and it builds only winhttp_offline.cpp + registry.cpp.
  • @kacper-serewis ran both tests on native Windows x64 (MSVC 19.50) at the first head.
  • scripts/build_runtime.ps1's source list includes the new file.

No game files. AI-assisted (Claude Code).

🤖 Generated with Claude Code

A GDK title links the XStore* functions statically (xgameruntime.lib); each
thunk asks QueryApiImpl for XStoreImpl and calls one slot. QueryApiImpl
refused the class, so the license check a retail title makes at boot
(XStoreCreateContext, XStoreQueryGameLicenseAsync) could only fail.

runtime/shims/xgameruntime_store.cpp serves it, in its own file, hooked
into QueryApiImpl with one line:

- ids and slot order from xgameruntime-docs (facts only), signatures,
  enums and error codes from the public GDK reference;
  STORE_SKU_ID_SIZE (18) and TRIAL_UNIQUE_ID_MAX_SIZE (64), which the
  reference names without values, from minecraft-linux/xgameruntime-rs
  (MIT); XStoreGameLicense is 104 bytes;
- IXStoreImpl..IXStoreImpl6 answer with one 84-slot vtable;
- a full game license, package and durable licenses that stay valid,
  no add-ons, no product listings, no package updates; license-changed
  and license-lost registrations are tokens;
- store-service and store-UI calls (and CanAcquireLicense*, whose result
  layout no public source gives) fail before starting; private slots log
  once.

xgameruntime_store_test (30 checks) drives the served slots and checks the
license bytes at their offsets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 5e2b900 the shim returns an active game license and successful package/durable license acquisition without entitlement evidence. Please return an offline failure when ownership cannot be established and cover empty and unknown IDs with synthetic tests. This matters for the repository's protection-workaround restriction. Both native Windows x64 tests passed (MSVC 19.50, SDK 10.0.26100), including assertions that currently expect unconditional success. Selected vtable slots were tested; title-caller ABI remains unverified. AI-assisted CPU review, no package, GPU or game services.

… slots

The same fixes @CharlyRien's review of ItsNotRexed#3363 led to for XUserImpl:
- context, license and product-query handles are looked up by kind in a
  live map, never read, so a closed, foreign or wrong-kind pointer is
  refused without touching freed memory, and a double close is a no-op;
- the docs' unknown slots 46-48 answer E_NOTIMPL instead of S_OK with
  nothing written; XStoreIsAvailabilityPurchasable (70) stays 0, since
  it is read as a bool and E_NOTIMPL's low byte would mean true.

Tests: 33 checks (double close, slot 46, slot 70).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@romainveurrier

romainveurrier commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Pushed d317307. Two review points from #3363 apply here too:

  • Handles are validated by lookup in a live map, never dereferenced, so freed memory is never read and a double close does nothing.
  • The unknown slots 46–48 answer E_NOTIMPL instead of S_OK with nothing written. XStoreIsAvailabilityPurchasable returns a bool, so it stays false.

33 checks under Wine. AI-assisted.

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Layout cross-check of d317307 against a second source (read only), the LGPL xgameruntime IDL (xodus-gaming/xgameruntime, include/xstore.idl, from Wine):

  • Interface chain and ids: IXStoreImpl 0dd112ac-… (67 methods), IXStoreImpl2 60b09f4e-… (+1), IXStoreImpl3 2d42fea5-… (+2), IXStoreImpl4 de3dbdd4-… (+4), IXStoreImpl5 5c48dedf-… (+5), IXStoreImpl6 b09d803c-… (+2). That's 81 methods + IUnknown = 84 slots, matching your static_assert, and all five derived ids match kStoreInterfaces byte for byte.
  • Slot order: I compared every slot your vtable comments name (43 of them, e.g. // 12 XStore…) with the IDL's method order. 0 mismatches. The per-version ranges also agree: 70 is IXStoreImpl2's XStoreIsAvailabilityPurchasable, 71-72 IXStoreImpl3, 73-76 IXStoreImpl4, 77-81 IXStoreImpl5, 82-83 IXStoreImpl6.

So the two sources agree on the layout; I didn't review the offline answers themselves.

AI-assisted review (Claude Code).

From @kacper-serewis's review of 5e2b900: the shim answered an active game
license and successful package and durable license acquisition without any
entitlement evidence, which is a license-check workaround the project
rules out. Offline, ownership can't be established, so:

- XStoreQueryGameLicenseAsync, XStoreAcquireLicenseForPackageAsync and
  XStoreAcquireLicenseForDurablesAsync (and their Results) fail before
  starting with HRESULT_FROM_WIN32(ERROR_NETWORK_UNREACHABLE), like the
  other store-service calls;
- no license handle is ever handed out: XStoreIsLicenseValid is false for
  anything, and license-lost registration refuses non-licenses;
- XStoreGameLicense and the two size constants taken from xgameruntime-rs
  are gone, since nothing writes a license any more.

Contexts, empty listings (no add-ons, products or updates; they grant
nothing) and registrations are unchanged. The test covers empty and
unknown package and store ids, and checks the title's license buffer is
left untouched; 30 checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@romainveurrier

Copy link
Copy Markdown
Contributor Author

@kacper-serewis, agreed, thank you. Answering "licensed" without entitlement evidence was a license-check workaround. Fixed in 383643a:

  • XStoreQueryGameLicenseAsync, XStoreAcquireLicenseForPackageAsync and XStoreAcquireLicenseForDurablesAsync (and their Results) fail before starting with HRESULT_FROM_WIN32(ERROR_NETWORK_UNREACHABLE), like the other store-service calls.
  • No license handle is ever handed out, so XStoreIsLicenseValid is false for anything.
  • XStoreGameLicense and the two constants from xgameruntime-rs are removed.
  • The test covers known-looking, empty and unknown package and store ids, and checks that the title's buffer is left untouched.

What's left grants nothing: store contexts, empty add-on, product and update listings, and registrations. AI-assisted.

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 383643a the entitlement finding is resolved. Unknown ownership now yields ERROR_NETWORK_UNREACHABLE from the async and result paths, with no license handle for empty or unknown IDs. Native Windows x64 synthetic tests passed 30/30, and a scratch variant passed 31/31 including unchanged output buffer and async block. No game files, GPU or game services. AI-assisted.

@romainveurrier

Copy link
Copy Markdown
Contributor Author

Closing: superseded by main's own XStoreImpl (594f348, runtime/shims/xgameruntime_store.cpp). It settles the license question in favour of "offline the game is owned", which is the maintainer's call. Thanks @kacper-serewis for the review. One note on its ASSUMPTION (UNVERIFIED) constants: minecraft-linux/xgameruntime-rs (MIT, src/xstore.rs at c523673a9e) independently gives STORE_SKU_ID_SIZE 18 and TRIAL_UNIQUE_ID_MAX_SIZE 64, the same values, with XStoreGameLicense in the reference's field order. It gives no value for SKU_ID_SIZE. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants