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

Open
opened 2026-11-24 15:31:23 +00:00 by microwave805 · 0 comments
microwave805 commented 2026-11-24 15:31:23 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by microwave805 on 2026-11-24T15:31:23Z.


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.

<!-- greyfinch-sync:ivall/xcl:issue:6585384453 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1390). Originally posted by [microwave805](https://github.com/microwave805) on 2026-11-24T15:31:23Z. --- 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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#1380
No description provided.