Repository navigation
Conversation
c884234 to
417f2b0
Compare
|
Correction to the description: I said |
|
Independent Windows verification of
No game files or network services were used. AI-assisted testing. |
Serrambi
left a comment
There was a problem hiding this comment.
Reviewed 417f2b0d and verified on Windows 11 Pro (MSVC 19.50.35719.0, Windows SDK 10.0.26100.0, Ninja RelWithDebInfo): approve.
Code review (runtime/shims/xgameruntime.cpp, runtime/test/xgameruntime_test.cpp, runtime/test/fixtures/tiny_gdk_load.cpp, docs/runtime_imports.md)
Method<F>x64this-dropping thunks (handling both regular andnoexceptsignatures),static_assert(std::size(kThreadingVtable) == 31), and singletonRuntimeObjectCAS reference counting (retaining the singleton reference floor of1) cleanly serveXThreadingImpl(slots 3–30) andXErrorImpl(slots 3–5) throughQueryApiImpl.- Measured slot positions match the GDK layout table and
third_party/xtaskqueuebehavior acrossxgameruntime_test.cppandtiny_gdk_load.cpp. - Two minor non-blocking notes:
g_error_contextandg_error_callbackare stored in separatestd::atomicglobals (error_set_callback/error_report), so concurrent re-registration could momentarily pair a callback with an older/newer context pointer.QueryApiImplguardsif (class_id && out)before callingobject_query_interface, so a call forkThreadingClass/kErrorClasswithout == nullptrlogs and returns0x80070032instead ofE_POINTER(unlike callingQueryInterfacedirectly on the singleton).
Checks on 417f2b0d
xgameruntime_test.exe:OK (45 checks),EXIT=0ctest --test-dir runtime/build --output-on-failure -R "^(xgameruntime|run_tiny_gdk_load|run_tiny_async|loader)$": 4/4 passed (loader,xgameruntime,run_tiny_async,run_tiny_gdk_load)
417f2b0 to
4eb6155
Compare
0xTehuti
left a comment
There was a problem hiding this comment.
Tested 417f2b0 on Windows 11 24H2, MSVC 19.44 (VS 2022 Community), Ninja RelWithDebInfo: pass
- Build: Clean compile and link with MSVC.
- Shim verification:
xgameruntime_test.exepasses all 21/21 checks cleanly in 0.07s, verifyingQueryApiImpldispatching forXThreadingImpl(slots 3–30) andXErrorImpl(slots 3–5), singleton lifecycle, and task queue forwarding tothird_party/xtaskqueue. - Clean-room: Layout derived cleanly from documented thunks; zero game data.
No game data used or added. AI-assisted.
XCurl.dll asks QueryApiImpl for XNetworkingImpl with IXNetworkingImpl2's interface id and calls slots 11-17 (measured with the ItsNotRexed#1877 thunk disassembly, docs/runtime_imports.md): the UTF-16 URL security-information async trio, the server certificate check, the connectivity hint and its change registration. QueryApiImpl refused the class, so each of those calls failed with class-not-provided. The class answers as a console without a network: the connectivity hint is initialized with level None; the preferred-port and URL security-info queries fail with HRESULT_FROM_WIN32(ERROR_NETWORK_UNREACHABLE), the *Async ones by completing their XAsyncBlock with it through XAsyncRun; the certificate check fails the same way; change registrations return tokens whose callbacks never fire; IXNetworkingImpl2's three additions are E_NOTIMPL. RuntimeObject gains an optional newer interface id so QueryInterface answers IXNetworkingImpl2 too. xgameruntime_test (+8 checks, 69): both interface ids, the hint, the async call completing with no network and its result size, the certificate check, register/unregister, the port query and slot 20. tiny_gdk_load's refused-class check uses an id no class has. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ItsNotRexed#1877's IXErrorImpl slot 3 returned void, but xgameruntime-docs gives HRESULT WINAPI XErrorReport(HRESULT status, const char* message), so a caller that checks the result read whatever was left in rax. It now returns S_OK after reporting. Slot 5 matches Microsoft's void XErrorSetOptions( XErrorOptions, XErrorOptions) instead of returning an HRESULT nobody reads (XErrorSetCallback was already void). The test checks slot 3's S_OK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed on #1745: #1745 (comment)
What and why
A GDK title doesn't import
XTaskQueueCreate,XAsyncBegin,XErrorReportand the rest by name. They're static thunks inxgameruntime.lib: the titleLoadLibraryWsxgameruntime.dll,GetProcAddressesQueryApiImpl, asks it for the class, calls one vtable slot and releases the object (docs/runtime_imports.md, "Run-time loaded modules"; #1384, #1517). The shim'sQueryApiImplrefused every class, so every XTaskQueue/XAsync call made through the thunks failed. The named exports the shim already has are never bound from the package (gta6rt --dry-runon all 16 DLLs: noxgameruntime.dllimport), so they didn't help.How the layout was established
xgameruntime-docs (GPL-3.0; facts only) lists each interface's methods in order, but with no slot numbers or signatures, and some entries are
_unknown_. I checked that list against the thunks statically linked into the package'slibHttpClient.GDK.dllandXCurl.dll, from my own copy. I disassembled them withllvm-objdump; no code was run, and nothing from the files is in this PR beyond slot numbers and argument shapes.Every thunk has the same shape:
QueryApiImpl. It treats0x80040154specially (turns it into0x89240107and calls an error hook); any other failure is returned as is.thisfirst, then the function's own arguments.Release(slot 2) is called.Every slot called matches the function at that position of the docs' list (after IUnknown's three slots), in argument count and width:
IXThreadingImpl: libHttpClient calls slots 3–7 and 9–30. Examples: slot 7XAsyncBegin(5 args), 9XAsyncSchedule(pointer, 32-bit), 10XAsyncComplete(pointer, HRESULT, size), 12XTaskQueueCreate(two 32-bit modes, pointer), 16XTaskQueueDispatch(returns a byte), 19XTaskQueueSubmitDelayedCallback(5 args), 22XTaskQueueTerminate(pointer, bool, 2 pointers), 27XThreadSetTimeSensitive(bool), 30XThreadIsTimeSensitive(returns a byte). Slot 8 (XAsyncBeginAlloc, private) is never called; slot 28 (XTaskQueueIsEmpty, private) takes no arguments.IXErrorImpl: XCurl calls slot 3, the docs'_unknown_, with an HRESULT and a pointer, so it isXErrorReport(HRESULT, const char*).IXNetworkingImpl: XCurl calls slots 11–17 (security info for URL, certificate check, connectivity hint). These are documented in the new table but not served in this PR.The change (
runtime/shims/xgameruntime.cpp)XThreadingImpl: a 31-entry vtable. Each documented slot forwards tothird_party/xtaskqueue, the implementation the named exports already use, through a type-checkedMethod<&fn>forwarder.XThreadSetTimeSensitive/IsTimeSensitivekeep a per-thread flag;AssertNotTimeSensitiveis a no-op. The two private slots log once and answer 0.XErrorImpl:XErrorReportlogs (bounded) and calls the callback set withXErrorSetCallback;XErrorSetOptionsreturns S_OK.QueryInterfaceanswers IUnknown and the class id, andE_NOINTERFACEotherwise. Any other class is still logged and refused with0x80070032.Tests
xgameruntime_test(+11 checks, 45 total): QueryApiImpl hands out both classes; the same object every time; slot 12 creates a manual queue; 18 submits; 16 dispatches and the callback runs; 15 duplicates; 17 closes; 27/30 round-trip the flag; QueryInterface rules; XErrorReport reaches the callback; XErrorSetOptions.run_tiny_gdk_load(a mapped program undergta6rt --run, through the loader'sLoadLibraryW/GetProcAddressshims): it now getsXThreadingImpl, creates and closes a queue through slots 12 and 17, and checks thatXNetworkingImplis still refused with the out pointer cleared.cteston Windows (RX 9070): everything else unchanged.d3d12_drawis the known Tests: wait for the bundle blend draws in d3d12_draw (fence 21, not 4) #1793 fence clash.d3d12_vulkan_devicefails atallocation_mismatcheson currentmainwith or without this change; that's AMD-specific and I'm looking at it separately.Disclosure: written with an AI assistant (Claude Code). I reviewed it, and the disassembly and test runs were done on my machine.
🤖 Generated with Claude Code