XGameRuntime & advapi32legacy: UE4 startup, login, and hotfix parity #24

Manually merged
github merged 1 commit from gh-pr/24/head into gh-pr/24/base 2026-11-26 04:04:51 +00:00
Owner

@⁠raylitebull on GitHub · 2026-11-21 22:41 UTC · original
raylitebull:xgameruntime-startup-parity → main · +2325 −152 · 9 files · 1 commits · merged 2026-11-21 22:47 UTC

Summary

Implements missing XGameRuntime and advapi32legacy.dll semantics needed by UE4/GDK console titles (e.g. Fortnite startup, login, and hotfix flows), written cleanly in XCL's idioms without touching d3d12x, xg.rs, or title_textures.rs and preserving XCL's offline XStore refusal policy.

Changes

  1. XUserGetTokenAndSignature{,Utf16}{Async,ResultSize,Result} + XSTS v1 ECDSA P-256 signing (crates/xcl/src/hle/xgameruntime/xsign.rs, mod.rs, api.rs):

    • Generates a per-process ephemeral ECDSA P-256 key pair via Windows CNG (bcrypt.dll, zero new crate dependencies) and produces a real Base64-encoded 76-byte XSTS v1 signature header ([version=1 BE][filetime BE][64-byte raw P-256 sig]) alongside an offline XBL3.0 authorization token.
    • Prevents crashes in GDK libraries (GameChat2, libHttpClient.GDK, EOSSDK) that reject or mis-index empty signatures.
    • Adds PayloadBuf / begin_with_fixups in xasync.rs so internal result-struct pointers (token, signature) are relocated in OP_GET_RESULT for both XCL's own XAsync and the PC xgameruntime.dll path.
  2. User device association & controller lookup (mod.rs, api.rs):

    • XUserFindForDevice (slot #3 on XUSER_DEVICE) now associates controllers with the local signed-in user (S_OK) instead of returning E_GAMEUSER_USER_NOT_FOUND.
    • Implements XUserFindControllerForUserWithUiAsync / Result (slots #9–#10).
  3. XNetworking HLE (37e56907 / bf2346b2, slots #3–#17) (crates/xcl/src/hle/xgameruntime/networking.rs, api.rs):

    • Implements UDP multiplayer port queries (3074, sync + async), per-URL HTTP security information (UTF-8 & UTF-16, TLS 1.2|1.3, exact GDK (block, bufSize, bufUsed, buf, outPtr) argument order), connectivity hint via iphlpapi.dll, registration tokens, and XNetworkingVerifyServerCertificate (real CryptoAPI SSL chain + SHA-1 thumbprint pin verification with plain-HTTP loopback allowance for local servers).
  4. XTaskQueue composite queues, monitors, and XAsync lifecycle + fallback (taskqueue.rs, xasync.rs, api.rs):

    • Refactors Port to Arc<Port> with weak-referenced port handles (XTaskQueueGetPort #14, XTaskQueueCreateComposite #13) and per-queue item ownership so terminating a composite queue cancels only its own work and never aborts sibling work on shared ports.
    • Implements working XTaskQueueRegisterMonitor / UnregisterMonitor callbacks and XThreadVerifyNotTimeSensitive / XThreadAssertNotTimeSensitive.
    • Fixes XAsyncBlock state retention leak by removing completed/consumed entries from ACTIVE while storing a compact completion header in block.internal, fixes double-XAsyncGetResult to return E_ILLEGAL_METHOD_CALL (0x8000000E), and snapshots callback/queue pointers before waking XAsyncGetStatus waiters.
    • Registers XCL's built-in XASYNC COM object as an automatic fallback in QueryApiImpl when System32\xgameruntime.dll (Gaming Services) is absent (while continuing to use PC xgameruntime.dll when present).
  5. Console GDK 19041/2020 IID compatibility, XError COM class, and vtable fixes (api.rs):

    • Adds legacy console vtables where slot layouts differ from GDK 261000: XPackage v1 (be3f3e9f, slot 28 XPackageEnumeratePackages), XPackage v2 (f92d8712, slots 35/36 EnumeratePackages/RegisterPackageInstalled), XSystem v3 (6fd71f09, slot 4 XSystemGetAppSpecificDeviceId instead of SandboxId), plus XPackageGetIdentifier (slot 27) and compatible alias IIDs (XUser v2, XSystem v2, XGame v1, XPLS v1).
    • Bumps SLOTS from 80 to 96 so GDK table slots 80..=83 are not truncated.
    • Implements the XError COM class (8ca467f7, slots #3–#5) without triggering DebugBreak.
    • Fixes per-IID PC-object caching for forwarding classes (XGameUi) so querying an older IID does not poison the main IID's cached PC vtable pointer.
  6. advapi32legacy.dll LSA & Advapi32 system fallback (crates/xcl/src/hle/mod.rs, crates/xcl/src/resolver.rs):

    • Appends advapi32.dll and sechost.dll to KERNELX.fallback so non-hooked imports from advapi32legacy.dll (such as LsaOpenPolicy, LsaQueryInformationPolicy, LsaClose, LookupPrivilegeValueW) resolve to Windows' real advapi32.dll/sechost.dll instead of auto-stubbing to 0 (for both static PE imports and LoadLibrary + GetProcAddress).

Verification

  • cargo build --workspace: 0 new warnings.
  • cargo test --workspace -- --test-threads=4: all tests passed (xcl lib 258 passed including 18 new unit tests across xsign, networking, taskqueue, xasync, api, and resolver; console_dlls_e2e 12 passed; console_shaders 1 passed; e2e 1 passed including new xcl_testtitle checks; gpu_pso_e2e 6 passed; xg_oracle 3 passed).
**@⁠raylitebull** on GitHub · 2026-11-21 22:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/24) `raylitebull:xgameruntime-startup-parity` → `main` · +2325 −152 · 9 files · 1 commits · merged 2026-11-21 22:47 UTC ## Summary Implements missing XGameRuntime and `advapi32legacy.dll` semantics needed by UE4/GDK console titles (e.g. Fortnite startup, login, and hotfix flows), written cleanly in XCL's idioms without touching `d3d12x`, `xg.rs`, or `title_textures.rs` and preserving XCL's offline `XStore` refusal policy. ### Changes 1. **`XUserGetTokenAndSignature{,Utf16}{Async,ResultSize,Result}` + XSTS v1 ECDSA P-256 signing** (`crates/xcl/src/hle/xgameruntime/xsign.rs`, `mod.rs`, `api.rs`): - Generates a per-process ephemeral ECDSA P-256 key pair via Windows CNG (`bcrypt.dll`, zero new crate dependencies) and produces a real Base64-encoded 76-byte XSTS v1 signature header (`[version=1 BE][filetime BE][64-byte raw P-256 sig]`) alongside an offline `XBL3.0` authorization token. - Prevents crashes in GDK libraries (`GameChat2`, `libHttpClient.GDK`, `EOSSDK`) that reject or mis-index empty signatures. - Adds `PayloadBuf` / `begin_with_fixups` in `xasync.rs` so internal result-struct pointers (`token`, `signature`) are relocated in `OP_GET_RESULT` for both XCL's own `XAsync` and the PC `xgameruntime.dll` path. 2. **User device association & controller lookup** (`mod.rs`, `api.rs`): - `XUserFindForDevice` (slot #3 on `XUSER_DEVICE`) now associates controllers with the local signed-in user (`S_OK`) instead of returning `E_GAMEUSER_USER_NOT_FOUND`. - Implements `XUserFindControllerForUserWithUiAsync` / `Result` (slots #9–#10). 3. **`XNetworking` HLE (`37e56907` / `bf2346b2`, slots #3–#17)** (`crates/xcl/src/hle/xgameruntime/networking.rs`, `api.rs`): - Implements UDP multiplayer port queries (`3074`, sync + async), per-URL HTTP security information (UTF-8 & UTF-16, TLS 1.2|1.3, exact GDK `(block, bufSize, bufUsed, buf, outPtr)` argument order), connectivity hint via `iphlpapi.dll`, registration tokens, and `XNetworkingVerifyServerCertificate` (real CryptoAPI SSL chain + SHA-1 thumbprint pin verification with plain-HTTP loopback allowance for local servers). 4. **`XTaskQueue` composite queues, monitors, and `XAsync` lifecycle + fallback** (`taskqueue.rs`, `xasync.rs`, `api.rs`): - Refactors `Port` to `Arc<Port>` with weak-referenced port handles (`XTaskQueueGetPort` #14, `XTaskQueueCreateComposite` #13) and per-queue item ownership so terminating a composite queue cancels only its own work and never aborts sibling work on shared ports. - Implements working `XTaskQueueRegisterMonitor` / `UnregisterMonitor` callbacks and `XThreadVerifyNotTimeSensitive` / `XThreadAssertNotTimeSensitive`. - Fixes `XAsyncBlock` state retention leak by removing completed/consumed entries from `ACTIVE` while storing a compact completion header in `block.internal`, fixes double-`XAsyncGetResult` to return `E_ILLEGAL_METHOD_CALL` (`0x8000000E`), and snapshots callback/queue pointers before waking `XAsyncGetStatus` waiters. - Registers XCL's built-in `XASYNC` COM object as an automatic fallback in `QueryApiImpl` when `System32\xgameruntime.dll` (Gaming Services) is absent (while continuing to use PC `xgameruntime.dll` when present). 5. **Console GDK 19041/2020 IID compatibility, `XError` COM class, and vtable fixes** (`api.rs`): - Adds legacy console vtables where slot layouts differ from GDK 261000: `XPackage` v1 (`be3f3e9f`, slot 28 `XPackageEnumeratePackages`), `XPackage` v2 (`f92d8712`, slots 35/36 `EnumeratePackages`/`RegisterPackageInstalled`), `XSystem` v3 (`6fd71f09`, slot 4 `XSystemGetAppSpecificDeviceId` instead of `SandboxId`), plus `XPackageGetIdentifier` (slot 27) and compatible alias IIDs (`XUser` v2, `XSystem` v2, `XGame` v1, `XPLS` v1). - Bumps `SLOTS` from `80` to `96` so GDK table slots `80..=83` are not truncated. - Implements the `XError` COM class (`8ca467f7`, slots #3–#5) without triggering `DebugBreak`. - Fixes per-IID PC-object caching for forwarding classes (`XGameUi`) so querying an older IID does not poison the main IID's cached PC vtable pointer. 6. **`advapi32legacy.dll` LSA & Advapi32 system fallback** (`crates/xcl/src/hle/mod.rs`, `crates/xcl/src/resolver.rs`): - Appends `advapi32.dll` and `sechost.dll` to `KERNELX.fallback` so non-hooked imports from `advapi32legacy.dll` (such as `LsaOpenPolicy`, `LsaQueryInformationPolicy`, `LsaClose`, `LookupPrivilegeValueW`) resolve to Windows' real `advapi32.dll`/`sechost.dll` instead of auto-stubbing to `0` (for both static PE imports and `LoadLibrary` + `GetProcAddress`). ### Verification - `cargo build --workspace`: 0 new warnings. - `cargo test --workspace -- --test-threads=4`: all tests passed (`xcl` lib 258 passed including 18 new unit tests across `xsign`, `networking`, `taskqueue`, `xasync`, `api`, and `resolver`; `console_dlls_e2e` 12 passed; `console_shaders` 1 passed; `e2e` 1 passed including new `xcl_testtitle` checks; `gpu_pso_e2e` 6 passed; `xg_oracle` 3 passed).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:04:49 +00:00
github manually merged commit e89985fa52 into gh-pr/24/base 2026-11-26 04:04:51 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-21 22:47 UTC · original

Reviewed and merged, thanks. Checked on top of current main: full workspace tests pass (258 lib tests, e2e, console-library tests), no new build warnings.

Notes from the review:

  • XNetworkingVerifyServerCertificate keeps full TLS checks (chain + SSL policy with the host name, pins fail closed) - good.
  • The offline XBL3.0 x=xcl;local-<id> token and the ephemeral P-256 signature never reach real services - fine with the project rule of no Xbox Live.
  • Small clippy nits for a follow-up if you like: 6 transmutes without type annotations (networking.rs), a useless vec!, a hand-written unwrap_or.
**@⁠ivall** on GitHub · 2026-11-21 22:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/24#issuecomment-7070430617) Reviewed and merged, thanks. Checked on top of current main: full workspace tests pass (258 lib tests, e2e, console-library tests), no new build warnings. Notes from the review: - XNetworkingVerifyServerCertificate keeps full TLS checks (chain + SSL policy with the host name, pins fail closed) - good. - The offline `XBL3.0 x=xcl;local-<id>` token and the ephemeral P-256 signature never reach real services - fine with the project rule of no Xbox Live. - Small clippy nits for a follow-up if you like: 6 transmutes without type annotations (`networking.rs`), a useless `vec!`, a hand-written `unwrap_or`.
This discussion has been locked. Commenting is limited to contributors.
No description provided.