Skip to content

xgameruntime: XPackageImpl's chunk, installation-monitor and mount-with-UI slots answer as a fully installed package (RT-499) - #6986

Closed
Jadiac5 wants to merge 2 commits into
ProjectLeonida:mainfrom
Jadiac5:runtime/xpackage-chunks-offline
Closed

Jadiac5 wants to merge 2 commits into
ProjectLeonida:mainfrom
Jadiac5:runtime/xpackage-chunks-offline

Conversation

@Jadiac5

@Jadiac5 Jadiac5 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Item: RT-499, XPackage chunk and installation-monitor slots offline
Claim: #6750 (comment)

What was wrong

In runtime/shims/xgameruntime.cpp, XPackageImpl slots 5, 6, 9, 12, 14, 16-19, 37 and 38 returned E_NOTIMPL.
The game calls all of them. Offline the whole package is on disk, so these can answer "everything is installed".

What the call sites show

Counted with tools/gdk_runtime_calls.py over the game executable, read statically (counts and shapes only).
The slot names come from tools/gdk_runtime_classes.json and match the comments already in the file.

Slot Method Args after this Call sites Result tested right after
5 XPackageCreateInstallationMonitor 6 2 2
6 XPackageCloseInstallationMonitorHandle 1 4 0 (void)
9 XPackageRegisterInstallationProgressChanged 4 3 2
12 XPackageFindChunkAvailability 4 4 3
14 XPackageChangeChunkInstallOrder 3 1 0
16 XPackageInstallChunksAsync 6 1 1
17 XPackageInstallChunksResult 2 1 1
18 XPackageEstimateDownloadSize 5 2 1
19 XPackageUninstallChunks 3 1 0
37 XPackageMountWithUiAsync 2 1 1
38 XPackageMountWithUiResult 2 1 0

The argument counts match the parameter lists of Microsoft's XPackage reference.

