xgameruntime: XPackage enumeration, installation monitors and package-installed registration offline #166

Closed
github-bot wants to merge 1 commit from gh-pr/166/head into gh-pr/166/base
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:33 UTC · original
ubiquitarianism:old-pr/9900 → main · +310 −22 · 2 files · 1 commits · closed without merging

Carried over from old PR 9900 by tedin7 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9900, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
tedin7: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

@ItsNotRexed: an exe PR, as you asked.

What

Offline answers for the XPackage calls a title makes at boot to learn what is installed: XPackageEnumeratePackages (Game lists the process's package; Content lists the ids in LEONIDA_CONTENT_PACKAGES, in order; a callback returning false stops the walk), XPackageCreateInstallationMonitor and its progress, update, close and registration calls (installed, launchable, complete; a package that is not installed gets ERROR_NOT_FOUND), and XPackageRegisterPackageInstalled (hands out a distinct nonzero token). IXPackageImpl slots 5, 6, 9, 28, 29 forward to the same functions, so both ways in answer alike.

Why

Without them every one of these calls failed and a title took the not-installed path.

Tested

Built locally with clang-cl 19 + lld-link against the xwin SDK, run under Wine: xgameruntime_test.exe.

  • With the change: xgameruntime_test: OK (171 checks).
  • Negative control (same test, shim from origin/main): 1 of 159 checks failed, FAIL XPackageEnumeratePackages is exported, exit code 1.
  • New checks: about 100 lines in runtime/test/xgameruntime_test.cpp (enumeration of Game and Content, early stop, invalid kind/callback, slot 28, monitor open/close/progress/registration, missing package, double close, distinct package-installed tokens). Slot 5 moved from the E_NOTIMPL check to slot 27.
**@⁠Andretuta** on GitHub · 2026-11-24 02:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/166) `ubiquitarianism:old-pr/9900` → `main` · +310 −22 · 2 files · 1 commits · closed without merging > Carried over from **old PR 9900** by `tedin7` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9900`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `tedin7`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): `@ItsNotRexed`: an exe PR, as you asked. ## What Offline answers for the XPackage calls a title makes at boot to learn what is installed: `XPackageEnumeratePackages` (Game lists the process's package; Content lists the ids in `LEONIDA_CONTENT_PACKAGES`, in order; a callback returning false stops the walk), `XPackageCreateInstallationMonitor` and its progress, update, close and registration calls (installed, launchable, complete; a package that is not installed gets `ERROR_NOT_FOUND`), and `XPackageRegisterPackageInstalled` (hands out a distinct nonzero token). `IXPackageImpl` slots 5, 6, 9, 28, 29 forward to the same functions, so both ways in answer alike. ## Why Without them every one of these calls failed and a title took the not-installed path. ## Tested Built locally with clang-cl 19 + lld-link against the xwin SDK, run under Wine: `xgameruntime_test.exe`. - With the change: `xgameruntime_test: OK (171 checks)`. - Negative control (same test, shim from origin/main): `1 of 159 checks failed`, `FAIL XPackageEnumeratePackages is exported`, exit code 1. - New checks: about 100 lines in `runtime/test/xgameruntime_test.cpp` (enumeration of Game and Content, early stop, invalid kind/callback, slot 28, monitor open/close/progress/registration, missing package, double close, distinct package-installed tokens). Slot 5 moved from the E_NOTIMPL check to slot 27.
XPackageEnumeratePackages lists the process's package (Game) or the LEONIDA_CONTENT_PACKAGES ones (Content); XPackageCreateInstallationMonitor and its progress, update, close and registration calls answer installed and complete; XPackageRegisterPackageInstalled hands out a token. IXPackageImpl slots 5, 6, 9, 28, 29 forward to the same functions.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:47:09 +00:00
github-bot closed this pull request 2026-11-26 08:47:09 +00:00
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-24 11:39 UTC · original

Built and ran this natively on Windows (MSVC 19.50.35721.0, head f14804d04 on its own base, RelWithDebInfo). ctest -R xgameruntime passes 8/8, and xgameruntime_test: OK (171 checks), the same count as the Wine run in the description.

Two things I'd fix before it leaves draft, and one small one. Each is cited.

1. The interface slots that are actually called are still E_NOTIMPL; the ones wired are not called.

  • The shim answers XPackageImpl as IXPackageImpl3: slots 3-34 are IXPackageImpl, 35-38 IXPackageImpl2, 39-40 IXPackageImpl3 (tools/gdk_runtime_classes.json; the vtable's own static_assert of 41 entries).
  • docs/runtime_imports.md:343 and :575 list the slots libHttpClient.GDK.dll's thunks call: 3-19, 22, 24-27, 30, 32-34, 37-40. Slots 28 and 29 are not among them; 39 (EnumeratePackages) and 40 (RegisterPackageInstalled) are. tests/test_gdk_runtime_calls.py pins slot 40 as XPackageRegisterPackageInstalled with 4 arguments.
  • This PR wires 5, 6 and 9 (good, all called) and 28/29, but leaves 35, 36, 39 and 40 as PN(n). This very run logs XPackageImpl slot 40 not implemented offline (E_NOTIMPL) while the suite passes. The new test checks slot 28 only.
  • Pointing 35/36 and 39/40 at pkg_enumerate/pkg_register_installed, with a test through slot 39 and 40, would close it.

2. XPackageDetails is 80 bytes in current GDKs, not 64.

Microsoft Learn's reference for XPackageDetails (pages for gdk-2510, 2604 and 2610, the only versions it covers) lists 12 fields. After installing come uint32_t index, uint32_t count, bool ageRestricted and const char* titleID. On x64 that is 60 index, 64 count, 68 ageRestricted, 72 titleID, 80 total. The offsets are my own MSVC layout arithmetic; the page lists fields, not offsets.

A title built against that header reads titleID from past the end of the 64-byte struct on the shim's stack. I could not find which GDK version added the fields, and I cannot say whether that change is why the interface was re-versioned. Filling the 80-byte layout is safe either way: an older title reads only the first 57 bytes. The docs say index/count are 0/1 in the package-installed callback, and titleID is 8 uppercase hex digits, empty for DLC. MicrosoftGame.Config's title id, which XGameGetXboxTitleId already serves, would fit.

3. Small: XPackageGetInstallationProgress answers totalBytes = installedBytes = launchBytes = 0. A caller that computes a percentage before checking completed divides by zero. Equal nonzero values (for example the package size, or 1) say the same thing more safely.

GPU (not exercised by these tests): NVIDIA GeForce RTX 5070 Ti, driver 617.42, Windows 11 Pro 26300.

AI-assisted.

**@⁠kawaii-shakal** on GitHub · 2026-11-24 11:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/166#issuecomment-7130374782) Built and ran this natively on Windows (MSVC 19.50.35721.0, head f14804d04 on its own base, RelWithDebInfo). `ctest -R xgameruntime` passes 8/8, and `xgameruntime_test: OK (171 checks)`, the same count as the Wine run in the description. Two things I'd fix before it leaves draft, and one small one. Each is cited. **1. The interface slots that are actually called are still `E_NOTIMPL`; the ones wired are not called.** - The shim answers `XPackageImpl` as `IXPackageImpl3`: slots 3-34 are IXPackageImpl, 35-38 IXPackageImpl2, 39-40 IXPackageImpl3 (`tools/gdk_runtime_classes.json`; the vtable's own `static_assert` of 41 entries). - `docs/runtime_imports.md:343` and `:575` list the slots `libHttpClient.GDK.dll`'s thunks call: 3-19, 22, 24-27, 30, 32-34, 37-40. Slots 28 and 29 are not among them; 39 (`EnumeratePackages`) and 40 (`RegisterPackageInstalled`) are. `tests/test_gdk_runtime_calls.py` pins slot 40 as `XPackageRegisterPackageInstalled` with 4 arguments. - This PR wires 5, 6 and 9 (good, all called) and 28/29, but leaves 35, 36, 39 and 40 as `PN(n)`. This very run logs `XPackageImpl slot 40 not implemented offline (E_NOTIMPL)` while the suite passes. The new test checks slot 28 only. - Pointing 35/36 and 39/40 at `pkg_enumerate`/`pkg_register_installed`, with a test through slot 39 and 40, would close it. **2. `XPackageDetails` is 80 bytes in current GDKs, not 64.** Microsoft Learn's reference for `XPackageDetails` (pages for gdk-2510, 2604 and 2610, the only versions it covers) lists 12 fields. After `installing` come `uint32_t index`, `uint32_t count`, `bool ageRestricted` and `const char* titleID`. On x64 that is 60 index, 64 count, 68 ageRestricted, 72 titleID, 80 total. The offsets are my own MSVC layout arithmetic; the page lists fields, not offsets. A title built against that header reads `titleID` from past the end of the 64-byte struct on the shim's stack. I could not find which GDK version added the fields, and I cannot say whether that change is why the interface was re-versioned. Filling the 80-byte layout is safe either way: an older title reads only the first 57 bytes. The docs say `index`/`count` are 0/1 in the package-installed callback, and `titleID` is 8 uppercase hex digits, empty for DLC. `MicrosoftGame.Config`'s title id, which `XGameGetXboxTitleId` already serves, would fit. **3. Small:** `XPackageGetInstallationProgress` answers `totalBytes = installedBytes = launchBytes = 0`. A caller that computes a percentage before checking `completed` divides by zero. Equal nonzero values (for example the package size, or 1) say the same thing more safely. GPU (not exercised by these tests): NVIDIA GeForce RTX 5070 Ti, driver 617.42, Windows 11 Pro 26300. AI-assisted.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:19 UTC · original

This carry-over of old upstream PR 9900 has been taken over in #997, so I'm closing this draft as #17 describes. The branch old-pr/9900 stays.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 19:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/166#issuecomment-7141925681) This carry-over of old upstream PR 9900 has been taken over in #997, so I'm closing this draft as #17 describes. The branch `old-pr/9900` stays. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.