[GH-ISSUE #47] Stop 5 is the only unimplemented import left at 9ec34cdff, and the retail name is not the one the policy classifies #8

Open
opened 2026-11-26 20:13:58 +01:00 by 4ld0 · 4 comments
Owner

Originally created by @tib1rgitta-eng on GitHub (Nov 24, 2026).
Original GitHub issue: https://github.com/ubiquitarianism/leonida/issues/47

--dry-run on main 9ec34cdff with the retail executable leaves one unimplemented import, not 20: XCRDAPI.dll!DStorageGetFactory. The xapu, chad and AcpHal shims merged into main cover the rest. That one import is stop 5 of retail_boot_chain.md, so the first --run still ends there.

Measured

Windows 11 26200, AMD RX 6750 GRE (RDNA2, driver 32.0.21045.16010), MSVC 2022 RelWithDebInfo, LEONIDA_D3D12=vulkan, own 1.0.2.1 copy, network off. A second machine and the other CPU/GPU vendor from the reports on #2, same stop.

  • --dry-run: 5 modules mapped, shim=93 host=421 module=72 unimplemented=1; the summary reads unimplemented by return policy: hresult=0 other=1. The line itself is UNIMPLEMENTED XCRDAPI.dll!DStorageGetFactory.
  • --run: both TLS callbacks and 4/4 DllMains return 1 (the loader reports 53,246 index-0 TLS reads rewritten), InitializeApiImplEx2(gdk=10002, gs=7901, mode=0x2) (offline), the import, then the title's own int3 2.64 s after start with 0 D3D12 calls, exit 3.
  • The int3 is at exe+0x1d8e505, called from exe+0x1d8e4f5; stack +0x1d8e505 -> +0x1d8e4b4 -> +0x96866f -> +0x56eba8 -> +0x56eb27 -> +0x2236e73 -> +0x2236dae -> +0x2240eab. Identical in two runs of this build.

The class never sees the retail name

runtime/shims/registry.cpp:114 gives DStorageGetFactory ReturnClass::HResult for dstorage.dll and dstorage_xs.dll. The retail executable imports the same function from XCRDAPI.dll (docs/runtime_imports.md:161); classify() lowercases the DLL name, so the retail spelling falls through to ReturnClass::Other. runtime/test/unimplemented_policy_test.cpp:232 asserts only the dstorage_xs.dll spelling, so the gap does not show.

That is the hresult=0 other=1 in the dry run. Under LEONIDA_UNIMPLEMENTED=fail this import therefore returns 0 rather than E_NOTIMPL, and the negative result the policy exists to produce never reaches the call site: the title sees S_OK with a null factory and asserts in its own code. The doc's own note in audio_hal_exe_calls.md ("under fail only imports classify_import ...") does not hold for this one.

Stop 5's fix is a branch, not a plan

docs/audio_hal_exe_calls.md:63 names #4348 as the open pull request for this function. The old repository is private now, and #17 lists the same work as the branch old-pr/4348. So stop 5 is either that branch carried over, or a fresh shim for DStorageGetFactory(REFIID, void**) and the factory's own methods; the classification line above is a one-line change plus a test.

(Prepared with AI assistance.)

Originally created by @tib1rgitta-eng on GitHub (Nov 24, 2026). Original GitHub issue: https://github.com/ubiquitarianism/leonida/issues/47 `--dry-run` on `main` `9ec34cdff` with the retail executable leaves **one** unimplemented import, not 20: `XCRDAPI.dll!DStorageGetFactory`. The xapu, chad and AcpHal shims merged into `main` cover the rest. That one import is stop 5 of [retail_boot_chain.md](retail_boot_chain.md), so the first `--run` still ends there. ## Measured Windows 11 26200, AMD RX 6750 GRE (RDNA2, driver 32.0.21045.16010), MSVC 2022 `RelWithDebInfo`, `LEONIDA_D3D12=vulkan`, own 1.0.2.1 copy, network off. A second machine and the other CPU/GPU vendor from the reports on `#2`, same stop. - `--dry-run`: 5 modules mapped, `shim=93 host=421 module=72 unimplemented=1`; the summary reads `unimplemented by return policy: hresult=0 other=1`. The line itself is `UNIMPLEMENTED XCRDAPI.dll!DStorageGetFactory`. - `--run`: both TLS callbacks and 4/4 `DllMain`s return 1 (the loader reports 53,246 index-0 TLS reads rewritten), `InitializeApiImplEx2(gdk=10002, gs=7901, mode=0x2)` (offline), the import, then the title's own `int3` **2.64 s** after start with **0 D3D12 calls**, exit 3. - The `int3` is at `exe+0x1d8e505`, called from `exe+0x1d8e4f5`; stack `+0x1d8e505 -> +0x1d8e4b4 -> +0x96866f -> +0x56eba8 -> +0x56eb27 -> +0x2236e73 -> +0x2236dae -> +0x2240eab`. Identical in two runs of this build. ## The class never sees the retail name `runtime/shims/registry.cpp:114` gives `DStorageGetFactory` `ReturnClass::HResult` for `dstorage.dll` and `dstorage_xs.dll`. The retail executable imports the same function from **`XCRDAPI.dll`** (`docs/runtime_imports.md:161`); `classify()` lowercases the DLL name, so the retail spelling falls through to `ReturnClass::Other`. `runtime/test/unimplemented_policy_test.cpp:232` asserts only the `dstorage_xs.dll` spelling, so the gap does not show. That is the `hresult=0 other=1` in the dry run. Under `LEONIDA_UNIMPLEMENTED=fail` this import therefore returns 0 rather than `E_NOTIMPL`, and the negative result the policy exists to produce never reaches the call site: the title sees S_OK with a null factory and asserts in its own code. The doc's own note in [audio_hal_exe_calls.md](audio_hal_exe_calls.md) ("under `fail` only imports `classify_import` ...") does not hold for this one. ## Stop 5's fix is a branch, not a plan `docs/audio_hal_exe_calls.md:63` names #4348 as the open pull request for this function. The old repository is private now, and #17 lists the same work as the branch `old-pr/4348`. So stop 5 is either that branch carried over, or a fresh shim for `DStorageGetFactory(REFIID, void**)` and the factory's own methods; the classification line above is a one-line change plus a test. *(Prepared with AI assistance.)*
Author
Owner

@TongSherbet commented on GitHub (Nov 24, 2026):

PR fixed this.

<!-- gh-comment-id:7120704447 --> @TongSherbet commented on GitHub (Nov 24, 2026): PR fixed this.
Author
Owner

@tib1rgitta-eng commented on GitHub (Nov 24, 2026):

Native Windows A/B on the retail executable, main 1c7f5b5106 with and without #131. This is the counterpart of #131's Wine measurement and it lands on the same next stop, down to the instruction.

Setup. Native Windows 11 (not Wine), AMD Radeon RX 6750 GRE 12GB (RDNA2), LEONIDA_D3D12=vulkan, my own 1.0.2.1 copy, network off. main 1c7f5b5106 checked out from a tarball (git over HTTPS to github.com does not work from this network), the #131 diff applied to that tree unmodified, runtime stage built with make_game.py (clang-cl, Windows SDK 10.0.26100). The shim's /EHa flag from the CMake change was picked up and the file compiled clean.

main 1c7f5b5106 main + #131
--dry-run 1 unimplemented: XCRDAPI.dll!DStorageGetFactory (hresult=0 other=1) 0 unimplemented; the import lists as shim XCRDAPI.dll!DStorageGetFactory, policy hresult=0 other=0
--run D3D12 calls 0 1, D3D12XboxCreateDevice ok
Ends at title int3 0x80000003 at exe+0x1d8e505 (call at +0x1d8e4f5), 2.38 s, exit 3 host AV at gta6rt.exe+0xf5478, 3.56 s
Device none Vulkan: AMD Radeon RX 6750 GRE 12GB, subgroups 32..64 (default 64), upload heaps in VRAM

So the classification fix in #131 is what clears stop 5 on Windows too: the import is served by the shim instead of returning 0 under the default policy, and the title's own assert at +0x1d8e505 is not reached.

The next stop is stop 7, and it is the argument swap in docs/retail_boot_chain.md §3.1. 0xc0000005, read 0xd0:

host:gta6rt.exe+0xf5478  callq *0xd0(%r10)
  from game_scarlett_master.exe+0x2478713
    +0x19f4f54, +0x580437e, +0x43a4911, +0x224070b, +0x23cf00a, +0x2215eca

The thunk at +0xf51b0 is the generic device forwarder for slot 26. r14 is set from rcx at +0xf51c6 (the first argument), and +0xf53e3 loads r10 from 0x10(%r14), the proxy's real_vtable. +0xd0 is 26 * 8, so this is a direct read of real_vtable[26]. When the title calls slot 26 it puts the return buffer in rcx and the proxy in rdx, so the load reads the third qword of the title's return buffer, which is zero here, and the vtable read faults at 0xd0 instead of jumping. The slot count guard at +0xf53b9 (0x18(%r14) > 26) passes, because it also reads the return buffer. Nothing in the tree compares the first argument against the proxy's own vtable, so no path recognises the swap; the log line is device slot 26 (forwarded) first call and the call is forwarded by number, as the chain document says.

Two smaller points:

  • #127 is not needed on Windows. In the same build no GameInput.dll entry appears as shim, module or unimplemented in --dry-run: ordinal 1 resolves through the host's installed GameInput.dll. The gap #127 describes shows under Wine only, so the Windows stop-7 chain does not depend on it.
  • dstorage_test was not run here; the PAGE_GUARD case #131 mentions is still unmeasured on Windows.

On this host a Windows run and #131's Wine run reach the same stop with the same evidence, which also matches the main + #127 + #131 column of #321. Traces stay local.

(Prepared with AI assistance.)

<!-- gh-comment-id:7121225307 --> @tib1rgitta-eng commented on GitHub (Nov 24, 2026): Native Windows A/B on the retail executable, `main` `1c7f5b5106` with and without #131. This is the counterpart of #131's Wine measurement and it lands on the same next stop, down to the instruction. **Setup.** Native Windows 11 (not Wine), AMD Radeon RX 6750 GRE 12GB (RDNA2), `LEONIDA_D3D12=vulkan`, my own 1.0.2.1 copy, network off. `main` `1c7f5b5106` checked out from a tarball (git over HTTPS to github.com does not work from this network), the #131 diff applied to that tree unmodified, `runtime` stage built with `make_game.py` (clang-cl, Windows SDK 10.0.26100). The shim's `/EHa` flag from the CMake change was picked up and the file compiled clean. | | `main` `1c7f5b5106` | `main` + #131 | |---|---|---| | `--dry-run` | 1 unimplemented: `XCRDAPI.dll!DStorageGetFactory` (`hresult=0 other=1`) | 0 unimplemented; the import lists as `shim XCRDAPI.dll!DStorageGetFactory`, policy `hresult=0 other=0` | | `--run` D3D12 calls | 0 | 1, `D3D12XboxCreateDevice ok` | | Ends at | title `int3` `0x80000003` at `exe+0x1d8e505` (call at `+0x1d8e4f5`), 2.38 s, exit 3 | host AV at `gta6rt.exe+0xf5478`, 3.56 s | | Device | none | Vulkan: `AMD Radeon RX 6750 GRE 12GB`, subgroups 32..64 (default 64), upload heaps in VRAM | So the classification fix in #131 is what clears stop 5 on Windows too: the import is served by the shim instead of returning 0 under the default policy, and the title's own assert at `+0x1d8e505` is not reached. **The next stop is stop 7, and it is the argument swap in `docs/retail_boot_chain.md` §3.1.** `0xc0000005`, read `0xd0`: ``` host:gta6rt.exe+0xf5478 callq *0xd0(%r10) from game_scarlett_master.exe+0x2478713 +0x19f4f54, +0x580437e, +0x43a4911, +0x224070b, +0x23cf00a, +0x2215eca ``` The thunk at `+0xf51b0` is the generic device forwarder for slot 26. `r14` is set from `rcx` at `+0xf51c6` (the first argument), and `+0xf53e3` loads `r10` from `0x10(%r14)`, the proxy's `real_vtable`. `+0xd0` is `26 * 8`, so this is a direct read of `real_vtable[26]`. When the title calls slot 26 it puts the return buffer in `rcx` and the proxy in `rdx`, so the load reads the third qword of the title's return buffer, which is zero here, and the vtable read faults at `0xd0` instead of jumping. The slot count guard at `+0xf53b9` (`0x18(%r14) > 26`) passes, because it also reads the return buffer. Nothing in the tree compares the first argument against the proxy's own vtable, so no path recognises the swap; the log line is `device slot 26 (forwarded) first call` and the call is forwarded by number, as the chain document says. Two smaller points: - **#127 is not needed on Windows.** In the same build no `GameInput.dll` entry appears as shim, module or unimplemented in `--dry-run`: ordinal 1 resolves through the host's installed `GameInput.dll`. The gap #127 describes shows under Wine only, so the Windows stop-7 chain does not depend on it. - `dstorage_test` was not run here; the `PAGE_GUARD` case #131 mentions is still unmeasured on Windows. On this host a Windows run and #131's Wine run reach the same stop with the same evidence, which also matches the `main` + #127 + #131 column of #321. Traces stay local. *(Prepared with AI assistance.)*
Author
Owner

@tib1rgitta-eng commented on GitHub (Nov 24, 2026):

Follow-up from the same host, with two local experiments on top of main + #131. Neither is proposed code: they are the two stand-ins docs/retail_boot_chain.md describes (§3.1 and §3.2), applied here only to see how much of the chain the native Windows path shares. The trace shapes below are what a maintainer would need to decide whether either belongs in the tree.

Experiment 1: the slot-26 swap (§3.1). In proxy_slot, before the slot-count check: if *(void**)self is not this proxy's own vtable, and the second argument's first word is, call the real method with the two exchanged — (buffer, this) becomes (this, buffer). With that, device slot 26 (forwarded) first call is followed by three handled calls instead of the fault at +0xf5478.

The run then reaches stop 8. Slot 8 CreateCommandQueue succeeds (queue proxy), D3D12XboxCreateDevice #1, slot 8 #2, CreateFence #3, slot 48 routed to CreateCommandQueueX #4 ok. Call #5 is a second slot-48 queue and is refused by the Vulkan layer's own description check:

[rt] d3d12: CreateCommandQueue refused (type, priority, flags or node mask), type 2
[rt] d3d12: queue desc type=2 priority=0 flags=0x2 node_mask=0x0

Type 2 is the copy queue, priority 0 and node mask 0 pass, and flags=0x2 is what fails: d3d12_vulkan_device.cpp:5678 accepts only DISABLE_GPU_TIMEOUT (0x1). §3.2 says the queue is created "with Flags limited to D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT", but proxy_create_command_queue (the slot-8 and slot-48 path) hands the title's descriptor to the real device unmasked, so the console's extra flag bit reaches the PC check. The title then asserts in its own code, int3 at exe+0x2478866, 5 D3D12 calls, 3.5 s.

Experiment 2: mask the queue flags (§3.2). Copying the descriptor and keeping only DISABLE_GPU_TIMEOUT:

#6..#7  CreateCommandQueue ok       (both new queues, including the copy queue)
#8..#11 CreateFence ok              (four fences)
#12     CreateCommandAllocator ok
#13     CreateCommandList failed

Slot 73 routes to CreateCommandListX (desc words 0x00000000 0x00000002 -> node mask 0, type 0), and the next line is QueryInterface: unknown IID {c3827890-4024-474c-98cf-645b51dc4874} — the PC runtime does not answer the interface the title asks for, so #13 fails and the title asserts at exe+0x2478b7b (13 calls, 3.5 s).

Stops walked on this host, all on native Windows and RDNA2: stop 5 on plain main → stop 7 with #131 → the copy-queue flag with the §3.1 stand-in → the command-list IID with both stand-ins. Each title assert sits one call after the host-side failure, so the count of D3D12 calls before the int3 names the stop without needing a trace.

Two things in the tree, as opposed to the two experiments: the §3.2 flag limit is not in proxy_create_command_queue, and nothing detects the slot-26 swap. If the second one is wanted, the check that costs nothing is the one above — the first argument's vtable word against the proxy's own.

(Prepared with AI assistance.)

<!-- gh-comment-id:7121328760 --> @tib1rgitta-eng commented on GitHub (Nov 24, 2026): Follow-up from the same host, with two **local experiments** on top of `main` + #131. Neither is proposed code: they are the two stand-ins `docs/retail_boot_chain.md` describes (§3.1 and §3.2), applied here only to see how much of the chain the native Windows path shares. The trace shapes below are what a maintainer would need to decide whether either belongs in the tree. **Experiment 1: the slot-26 swap (§3.1).** In `proxy_slot`, before the slot-count check: if `*(void**)self` is not this proxy's own vtable, and the second argument's first word *is*, call the real method with the two exchanged — `(buffer, this)` becomes `(this, buffer)`. With that, `device slot 26 (forwarded) first call` is followed by three handled calls instead of the fault at `+0xf5478`. The run then reaches stop 8. Slot 8 `CreateCommandQueue` succeeds (queue proxy), `D3D12XboxCreateDevice` #1, slot 8 #2, `CreateFence` #3, slot 48 routed to `CreateCommandQueueX` #4 ok. Call #5 is a second slot-48 queue and is refused by the Vulkan layer's own description check: ``` [rt] d3d12: CreateCommandQueue refused (type, priority, flags or node mask), type 2 [rt] d3d12: queue desc type=2 priority=0 flags=0x2 node_mask=0x0 ``` Type 2 is the copy queue, priority 0 and node mask 0 pass, and `flags=0x2` is what fails: `d3d12_vulkan_device.cpp:5678` accepts only `DISABLE_GPU_TIMEOUT` (0x1). §3.2 says the queue is created "with `Flags` limited to `D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT`", but `proxy_create_command_queue` (the slot-8 and slot-48 path) hands the title's descriptor to the real device unmasked, so the console's extra flag bit reaches the PC check. The title then asserts in its own code, `int3` at `exe+0x2478866`, 5 D3D12 calls, 3.5 s. **Experiment 2: mask the queue flags (§3.2).** Copying the descriptor and keeping only `DISABLE_GPU_TIMEOUT`: ``` #6..#7 CreateCommandQueue ok (both new queues, including the copy queue) #8..#11 CreateFence ok (four fences) #12 CreateCommandAllocator ok #13 CreateCommandList failed ``` Slot 73 routes to `CreateCommandListX` (`desc words 0x00000000 0x00000002 -> node mask 0, type 0`), and the next line is `QueryInterface: unknown IID {c3827890-4024-474c-98cf-645b51dc4874}` — the PC runtime does not answer the interface the title asks for, so #13 fails and the title asserts at `exe+0x2478b7b` (13 calls, 3.5 s). Stops walked on this host, all on native Windows and RDNA2: stop 5 on plain `main` → stop 7 with #131 → the copy-queue flag with the §3.1 stand-in → the command-list IID with both stand-ins. Each title assert sits one call after the host-side failure, so the count of D3D12 calls before the `int3` names the stop without needing a trace. Two things in the tree, as opposed to the two experiments: the §3.2 flag limit is not in `proxy_create_command_queue`, and nothing detects the slot-26 swap. If the second one is wanted, the check that costs nothing is the one above — the first argument's vtable word against the proxy's own. *(Prepared with AI assistance.)*
Author
Owner

@BubsMcgee commented on GitHub (Nov 25, 2026):

Fixed on main: runtime/shims/dstorage.cpp serves DStorageGetFactory as dstorage_xs.dll, xcrdapi.dll and dstorage.dll (:1480), so stop 5 has a shim now. Re-checked at 9e7720c9e; the header records the evidence in docs/directstorage.md. Closing is the author's call.

<!-- gh-comment-id:7169514049 --> @BubsMcgee commented on GitHub (Nov 25, 2026): Fixed on main: `runtime/shims/dstorage.cpp` serves `DStorageGetFactory` as `dstorage_xs.dll`, `xcrdapi.dll` and `dstorage.dll` (`:1480`), so stop 5 has a shim now. Re-checked at `9e7720c9e`; the header records the evidence in `docs/directstorage.md`. Closing is the author's call.
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#8
No description provided.