Skip to content

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

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:xgameruntime-startup-parity
Nov 21, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:xgameruntime-startup-parity

Conversation

@raylitebull

Copy link
Copy Markdown
Member

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):

  3. XNetworking HLE (37e56907 / bf2346b2, slots XAudio2: real Opus decoder via Windows MSOpusDecoder MFT #3–Olympus: add bounded mesh wave dispatcher #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 Olympus: emulate geometry wave64 on wave32 #14, XTaskQueueCreateComposite Olympus: probe large RPF9 archives safely #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 XAudio2: real Opus decoder via Windows MSOpusDecoder MFT #3–Olympus: expand RDNA2 ISA compatibility #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).

@ivall

ivall commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

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.

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.

2 participants