Skip to content

xgameruntime: serve XGameRuntimeFeature, XGameEvent, XSystemAnalytics and XDisplay offline through QueryApiImpl - #3476

Open
seblessa wants to merge 2 commits into
ItsNotRexed:mainfrom
seblessa:gdk-offline-classes
Open

seblessa wants to merge 2 commits into
ItsNotRexed:mainfrom
seblessa:gdk-offline-classes

Conversation

@seblessa

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #3381 (comment)

What and why

A title linked with xgameruntime.lib reaches the GDK only through QueryApiImpl and one vtable slot per function (docs/runtime_imports.md, "Run-time loaded modules"). runtime/shims/xgameruntime.cpp serves threading, errors, networking, system and package; any other class is refused with 0x80070032, so the title takes its failure path. This adds five more classes a title is likely to touch at boot, none of them claimed elsewhere (XUser, XGameSave, XGame and XStore are left alone; XStore on purpose: no licence answers).

Each slot's position and argument shape was checked against libHttpClient.GDK.dll's statically linked thunks (class id in rcx, interface id in rdx, slot from the vtable call; measured with tools/gdk_runtime_calls.py, #3455, read-only on the retail package, nothing from it in the commit). The order follows xodus-gaming/xgameruntime-docs (GPL-3.0, facts only), and the semantics and return types follow Microsoft's public GDK reference pages, cited per method in the code. The measured argument counts match the documented signatures for every slot.

Class (interface the thunks ask for) Slots Offline behaviour
XPersistentLocalStorageImpl (IXPersistentLocalStorageImpl3) 3-8 The path is <overlay>\.gta6rt-pls\, created on first use and hidden from GAME:\ listings like the overlay's marker folder (small change in file_system.cpp/.h), never inside the package. A short buffer returns E_FAIL, as documented. Space info reports the volume's free bytes and the folder's used bytes. The space prompt completes with E_ABORT. Mounting another package's storage returns FILE_NOT_FOUND and clears the handle
XGameRuntimeFeatureImpl 3 Returns bool: true only for features whose class this runtime serves and that Microsoft documents as available on Windows; XDisplay and XStore answer false
XGameEventImpl 3 Event writes are accepted and logged (32 lines, then a single "rest not logged"); null required arguments return E_INVALIDARG
XSystemAnalyticsImpl 3 The same struct the named XSystemGetAnalyticsInfo export returns (the thunk's one argument is the hidden return-struct pointer, checked in its code)
XDisplayImpl (IXDisplayImpl) 3-4 HDR mode answers Disabled (the runtime presents SDR) with the info struct zeroed; slot 3 is undocumented and returns E_NOTIMPL

Each object answers QueryInterface for its class id and every interface id of its chain, through the interface_ids list RuntimeObject already has. docs/runtime_imports.md gets a row per class.

Not included, because they would be guesswork today: XGameStreamingImpl (four of its slots are called through an interface id the docs don't list), XAccessibilityImpl, XLauncherImpl, XUserDeviceImpl (it depends on XUserImpl).

Tested

Windows 11 Pro (26300), VS 2022 Build Tools 17.14, Vulkan SDK 1.4.363; AMD Radeon iGPU (RDNA2, driver 25.10.36) as the default Vulkan device.

  • xgameruntime_test: 130 checks. Every new slot is called through QueryApiImpl exactly as a thunk does (class id plus the measured interface id), with outputs, error paths and the refusal of unknown ids.
  • Full ctest: 132 of 132 passed (the tests that need game files skip; gameinput is disabled without SDL3 in that build).

AI-assisted: written and tested with Claude Code.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change.)

🤖 Generated with Claude Code

…iImpl

XPersistentLocalStorageImpl (IXPersistentLocalStorageImpl3, slots 3-8), XGameRuntimeFeatureImpl (3),
XGameEventImpl (3), XSystemAnalyticsImpl (3) and XDisplayImpl (IXDisplayImpl, 3-4). Interface ids, slots and
argument counts are tools/gdk_runtime_calls.py's measurement of libHttpClient.GDK.dll; each slot is the function
at that position of xgameruntime-docs' layout, and behaves as Microsoft's GDK reference page for it says.

- Persistent local storage is <overlay>\.gta6rt-pls\, made on first use and hidden from GAME:\ listings; sizes
  count the terminator; a short buffer is E_FAIL (ERROR_INSUFFICIENT_BUFFER with device type Pc); space info
  reports the volume's free bytes and the folder's files; the space prompt completes with E_ABORT through XAsync;
  mounting another title's storage is FILE_NOT_FOUND with the handle cleared.
- XGameRuntimeIsFeatureAvailable (bool) is true when the feature's class is served and the feature is documented
  for Windows: XDisplay, XStore and every unserved class are false.
- XGameEventWrite accepts and logs (bounded); null required arguments are E_INVALIDARG.
- XSystemGetAnalyticsInfo returns the named export's struct through the member-function return pointer.
- XDisplayTryEnableHdrMode answers Disabled (SDR presentation) with the info zeroed; undocumented slot 3 is
  E_NOTIMPL.

xgameruntime_test calls every slot as the thunks do (class id + measured interface id), with error paths and
refused ids; file_system_test checks the storage folder stays out of GAME:\ listings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 20:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…d#3471)

Another contributor claimed XPersistentLocalStorageImpl first (RT-219, ItsNotRexed#3471), so this branch no longer serves it:
its vtable, object and QueryApiImpl entry, its xgameruntime_test checks and its docs/runtime_imports.md row go, and
file_system.cpp/.h, file_system_test.cpp and CMakeLists.txt are back to main's content (the .gta6rt-pls listing
filter and the extra file_system.cpp in xgameruntime_test only served the storage class).

XGameRuntimeFeatureImpl keeps the class id in its table, so XGameRuntimeIsFeatureAvailable(XPersistentLocalStorage)
follows QueryApiImpl: false now, true once the class is served. The test checks it with the other features that
follow their class. XGameRuntimeFeatureImpl, XGameEventImpl, XSystemAnalyticsImpl and XDisplayImpl are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@seblessa seblessa changed the title xgameruntime: serve XPersistentLocalStorage, XGameRuntimeFeature, XGameEvent, XSystemAnalytics and XDisplay offline through QueryApiImpl xgameruntime: serve XGameRuntimeFeature, XGameEvent, XSystemAnalytics and XDisplay offline through QueryApiImpl Nov 22, 2026
@seblessa

Copy link
Copy Markdown
Contributor Author

Scope update in f7b10b9: I dropped XPersistentLocalStorageImpl from this PR, because RT-219 is @itsRevela's (#3471), as agreed in the coordination issue. The description's storage row no longer applies. The file_system change is reverted to upstream/main, and XGameRuntimeFeatureImpl now reports the storage feature only once that class is actually served, which the test checks. Re-tested: xgameruntime_test 111 checks, ctest 132/132 (Windows 11, AMD Radeon iGPU, VS 2022 17.14). (AI-assisted.)

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Layout cross-check of f7b10b9 against the LGPL xgameruntime IDL (xodus-gaming/xgameruntime, include/*.idl, from Wine; read only):

  • XGameRuntimeFeature (8836fe87-…, one method XGameRuntimeIsFeatureAvailable at slot 3) and XGameEvent (bbfbdcc7-…, XGameEventWrite at slot 3): the IDL agrees with the PR.

  • XDisplay: the two sources disagree. The PR follows xgameruntime-docs, with slot 3 unknown and XDisplayTryEnableHdrMode at slot 4. include/xdisplay.idl has:

    interface IXDisplayImpl : IUnknown            // 35f07670-…
    { XDisplayHdrModeResult XDisplayTryEnableHdrMode(XDisplayHdrModePreference, XDisplayHdrModeInfo*); }
    coclass XDisplayImpl { [default] interface IXDisplayImpl; }   // 03f0fe74-…
    

    That's one method, so TryEnableHdrMode would be at slot 3. The IDL puts XDisplayAcquireTimeoutDeferral/XDisplayCloseTimeoutDeferralHandle on IXLauncherImpl (1b339674-…, after XLaunchUri), not on the display class. Your class and interface ids match it.

    No DLL in the package calls XDisplay, so I can't measure which is right. The current choice is the safe one for a wrong guess: slot 3 logs and returns E_NOTIMPL rather than writing through a pointer it may not have. If the first boot's log shows "XDisplayImpl slot 3 (undocumented) called", that would point to the IDL's layout. It might help to mention the IDL's alternative in the slot-3 comment, so whoever reads that log knows what to try.

AI-assisted review (Claude Code).

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Correction to my comment above: your layout is the more trustworthy one, not the IDL's. I compared the two sources class by class. Where xgameruntime-docs marks a slot _unknown_, the Wine IDL leaves the method out entirely and shifts everything after it up by one. It happens here (XDisplay slot 3) and in XUser (docs' unknown slot 15, see #3363). Where the docs have no unknown slots (XGameSave's 30, XGame's 3, XStore's 81) the two agree exactly. So the IDL's one-method IXDisplayImpl is most likely missing your slot 3, and TryEnableHdrMode at slot 4 stands. Please disregard the suggestion to move it.

AI-assisted review (Claude Code).

@memorypressure

Copy link
Copy Markdown

Needs a rebase: two hunks in runtime/shims/xgameruntime.cpp conflict with main — the class-list comment and QueryApiImpl, where main's object loop (which since 4c52ce2 includes g_persistent_storage) collided with your find_object() refactor. The resolution is small: keep find_object() and add g_persistent_storage to its list — resolving to the PR side alone would silently drop main's new XPersistentLocalStorageImpl service. Good news: your slot-3 feature test compares availability against QueryApiImpl dynamically, so it stays correct once PLS is in the list. One merge-order note: the docs and test comments credit tools/gdk_runtime_calls.py as the measurement source, but that tool currently exists only in #3455 — if that does not land first, the citation points at a file that is not in the tree. The four classes themselves read well: measured ids, per-slot behaviour documented, refusals for the unmeasured ones. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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.

4 participants