Repository navigation
runtime: xapu.dll and chad.dll shims, connections that succeed with an empty result queue (RT-489) - #6981
runtime: xapu.dll and chad.dll shims, connections that succeed with an empty result queue (RT-489)#6981Jadiac5 wants to merge 3 commits into
Conversation
|
Static check at
The No Windows ctest here, so this is static confirmation only. No game data: counts, offsets and RVAs only. AI-assisted. |
|
Tested
Details: #6910 (comment). AI-assisted (Claude Code). |
…n empty result queue The executable's ten APU and audio DSP imports (one call site each, four for XApuEnqueueCommand) now bind to runtime/shims/xapu_chad.cpp instead of the unimplemented thunk. Both connects return a handle; the APU connect also returns a zeroed shared buffer. Commands are accepted and dropped, the result count is 0 and dequeuing fails. xapu_chad_test calls all ten in the call-site shapes.
8f8fb2b to
e6515ea
Compare
…d.dll shims) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/runtime_imports.md # runtime/CMakeLists.txt
On top of ItsNotRexed#6981, from the public GDK reference (xapu.h, XDspAudio.h on docs.xbox.com) checked against the executable's call sites (static read): - XApuConnect takes the 24-byte block as input and leaves it alone; base data is baseDataLength bytes, zeroed; no result-ready event (the title does not ask for one). - Every XApu command gets exactly one result with its id, visible from the second XApuGetResultCount after the enqueue (the title stores a stream's state only after the enqueue returns and polls from another job). Without results the title's stream slots never return to their free list. - A process command is answered with one frame of silence in its output buffer, bounded by its capacity and the base data; the 0x50-byte result is the packed XApuResult, outputDataLength at +0x34. An empty queue is XAPU_E_PENDING_RESULTS. - XDspActivate hands out a zeroed XDspStatus per stream (the voice path reads it with no NULL check); XDspSubmitCommand returns sequences 1, 2, ... and marks each processed in that block, which the title waits for before the next submit. Status blocks are pooled, never freed. - The documented error codes for refused calls (stream limit, clients, invalid command or stream index, handles still active). - build_runtime.ps1's cl.exe fallback lists acphal.cpp and xapu_chad.cpp, which tests/test_build_runtime_fallback.py requires. xapu_chad_test drives all ten in the title's shapes, with commands against a no-access page, and one thread enqueuing 20000 commands while another polls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto main AI-assisted (Claude Code). |
|
Tested
|
|
Tested |
|
Thanks for the test and the finding. Fixed in
AI-assisted (Claude Code). |
…shapes - XGCreateTextureComputer: fix signature from 4 args (desc, device, riid, out) to the measured 2 args (desc, out**). The out pointer arrives in RDX, not R9 — the old 4-arg version wrote through a stale register as textureComputer, which the two callers that ignore the HRESULT would use as a null/wild vtable call. Now returns a static computer with a proper vtable (AddRef/Release for slot 0/1, E_NOTIMPL for all other slots with a one-time log). - XGSuggestSwizzleMode: fix signature from 2 args (desc, mode*) to the measured 3 args (desc, flags, mode*). The mode* arrives in R8, not RDX, so *mode = 0 was previously writing to a wrong register. Now returns E_NOTIMPL and writes nothing (the caller already zeroed the field). - AcpHalCreate: replace the non-dereferenceable id<<4 handle with a static object with a proper vtable (IAcpHal COM-like interface). Any method call through it logs once per slot and returns E_NOTIMPL instead of faulting. Both fixes match the measured call shapes documented in the overlapping PRs ItsNotRexed#6891 and ItsNotRexed#6981 and verified by reviewers. AI-assisted: yes
|
Tested Built |
|
Verified at your rebased head e6515ea: merges clean into 8575d36 (the old docs/runtime_imports.md conflict vs #6715 is gone). The shims register through SHIM_TABLE so owns_dll picks both DLLs up without loader changes, and the call shapes match the independently measured docs/audio_hal_exe_calls.md (#6899, tools/import_call_sites.py): 8 xapu + 5 chad sites, the 0x80 stream limit, result queue semantics all consistent; buffer-size guesses are honestly marked HYPOTHESIS. Three things before merge: (1) your own docs/runtime_imports.md:141-142 still says "the other 22 are in five DLLs ... with no shim at all" — that sentence now contradicts this PR (xapu and chad are shimmed here); fix its count and list in the same PR; (2) cite tools/import_call_sites.py for the "read statically from the executable's call sites" claim, matching #6899's convention; (3) XApuDisconnect's shape comment omits the measured second argument 0x20 that audio_hal_exe_calls.md records. C++ not buildable here; xapu_chad_test runs in the windows CI job. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run, C++ review-only). |
|
Re-tested at |
Update xapu.cpp and chad.cpp to use the measured argument shapes from the executable (PR ItsNotRexed#6981) instead of GDK-documented struct-based signatures that mismatch the real call site register layout. xapu.cpp: - XApuConnect: (void* out24, void* out16, void** handle) — 3 raw pointers matching the measured call, not the GDK struct types. Removed the XApuConnectInputParameters/OutputParameters structs that were reading garbage from arg1. - XApuEnqueueCommand: (handle, cmd*, uint64_t flags) — 3rd arg is flags (always 0 at call sites), not totalCommandCount*. - XApuGetResultCount: (handle, uint64_t flags) — 2nd arg is flags, not totalResultCount*. - XApuDequeueResult: (handle, out*) — no arity change. - XApuDisconnect: (handle) — no arity change. chad.cpp: - XDspActivate: (handle, u64, u64, u64, u64) — 5 args (was 4). The measured call passes 4 extra uint64_t values; our old 4-arg version read status/streamHandle from the wrong registers. - XDspDeactivate: (handle, u64, u64, u64) — 4 args (was 1). - XDspSubmitCommand: (void*, void*) — 2 args (was 3 with commandSeq). Also fix chad_test.cpp to pass baseBufferLength >= 0x10000 so the shim's validation doesn't reject it, and update error code expectations (E_POINTER for null handle, not E_INVALIDARG). Fix acphal_test.cpp APU_ADDRESS struct ordering (must be defined before the using declarations that reference it). AI-assisted: yes
…it merges with main's xmem notes
|
New head
Not run against the retail executable. AI-assisted (Claude Code). |
Item: RT-489, shims for
xapu.dllandchad.dll(claimed in #6750 (comment)).What the imports are for
xapu.dllis the console's audio processing unit (APU) command queue andchad.dllits audio DSP. #6715 liststheir ten imports among the 30 the retail executable calls with no binding. A PC has neither unit.
What the call sites show
Read statically from the executable (never run or mapped). Each import is reached through one jump stub; the
direct callers:
XApuConnect: 1 site, three pointer arguments (two outputs of 24 and 16 bytes, and a handle). Success is read asSUCCEEDED. The first qword of the 16-byte output is used later as the base of a CPU-visible buffer: stream inputat a 0x280-byte stride from the base, stream output at a 0x1E00-byte stride from base + 0x14000. The 24-byte
output is only ever zeroed.
XApuEnqueueCommand: 4 sites, (handle, pointer to a stack-built command, 0). The command's first dword is a type(1, 2 and 3 seen), the second a stream slot. The return value is never read.
XApuGetResultCount: 1 site, (handle, 0). 0 skips the dequeue loop.XApuDequeueResult: 1 site, (handle, pointer to a zeroed 0x50-byte local), called count times; a negativeresult ends the loop.
XApuDisconnect: 1 site, one argument (the handle global, cleared after); the return value is not read.XDspConnectWithMaximumStreamLimit: 1 site, six arguments (a buffer from the title'sXMemAlloc, two dwords,0x80,1, a handle output). Success is a return of 0.XDspActivate: 1 site, five arguments, the handle first. Success is a return of 0, else the caller returns -1.XDspSubmitCommand: 1 site, two arguments (the wrapper swaps them). Success is a return of 0.XDspDeactivate,XDspDisconnect: 1 tail jump each; the caller returns what they return.What each function does now
New file
runtime/shims/xapu_chad.cpp, registered likexmem.dll(soowns_dllcovers both DLLs for run-timeLoadLibrarytoo):XApuConnect: allocates a zeroed shared buffer, writes{base, size}to the 16-byte output, zeroes the 24-byteoutput and returns
S_OKwith a handle.E_INVALIDARGwithout a handle pointer.XApuEnqueueCommand:S_OK, the command is dropped.XApuGetResultCount: 0.XApuDequeueResult:E_FAILwithout writing.XApuDisconnect: frees the buffer and the handle,S_OK.XDspConnectWithMaximumStreamLimit: a handle andS_OK.XDspActivate,XDspSubmitCommand,XDspDeactivate:S_OK.XDspDisconnect: frees the handle,S_OK.--trace, the first call of each function and the first command of each type is anaudio_queueevent,with the caller.
The effect is silent audio: the title's buffers are accepted and nothing is rendered into them.
Hypotheses (also in the file's comment):
DSP connect passes 0x80 as its stream limit; no call site shows a bound.
XDspSubmitCommand's two arguments is the handle; neither is checked.Tests
xapu_chad_test(new, in ctest asxapu_chad): 28 checks, 0 failures. It resolves all ten through the registry,checks
owns_dll, the connect outputs, that the buffer is zeroed and writable at the end of slot 127, threecommand types, the empty result queue, and the DSP calls in their call-site shapes.
xapu_chad,xmem,process_cmdline,file_system,unimplemented_policy,winhttp_offline: 6/6 passed.gta6rtbuilds with the new file.python -I tests/test_docs_repo_paths.py: OK.python -I scripts/check_no_game_data.py: exit 0.Not tested
Related: #6899 documents the same call sites. It is docs only, so this PR does not depend on it. One difference:
it reads a second argument
0x20forXApuDisconnect; here that0x20goes to anXMemFreecall just before, andthe disconnect site loads only the handle.
Tested on Windows 11, MSVC 19.44, AMD Radeon RX 9070 XT, driver 32.0.32029.2010 (no GPU is used by these tests).
AI-assisted (Claude Code).