Skip to content

runtime: trampoline xgameruntime QueryApiImpl for pre-attach caches - #5

Open
SimSalabimse wants to merge 3 commits into
mainfrom
cursor/runtime-queryapi-export-trampoline-987f
Open

SimSalabimse wants to merge 3 commits into
mainfrom
cursor/runtime-queryapi-export-trampoline-987f

Conversation

@SimSalabimse

@SimSalabimse SimSalabimse commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Change

Account-picker TRACE_API still shows zero QueryApiImpl / provider … proxied after the scoped package GPA patch and after the bound delay-IAT rewrite (R0Y00#2349). A QueryApiImpl pointer resolved before GameInput/runtime_proxy attach stays the real export forever: IAT/GPA rewrites do not touch already-held function pointers, so FakeUser never sees providers on that path.

This change installs an absolute-JMP trampoline at xgameruntime.dll!QueryApiImpl after the proxy attaches (stolen-prologue stub becomes real_query). Unrelated modules that also export QueryApiImpl (the fixture decoy) are not patched. An unknown prologue is left alone and logged once.

Follow-ups on this branch:

  • 8fa334b3 — MSVC C2326 Guard fix (SrwExclusive)
  • 1e9f0f96 — after host ce75 (8fa334b3 tip, zero install/refuse): rate-limited export trampoline pending: xgameruntime.dll not loaded yet, aborted on VirtualAlloc/VirtualProtect, Ldr xgameruntime.dll load noticed, and a one-shot never loaded after 30s attach window (or still incomplete if seen)

Refs R0Y00#870. Fixes R0Y00#2350 (done-when for the trampoline itself; host may still show the DLL never loads).

AI-assisted.

Note: This is the fork self-PR. Prefer the upstream PR against R0Y00/Xbox2Windows when available (same head branch).

Verification

g++ -std=c++17 -Wall -Wextra -Werror -Isrc -o /tmp/gpa_patch_check tests/startup_runtime_gpa_patch_check.cpp
/tmp/gpa_patch_check
# -> startup_runtime_gpa_patch: ok
/tmp/gpa_patch_check --mutate name-only
# -> FAIL: name-only accepts QueryApiImpl from other.dll (exit 1)
python3 -B tests/docs_links_check.py

On Windows after pull of 1e9f0f96:

git fetch origin cursor/runtime-queryapi-export-trampoline-987f
git checkout cursor/runtime-queryapi-export-trampoline-987f
git log -1 --format=%h   # expect 1e9f0f96
cmake --build --preset dev --target startup_runtime_proxy_carrier
ctest --preset dev --no-tests=error -R '^startup_runtime_proxy_scope$'

Retest

subst G: "C:\Users\x\Documents\Games\Game"
$env:X2W_TRACE_API='1'
.\tools\startup\run.ps1 `
  -Exe "C:\Users\x\Documents\Games\Game\game_scarlett_master.exe" `
  -DataDir "G:\" `
  -BuildDir out\build\dev `
  -LogDir out\startup\y-trampoline `
  -Seconds 180 -Render -Translate -FakeUser -GpuMirror `
  -ContinueAsserts 1000 -TraceCalls -InputScript '20@75,4@90'

Confirm build= / git log -1 --format=%h is 1e9f0f96. Then:

findstr /C:"export trampoline" /C:"load noticed" /C:"never loaded" /C:"still incomplete" /C:"provider" /C:"proxied" out\startup\y-trampoline\stderr*.txt

Expect at least pending early; by ~30 s either installed, aborted/refused, or never loaded after 30s attach window. If the last fires with no load noticed, the title never mapped xgameruntime.dll on this picker path — next claimable is force-load / alternate sign-in / PE import proof, not more JMP work and not FakeUser slot-7.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
Open in Web Open in Cursor 

cursoragent and others added 3 commits November 25, 2026 13:40
IAT/GPA rewrites leave a QueryApiImpl pointer resolved before proxy attach
as the real export, so FakeUser / TRACE_API never see providers on that path.
Install an absolute-JMP at xgameruntime!QueryApiImpl after attach (stolen
prologue stub for real_query); leave unrelated same-named exports alone.

Refs R0Y00#870. Fixes R0Y00#2350.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Nested Guard::~Guard cannot access an enclosing-function local under MSVC.
Use a self-contained SrwExclusive that owns the SRWLOCK pointer.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
ce75 showed tip code with zero install/refuse lines because xgameruntime.dll
never mapped; silent retries made that indistinguishable from a wrong deploy.
Log rate-limited pending while the DLL is missing, abort on VirtualAlloc /
VirtualProtect failure, note Ldr loads of xgameruntime.dll, and emit a one-shot
after a 30s attach window.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
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.

runtime: trampoline xgameruntime!QueryApiImpl for pre-attach GPA caches

2 participants