Skip to content

d3d12_xs: device slot 26 takes the console's struct-return form, again (RT-SLOT26) - #349

Merged
ubiquitarianism merged 1 commit into
ProjectLeonida:mainfrom
Mumogg:slot26-struct-return
Nov 24, 2026
Merged

ubiquitarianism merged 1 commit into
ProjectLeonida:mainfrom
Mumogg:slot26-struct-return

Conversation

@Mumogg

@Mumogg Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Claimed in #14 as RT-SLOT26. Clears the stop after #127 and #131.

What and why

The retail executable calls GetCustomHeapProperties (device slot 26) with the buffer for the returned struct in RCX and the device in RDX. main's generic forwarder takes RCX for the proxy, reads a vtable out of the title's stack buffer and faults: the host access violation right after D3D12XboxCreateDevice that I measured under Wine and that was confirmed on native Windows in #131.

This is commit 86b8e04e4 by Senne Cools (-x, authorship kept). It is an ancestor of main whose content is not in the tree. The cherry-pick conflicted with what main has gained around it since; I kept both sides everywhere:

  • d3d12_xs_device.cpp: the slot 26 thunk next to slot 133's, and 26 added to device_slot_overridden with the Xbox route slots.
  • xs_proxy_mock_test.cpp: the slot 26 case next to check_xbox_slots and check_console_command_list.
  • docs/d3d12_vulkan.md: main's UMA paragraph, followed by the commit's sentences about the call shape.

Measured

Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100, own 1.0.2.1 copy, network off, on main ece4ba5b3.

main this branch
D3D12 calls under --run 1 5
Ends with host AV at device slot 26 the title's own int3 after CreateCommandQueue is refused

The next stop is device slot 48: it is routed to CreateCommandQueueX, and the layer refuses the queue (type, priority, flags or node mask, type 2). That is stop 8 of docs/retail_boot_chain.md, and I will look at it next.

  • xs_proxy_mock_test under Wine: passes, including the new case (buffer in RCX and device in RDX reaches the PC method and writes only the struct; the PC form is forwarded unchanged).
  • device_proxy_test gets a case too, but that test stops at D3D12XboxCreateDevice returns a device under Wine here, on main as well, so I could not run it.

Not built with MSVC and not run on Windows.

AI-assisted (Claude Code); built and run on the machine above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt

The retail executable calls GetCustomHeapProperties with the return buffer in RCX and the device in RDX. The forwarder took RCX for the proxy and faulted.

AI-assisted.

(cherry picked from commit 86b8e04)
@BadgersMC

Copy link
Copy Markdown
Contributor

Native Windows validation for c4954581ae27e9db5baabaea091302ed54eb96ea as included in #350 at 9e6f8ae1332aed8efb5b2ed78a4780340c29fc40. Windows 11 Home build 26100, MSVC 19.44.35228, Windows SDK 10.0.26100, RelWithDebInfo.

The slot 26 regression check passed. The mock confirmed that the Xbox argument order reaches the PC method, writes only the requested struct, and leaves the PC calling form working. All six xs_proxy_mock variants and both device_proxy WARP tests passed. This was a stacked test, with synthetic inputs and no game files. AI-assisted testing with Codex.

@Mumogg

Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the Windows run, here and on #350. Those two were the part I could not do: built with clang-cl and run under Wine only on my side.

AI-assisted.

@fiestorra

Copy link
Copy Markdown
Contributor

Confirmation of your stop on a third machine, and the symbol behind it. Built this repository's main at ece4ba5b3 here with MSVC 14.44.35207 on Windows build 26300 and ran the title (gta6rt.exe --run game_scarlett_master.exe --trace-d3d12, LEONIDA_D3D12=vulkan, device picked: NVIDIA RTX 4090, driver 32.0.16.2124). The loader line reads shim=94 host=421 module=72 unimplemented=0 and D3D12XboxCreateDevice returns ok once, then device slot 26 (forwarded) first call and the process dies of 0xc0000005 reading address 0xd0 — the same title frames as #47's comment 7121225307 (game_scarlett_master.exe+0x2478713, +0x19f4f54, +0x580437e, +0x43a4911, +0x224070b, +0x23cf00a, +0x2215eca), so this row reproduces on native MSVC as well as on the clang-cl build and the AMD part.

I resolved the host frame with the Windows debugger against gta6rt.pdb for this build: the fault is in rt::d3d12_xs::proxy_slot<26>+0x239, mov r10, qword ptr [rax+0D0h] with rax = 0, which is runtime/shims/d3d12_xs_device.cpp:1923 auto fn = reinterpret_cast<ForwardFn>(self->real_vtable[Slot]);. The proxy pointer itself is fine (the Slot >= self->slot_count check reads DeviceProxy+0x18 and self->real at +0x8 just before), and real_vtable is DeviceProxy+0x10, so what is null is the cached table, indexed at 26 × 8 = 0xd0. In that file the field is written in one place only, line 608 proxy->real_vtable = *reinterpret_cast<void***>(real);, while another path re-reads it from the object each call (line 1091 auto** const real_vtable = *reinterpret_cast<void***>(self->real);). I have not measured which creation path this device came through, so I am not claiming to know why it is null; I only have the offset and the instruction, and the observation that the generic forward trusts the cached field while a nearby path does not. Not claiming the row — it is yours, and this is only the extra symbol for it.

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.

5 participants