XGameRuntime: XAsync* entry points dereference null XAsyncBlock when forwarding to system xgameruntime.dll #1390

Open
opened 2026-11-26 04:52:42 +00:00 by github-bot · 0 comments
Owner

@⁠microwave805 on GitHub · 2026-11-24 15:31 UTC · original

Checked on main (930e8b4).

Problem

All 8 XAsync* entry points in crates/xcl/src/hle/xgameruntime/xasync.rs (XAsyncBegin at :228-241, XAsyncSchedule at :261-268, XAsyncComplete at :279-288, XAsyncGetStatus at :329-346, XAsyncGetResultSize at :349-373, XAsyncGetResult at :375-388, XAsyncCancel at :446-452, XAsyncRun at :462-469) forward to pc(slot) (System32\xgameruntime.dll) before checking b.is_null() (or provider == 0 / work == 0):

pub unsafe extern "system" fn XAsyncBegin(b: *mut XAsyncBlock, ..., provider: usize) -> HRESULT {
    if let Some((o, f)) = pc(7) {
        let f: ... = std::mem::transmute(f);
        return f(o, b, context, identity, _identity_name, provider);
    }
    if b.is_null() || provider == 0 {
        return E_INVALIDARG;
    }

Verified directly against Windows C:\Windows\System32\xgameruntime.dll: all 8 COM slots dereference b + 0x24 without a null check and immediately raise STATUS_ACCESS_VIOLATION reading 0x0000000000000024.

Minimal trigger

On any Windows 10/11 machine with Gaming Services installed (PC_ASYNC != 0, set by api.rs:165-169), call any XCL async wrapper that forwards b without pre-checking null (e.g., XUserAddAsync(0, null), XGameSaveInitializeProviderAsync(..., null), XGameSaveReadBlobDataAsync(..., null), XGameSaveSubmitUpdateAsync(..., null), XNetworkingQueryPreferredLocalUdpMultiplayerPortAsync(null), or any XAsync* directly) with b = null. Unit tests don't hit this because they run with PC_ASYNC == 0.

In begin_with_fixups (xasync.rs:557-564), the crash occurs before Payload cleanup can run.

Suggested fix

Run the b.is_null() (and provider == 0 / work == 0 / result == E_PENDING) validation checks before if let Some((o, f)) = pc(...) in all 8 XAsync* functions.


AI use: Antigravity (Gemini 4 Neon) performed the read-only source audit and drafted this issue; checked and verified on 930e8b4 before opening.

**@⁠microwave805** on GitHub · 2026-11-24 15:31 UTC · [original](https://github.com/xcl-dev/xcl/issues/1390) Checked on `main` (`930e8b4`). ### Problem All 8 `XAsync*` entry points in `crates/xcl/src/hle/xgameruntime/xasync.rs` (`XAsyncBegin` at `:228-241`, `XAsyncSchedule` at `:261-268`, `XAsyncComplete` at `:279-288`, `XAsyncGetStatus` at `:329-346`, `XAsyncGetResultSize` at `:349-373`, `XAsyncGetResult` at `:375-388`, `XAsyncCancel` at `:446-452`, `XAsyncRun` at `:462-469`) forward to `pc(slot)` (`System32\xgameruntime.dll`) **before** checking `b.is_null()` (or `provider == 0` / `work == 0`): ```rust pub unsafe extern "system" fn XAsyncBegin(b: *mut XAsyncBlock, ..., provider: usize) -> HRESULT { if let Some((o, f)) = pc(7) { let f: ... = std::mem::transmute(f); return f(o, b, context, identity, _identity_name, provider); } if b.is_null() || provider == 0 { return E_INVALIDARG; } ``` Verified directly against Windows `C:\Windows\System32\xgameruntime.dll`: all 8 COM slots dereference `b + 0x24` without a null check and immediately raise `STATUS_ACCESS_VIOLATION` reading `0x0000000000000024`. ### Minimal trigger On any Windows 10/11 machine with Gaming Services installed (`PC_ASYNC != 0`, set by `api.rs:165-169`), call any XCL async wrapper that forwards `b` without pre-checking null (e.g., `XUserAddAsync(0, null)`, `XGameSaveInitializeProviderAsync(..., null)`, `XGameSaveReadBlobDataAsync(..., null)`, `XGameSaveSubmitUpdateAsync(..., null)`, `XNetworkingQueryPreferredLocalUdpMultiplayerPortAsync(null)`, or any `XAsync*` directly) with `b = null`. Unit tests don't hit this because they run with `PC_ASYNC == 0`. In `begin_with_fixups` (`xasync.rs:557-564`), the crash occurs before `Payload` cleanup can run. ### Suggested fix Run the `b.is_null()` (and `provider == 0` / `work == 0` / `result == E_PENDING`) validation checks **before** `if let Some((o, f)) = pc(...)` in all 8 `XAsync*` functions. --- **AI use:** Antigravity (Gemini 4 Neon) performed the read-only source audit and drafted this issue; checked and verified on `930e8b4` before opening.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:52:42 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.