Skip to content

RT-5: how the retail executable calls the audio coprocessor, texture layout and DirectStorage imports (22, no shim) - #6899

Merged
shayderrr merged 2 commits into
ItsNotRexed:mainfrom
Etoile-Bleu:exe-audio-hal-calls
Nov 23, 2026
Merged

shayderrr merged 2 commits into
ItsNotRexed:mainfrom
Etoile-Bleu:exe-audio-hal-calls

Conversation

@Etoile-Bleu

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #6603 (RT-5, claim posted at the time of this PR; measurement only, the audio shims are not claimed)

@ItsNotRexed fourth exe PR, after #6715, #6751 and #6843.

Depends on: #6843 (this branch includes its commit for tools/import_call_sites.py; the diff of its own is the second commit: docs/audio_hal_exe_calls.md and one row in docs/README.md).

What and why

22 of the executable's 30 unimplemented imports are not xmem/d3d12_xs: the audio coprocessor (AcpHal.dll 9, xapu.dll 5, chad.dll 5), xg_xs.dll 2 and XCRDAPI.dll 1. No PR serves the audio group and its API is not publicly documented, so before anyone writes shims this records how the executable calls them, from the file alone: 36 call sites, the constants they pass and how each site uses the result.

What it shows:

  • The audio functions form one connected init and teardown: AcpHalCreate and AcpHalAllocateShapeContexts write to globals, ApuCreateHeap takes 0x226e00, a small family of ApuIsVirtualAddressValid / ApuMapVirtualAddress / ApuMapApuAddress calls (the same four size constants 0x40, 0x80, 0x800, 0x800) turns CPU buffers into 32-bit coprocessor addresses and back, and XApuEnqueueCommand / XApuDequeueResult / XApuDisconnect share one handle global.
  • Four calls have a negative-result branch (AcpHalCreate, AcpHalAllocateShapeContexts, ApuCreateHeap, XApuDequeueResult). Under LEONIDA_UNIMPLEMENTED=log they return 0, which that code reads as success with its outputs unset, and under fail only imports classify_import knows are HRESULTs get E_NOTIMPL, so neither mode makes the executable take its own failure path. Whether the title survives that path is unmeasured and the page says so.
  • DStorageGetFactory has the public (REFIID, void**) shape (runtime: console DirectStorage (DStorageGetFactory) with file-to-memory reads #4348 is open for it). xg_xs is counts only.

No code or data of the executable is quoted, only counts and the constants a call passes. Nothing was run.

Tested

Own Xbox 1.0.2.1 package plus the executable (SHA-256 e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993), Windows 11 26200, Python 3.13, main 1cc6e3c1.

  • python -I tools/import_call_sites.py game_scarlett_master.exe --dll AcpHal.dll --dll xapu.dll --dll chad.dll --dll xg_xs.dll --dll XCRDAPI.dll: 22 imports, 36 call sites, every import has at least one.
  • The argument registers before each site were read by hand with radare2 and are in the page as constants only.
  • All 11 tests/test_docs_*.py OK (links, repo paths, table rows, repeated lines).

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. Counts and call constants only; no disassembly, strings or code from the executable.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (not a translator change)

…oc sites pass an attribute word the shim refuses

tools/import_call_sites.py finds an import's thunk and the call/jmp rel32 instructions that reach it, from the file
alone. On game_scarlett_master.exe: XMemVirtualAlloc 23 sites (every attributes value nonzero, protections carrying
PAGE_GRAPHICS bits), the physical-page family 21 sites with an AWE-shaped signature and 64 KiB pages, and the
constants the other xmem imports are called with. docs/xmem_exe_calls.md records them and what is still unmeasured.
…layout and DirectStorage imports

22 imports with no shim, 36 call sites, from tools/import_call_sites.py and the argument registers before each call.
The audio group shows one connected init and teardown (AcpHal, xapu, chad) and four calls with a negative-result
branch (AcpHalCreate, AcpHalAllocateShapeContexts, ApuCreateHeap, XApuDequeueResult), which neither
LEONIDA_UNIMPLEMENTED mode makes the executable take today.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Adds tools/import_call_sites.py (finds a PE32+ import's jmp [rip+disp32] thunk and the call/jmp rel32 sites reaching it, reusing pe_inspect) and tests/test_import_call_sites.py (byte-built PE covering calls, tail jumps, unused/ordinal imports, 32-bit refusal, CLI/JSON, exit codes). Two new docs record measurements from the retail executable: xmem_exe_calls.md (23 XMemVirtualAlloc sites all passing an attribute word the shim refuses; inferred physical-page family) and audio_hal_exe_calls.md (22 audio/texture/DirectStorage imports, 36 sites, four with negative-result branches). README gains two rows.

Why merge

The tool turns static executable analysis into a repeatable measurement, and the pages give shim authors exact call sites, constants and failure-branch behavior without running the game. Includes #6843's commit; docs and synthetic tests only, no executable bytes quoted.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

Adds tools/import_call_sites.py (finds a PE32+ import's jmp [rip+disp32] thunk and the call/jmp rel32 sites reaching it, reusing pe_inspect) and tests/test_import_call_sites.py (byte-built PE covering calls, tail jumps, unused/ordinal imports, 32-bit refusal, CLI/JSON, exit codes). Two new docs record measurements from the retail executable: xmem_exe_calls.md (23 XMemVirtualAlloc sites all passing an attribute word the shim refuses; inferred physical-page family) and audio_hal_exe_calls.md (22 audio/texture/DirectStorage imports, 36 sites, four with negative-result branches). README gains two rows.

Why merge

The tool turns static executable analysis into a repeatable measurement, and the pages give shim authors exact call sites, constants and failure-branch behavior without running the game. Includes #6843's commit; docs and synthetic tests only, no executable bytes quoted.

Verdict: Approve

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.

2 participants