What each slot answers now

  • 5: S_OK and a monitor handle (one shared handle). Slot 7 already reads every monitor as complete.
  • 6: closes nothing (void).
  • 9: S_OK and a non-zero token. The callback is never called: the install is already complete. Slot 10 already
    unregisters any token.
  • 12: S_OK, availability Ready (0) for every chunk.
  • 14: S_OK, nothing is queued.
  • 16/17: the async block completes at once (the file's XAsyncBegin provider pattern); the result is S_OK and the
    same monitor handle as slot 5.
  • 18: S_OK, download size 0, no user confirmation.
  • 19: refused with E_ACCESSDENIED. The game folder is read only, nothing is removed, and chunks stay Ready.
    The one caller does not test the result, so a no-op would act the same; a refusal says what really happened
    and matches slot 34 (uninstall package answers "not uninstalled").
  • 37/38: slot 23's XPackageMount (the LEONIDA_CONTENT_PACKAGES registry), completed on the async block; the
    result is the mount handle. No UI is shown.
  • Missing pointers give E_INVALIDARG (package id, callback) or E_POINTER (outputs, async block).

Hypotheses

  • The XPackageChunkAvailability values (Ready 0, Pending 1, Installable 2, Unavailable 3) are from the GDK
    header as I know it, not checked against a header in this repository.
  • Slot 37 returns a refused mount (ERROR_NOT_FOUND, or E_ACCESSDENIED for the game's own id) from the Async
    call itself. Whether the GDK fails there or only in the result is not known. The one caller tests the Async
    return value.
  • Slots 5, 12, 14, 16 and 18 return ERROR_NOT_FOUND for a package that is neither the process's own nor a configured content package, as slot 23's mount does. Slot 9 takes a monitor handle, not an id.
  • The game asks for XPackageImpl with IXPackageImpl4's id; that answer is PR xgameruntime: XPackageImpl answers IXPackageImpl4's id too #5152. This change only adds
    slot answers in the same vtable and does not need xgameruntime: XPackageImpl answers IXPackageImpl4's id too #5152 to build or test, but the game reaches them only
    with xgameruntime: XPackageImpl answers IXPackageImpl4's id too #5152. Both PRs change the same docs/runtime_imports.md row, so the second to merge needs a small rebase.

Tests

  • xgameruntime_test: 154 checks, all pass (12 new checks for slots 5, 6, 9, 12, 14, 16-19, 37, 38 and "no
    progress callback is ever called"; the E_NOTIMPL example moved from slot 5 to slot 13).
  • ctest -R "xgameruntime|unimplemented_policy": 9 of 9 pass.
  • python -I tests/test_docs_repo_paths.py: OK. python -I scripts/check_no_game_data.py: OK.

Not tested: not run against the retail executable.

Related: #5152 (not a build dependency, see Hypotheses).

Tested on Windows 11, MSVC 19.44 (AMD Radeon RX 9070 XT, driver 32.0.32029.2010; the tests use no GPU).

AI-assisted (Claude Code).

@tikD1337

Copy link
Copy Markdown
Contributor

Review: #6986: XPackageImpl chunk, installation-monitor and mount-with-UI slots (RT-499)

Environment: Windows 11, CPython 3.13. The runtime is built with CMake + Ninja (RelWithDebInfo). I read the change against runtime/shims/xgameruntime.cpp and against the vendored third_party/xtaskqueue/Source/Task/AsyncLib.cpp, because that file is what XAsyncBegin / XAsyncGetResult resolve to.

What changed

Ten more IXPackageImpl / IXPackageImpl2 vtable slots now return a real answer instead of E_NOTIMPL. They all follow one model: the package is fully installed offline.

Slot Method Answer
5 / 6 CreateInstallationMonitor / CloseInstallationMonitorHandle Every caller gets the same handle, the address of g_package_monitor. Closing it does nothing.
9 RegisterInstallationProgressChanged Returns token 1. The callback is never called. Slot 10 already accepts any token.
12 FindChunkAvailability Always Ready (0).
14 ChangeChunkInstallOrder S_OK, since nothing is queued.
16 / 17 InstallChunksAsync / Result Completes on the async block and returns the same monitor.
18 EstimateDownloadSize 0, and no user confirmation.
19 UninstallChunks E_ACCESSDENIED. This matches slot 34's "not uninstalled".
37 / 38 MountWithUiAsync / Result Runs slot 23's XPackageMount before the call returns. The handle travels in the async context. A refused mount is returned by the Async call itself.

Slots 13, 15, 20, 21, 35, 36, 39 and 40 still log once and return E_NOTIMPL. The docs/runtime_imports.md row and the block comment above kPackageVtable are updated to match.

Why it holds up

  • The provider follows the AsyncLib contract. package_value_provider schedules DoWork with no delay and completes with sizeof(uint64_t) bytes. In GetResult it checks the buffer size before writing.
    • The default branch returns S_OK for Cancel. That is harmless: AsyncLib.cpp:794 ignores the provider's return on Cancel, and the zero-delay DoWork completes anyway.
    • XAsyncGetResult also checks the identity (AsyncLib.cpp:1124). If the caller passes slot 16's block to slot 38, it gets the Call/Result mismatch error instead of a misread value.
  • Mount with UI reuses existing code. pkg_mount_with_ui_async calls the existing XPackageMount, so the E_ACCESSDENIED (the game's own identifier) and ERROR_NOT_FOUND paths behave exactly like slot 23. If XAsyncBegin fails after a successful mount, the handle is closed, so that path does not leak.
  • Argument checks follow the existing pattern. A null identifier gives E_INVALIDARG and a null output gives E_POINTER, as in the rest of the file.
  • The answers agree with what was already there. Slot 7 already reports "installed, launchable, completed" for any monitor, and slot 8 reports "nothing changed". A single static monitor whose close does nothing fits both.
  • The ABI matches. XPackageMountHandle is { uint64_t handle; } (xgameruntime.cpp:853). The test reads it as uint64_t*, which is layout-identical, and it packs into the context with uintptr_t on x64.

Findings

  1. Slots 5, 12, 14, 16 and 18 accept any package identifier, so they disagree with slot 23 (should be fixed before merge). pkg_find_chunk_availability returns Ready for any non-null string, including a DLC identifier that is not in LEONIDA_CONTENT_PACKAGES. For that same identifier, XPackageMount / slot 37 return HRESULT_FROM_WIN32(ERROR_NOT_FOUND) (from resolve_package_path).

    • Failure: a title that checks chunk availability before mounting would see "Ready" and then fail the mount. It could also offer DLC the player doesn't have.
    • Suggested fix: answer these slots only for the process's own identifier (LEONIDA_PACKAGE_ID / kDefaultPackageIdentifier) or for an identifier that resolve_package_path resolves. Return ERROR_NOT_FOUND for anything else, so every slot has the same idea of "installed".
    • The tests pass "pkg", which is neither, so they would need a valid identifier too.
  2. A mount from slot 37 can outlive its async block (nit). If the caller cancels before DoWork, or never calls slot 38, the entry stays in s_active_mounts. Nothing in XAsyncOp::Cleanup closes it. It is a small map entry and real callers do collect the result, so this is not blocking. A comment saying so would help.

  3. The two identity objects are not guaranteed to have different addresses (nit). kInstallChunksIdentity and kMountWithUiIdentity are both const char = 0. Read-only data folding (MSVC /Gw + /OPT:ICF, or lld --icf=all) is allowed to merge them, which would quietly weaken the Call/Result mismatch check. The current runtime/CMakeLists.txt sets neither flag, but giving them different values (0 and 1), or making them non-const, removes the risk for free.

  4. The "one caller tests the result" claims are unsourced (docs nit). The comments on slot 19 ("the one caller does not test the result") and slot 37 ("which its one caller tests") describe the title's call sites. Please cite where that was measured: the libHttpClient.GDK.dll offset, or the census behind the "3-19, 22, 24-27, 30, 32-34, 37-40" column. Otherwise mark them as hypotheses, as AGENTS.md asks.

    • The slot 37 comment already says "whether the GDK fails there or in the result is not known", which is the right way to put it.

Tests

The reported verification passed without game files:

  • git diff --check
  • python -m compileall -q make_game.py tools tests
  • check_no_game_data.py
  • python -I make_game.py --help

The targeted test list in that run is empty ([]), so runtime/test/xgameruntime_test.cpp was not run as part of it. That file is where all of the new checks live. Please build and run it with cmake --build runtime/build, then run the xgameruntime_test target, and give the result and compiler in the PR body.

The new checks cover:

  • slots 37/38 round-tripping a mount handle that slot 24 then accepts, and slot 37 refusing an uninstalled package;
  • the E_POINTER / E_INVALIDARG paths on slots 5 and 9;
  • Ready from slot 12, a size of 0 with no confirmation from slot 18, and E_ACCESSDENIED from slot 19;
  • slots 16/17 returning the same monitor as slot 5;
  • the progress callback never being called;
  • E_NOTIMPL probes moved from slot 5 to slots 13 and 40.

If finding 1 is adopted, add one check that slot 12 returns ERROR_NOT_FOUND for "NOTINSTALLED".

Project rules

  • No game data: the selectors in the tests are 24 zeroed bytes, and the only identifiers are synthetic (SLOTDLC_…, NOTINSTALLED, pkg). check_no_game_data.py passes.
  • No keys or protection workarounds: nothing here touches encryption, licensing or package signatures. "Uninstall chunks" is refused rather than faked.
  • Nothing online: none of the new code makes network calls, and no install, download or store UI is reached. Installing returns immediately with no network activity.
  • Fix, don't disable: each slot gets a documented answer in the shape of its GDK signature, and the slots still not served keep the log-once E_NOTIMPL. This is not a translator change, so the docs/design.md contract table does not apply. The docs/runtime_imports.md row is updated.

Approve once finding 1 is fixed and the runtime test run is reported. Findings 2 to 4 can be done here or as follow-ups.

AI-assisted.

@mrp1no

mrp1no commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 44157379 on Windows 11, MSVC RelWithDebInfo, merged onto main bd3f061ad, against my own copy of the retail executable (outcomes only):

Details: #6910 (comment). AI-assisted (Claude Code).

…kageMount does

Slots 5, 12, 14, 16 and 18 answered for any identifier. They now return
ERROR_NOT_FOUND unless the identifier is the process's own package or a
content package, which is what slot 23 does. The two identity constants get
different values, and the comments name where the call-site counts come from.
@Jadiac5

Jadiac5 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. All four points are in 6588ec450:

  1. Slots 5, 12, 14, 16 and 18 now return ERROR_NOT_FOUND unless the identifier is the process's own package or a configured content package, the same rule slot 23's mount uses. The monitor output is null on that path. One new check covers all five.
  2. The comment on slot 37 now says that a mount whose result is never collected stays in the mount table.
  3. The two identity constants have different values.
  4. The "one call site" comments name tools/gdk_runtime_calls.py as the source of the count.

xgameruntime_test: OK (154 checks); ctest xgameruntime|unimplemented_policy 9/9. Windows 11, MSVC 19.44, RelWithDebInfo (AMD Radeon RX 9070 XT, driver 32.0.32029.2010; no GPU used). Not run against the retail executable. The description is updated.

AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Collaborator

Tested 6588ec4 merged with main e6190e7 on Windows 11 / RTX 4080 SUPER against own copy of the retail exe: pass

  • Build: MSVC 14.51 (VS 18), Ninja, RelWithDebInfo, gta6rt + xgameruntime_test. The merge is clean.
  • ctest -R xgameruntime$: 1/1 passed.
  • Negative control: main's runtime/shims/xgameruntime.cpp with the PR's test makes xgameruntime fail (0/1). With the PR's file restored it passes again. (The earlier head 4415737 gave the same pass/fail pair.)
  • gta6rt --dry-run (LEONIDA_D3D12=vulkan, fresh --trace, --trace-d3d12, --overlay to a scratch folder): main and the PR both have 30 unimplemented imports (shim 53), with the same list. That is expected, since the change is in XPackageImpl slots and not in the import table.
  • gta6rt --run with LEONIDA_UNIMPLEMENTED=stop, 4 runs: 2 × exit 3 at the same stop as main (d3d12_xs.dll!D3D12ConfigureVirtualMemoryX, after 2 TLS callbacks and 4/4 DllMain OK), and 2 × C0000005 before that stop. Main e6190e7 shows the same intermittent C0000005/C0000374 before the stop: 3 of 8 runs, interleaved with this machine's PR runs. The crash is not this PR's. The XPackage calls are not reached yet in a stop-mode run, so the PR alone doesn't move --run.

@LooperSalty

Copy link
Copy Markdown

Tested 6588ec45 on RTX 4070 SUPER (driver 610.88), Windows 11, MSVC 19.51 (VS 18, 14.51.36231), RelWithDebInfo, at the PR's own head (not merged with main): pass.

  • xgameruntime_test: OK, 154 checks (matches the PR body).
  • ctest -R "xgameruntime|unimplemented_policy": 9 of 9 pass.
  • python -I tests/test_docs_repo_paths.py: OK (3 tests). python -I scripts/check_no_game_data.py: exit 0.
  • Full ctest -C RelWithDebInfo -j 12, clean build: the only failures that stay on re-run at rest are d3d12_indirect_dispatch_count and d3d12_indirect_rt, which fail the same way on main 8575d36e built the same way. Everything else passes (d3d12_bindless_churn*, d3d12_multithread, d3d12_vulkan_device pass alone; they only failed in the full parallel run).

Not run: the retail executable (no game files used), GPU suite.

AI-assisted (Claude Code).

@3greasier-quantifies

Copy link
Copy Markdown

Tested 6588ec450 on RTX 3070 (driver 32.0.16.2101), Windows 11 x64, MSVC 2022 (Build Tools), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0: pass.

  • Read the changes to runtime/shims/xgameruntime.cpp (the new slot functions, the vtable entries and the async provider) and the doc row. Nothing unusual.
  • Built the full runtime.
  • The eight xgameruntime* ctest entries (xgameruntime, _user, _gamesave, _store, _offline, _offline_hdr, _user_gamertag, _user_gamertag_long) passed.
  • Full ctest -C RelWithDebInfo -j4: one failure, d3d12_indirect_dispatch_count. It also fails on this PR's merge base 1cc6e3c12 (rebuilt that one test there), and the PR doesn't touch the D3D12 code, so it is not from this PR. The other tests passed or skipped (game data, Bink, gameinput).

Not checked: the real game executable or any game files, so slots 5-19 and 37-38 are only checked against the PR's own unit test.

AI-assisted: yes (Claude Code ran the build and tests; I read the results).

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.

7 participants