From 54ed404defd035465ece0f2beeb792cf51179691 Mon Sep 17 00:00:00 2001 From: Mumogg <104529023+Mumogg@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:30:28 -0600 Subject: [PATCH 1/2] d3d12_xs: console list slot 139 is Reset, routed to the PC slot 10 The retail title resets its command lists through list slot 139, with (allocator proxy, pipeline state). main's slot map had no entry for it, so the call was recorded and dropped and the list stayed closed. The map sends it to the PC slot 10, and the unwrap keys on the PC slot, so console slot 10 and console slot 139 both hand the real list its real allocator (and a wrapped pipeline state the same way) and re-pin the inline cursor. The mapping and the unwrap rule are those of ef9d0759d (Nolan Cotter; measured by Pipodi), written again for main's list proxy, where that commit does not apply. xs_proxy_mock_test checks the map entry and a slot 139 call. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt --- runtime/shims/d3d12_xs_device.cpp | 5 ++++- runtime/shims/d3d12_xs_device.h | 1 + runtime/test/xs_proxy_mock_test.cpp | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index dd84c7b68..e8fd3d4cf 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -1221,8 +1221,11 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t std::uint64_t, std::uint64_t); auto** const real_vtable = *reinterpret_cast(self->real); UnwrappedArray heaps; - if constexpr (Slot == 10) { + if constexpr (pc == 10) { + // Reset(allocator, pso): console slot 10, and slot 139 as the retail title calls it. The title hands + // its allocator proxy; the real list takes the real one (and a wrapped pipeline state the same way). a1 = unwrap_object(a1); + a2 = unwrap_object(a2); self->pin_cursor_at_limit(); } else if constexpr (Slot == kConsoleExecuteBundle) { a1 = unwrap_object(a1); diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h index 652b6047c..b9062ff20 100644 --- a/runtime/shims/d3d12_xs_device.h +++ b/runtime/shims/d3d12_xs_device.h @@ -237,6 +237,7 @@ inline constexpr unsigned console_to_pc_list_slot(unsigned slot) { if (slot == 60) return 58; // EndEvent (no console SetMarker/BeginEvent) if (slot == 61) return 59; // ExecuteIndirect (Package) if (slot == 85) return 16; // CopyTextureRegionX -> CopyTextureRegion + if (slot == 139) return 10; // Reset(allocator, pso), as the retail title calls it (measured, Pipodi) if (slot == 146) return 80; // D3D12_BARRIER_GROUP (Package; PC GCL7) return kListNotForwarded; } diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index 83f0240a9..ab574c226 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -2081,6 +2081,7 @@ int check_console_command_list() { EXPECT(xs::console_to_pc_list_slot(60) == 58); // EndEvent EXPECT(xs::console_to_pc_list_slot(61) == 59); // ExecuteIndirect EXPECT(xs::console_to_pc_list_slot(85) == 16); // CopyTextureRegion + EXPECT(xs::console_to_pc_list_slot(139) == 10); // Reset, as the retail title calls it EXPECT(xs::console_to_pc_list_slot(146) == 80); // GCL7 Barrier EXPECT(xs::console_to_pc_list_slot(148) == xs::kListNotForwarded); // AllocateUploadMemory @@ -2186,6 +2187,15 @@ int check_console_command_list() { std::memcpy(&c18, reinterpret_cast(base + 0x18), sizeof(c18)); EXPECT(c18 == expected_limit); + // Console slot 139 is Reset as the retail title calls it: the same PC slot 10, allocator unwrapped, cursor + // re-pinned, and the list's own slot 139 never reached. + std::memcpy(reinterpret_cast(base + 0x18), &zero, sizeof(zero)); + EXPECT(hr_of(raw(list_proxy, 139, word(allocator), 0, 0, 0)) == S_OK); + EXPECT(real_list->calls[10] == 2 && real_list->calls[139] == 0); + EXPECT(real_list->args[10][0] == word(real_allocator) && real_list->args[10][1] == 0); + std::memcpy(&c18, reinterpret_cast(base + 0x18), sizeof(c18)); + EXPECT(c18 == expected_limit); + // Console slot 7 (GetDevice) returns device proxy void* list_dev = nullptr; const IID dev_iid = __uuidof(ID3D12Device); From 862890c893eb19eb39eb2fd95e7786e42ff4b18c Mon Sep 17 00:00:00 2001 From: Mumogg <104529023+Mumogg@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:42:00 -0600 Subject: [PATCH 2/2] d3d12_xs: the title's queue slot 18 is the frequency getter, not PC GetDesc Queue slot 18 is ID3D12CommandQueue::GetDesc on the PC: a struct return that writes a 16-byte description through the hidden pointer. The retail title calls slot 18 with one pointer to 8 bytes, the shape of GetTimestampFrequency(UINT64*), which the console queue has there (two methods are inserted at 14/15, so the PC slots 16 to 18 sit two later). Forwarded as GetDesc, the call wrote a description over the title's 8 bytes and what follows them; the title then went wrong a little later, after its first submission. The title's call (set_console_caller, as device slots 61 and 74) now goes to the PC slot 16. A host caller, and every caller when no classifier is installed, keeps the PC GetDesc. The reading of slot 18 is that of the console queue work in old PR 2490 (Nolan Cotter), which answers an undetected slot 18 as the frequency getter because it is the only reading that cannot overrun its argument. That work's layout detection does not apply to main's queue proxy; this is the one rule the boot needs, written for it. xs_proxy_mock_test: the guest call reaches the mock queue's slot 16 with its pointer and leaves the words around it; a host call, with a classifier and with none, reaches slot 18. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt --- runtime/shims/d3d12_xs_device.cpp | 15 +++++++++++++++ runtime/test/xs_proxy_mock_test.cpp | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index e8fd3d4cf..827b00e77 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -805,6 +805,8 @@ static_assert(kQueueSlots * sizeof(void*) <= 4096 && kFenceSlots * sizeof(void*) constexpr unsigned kQueueExecuteCommandLists = 10; // (UINT, ID3D12CommandList* const*) constexpr unsigned kQueueSignal = 14, kQueueWait = 15; // (ID3D12Fence*, UINT64) +constexpr unsigned kQueueGetTimestampFrequency = 16, kQueueGetDesc = 18; // the PC slots +bool is_console_caller(const void* address); // defined with the device proxy constexpr unsigned kQueueExecuteCommandListsX = 35; // console ExecuteCommandLists(count, lists) variant static_assert(kQueueExecuteCommandLists < kQueuePublicSlots && kQueueExecuteCommandListsX < kQueueSlots, "queue execution slots must stay within their respective tables"); @@ -1397,6 +1399,19 @@ std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_ if constexpr (K == ChildKind::queue && Slot == kQueueExecuteCommandLists) { return queue_execute_command_lists(self, a1, a2); } + if constexpr (K == ChildKind::queue && Slot == kQueueGetDesc) { + // Queue slot 18 is GetDesc on the PC: a struct return, 16 bytes written through the hidden pointer. The + // retail title calls slot 18 with one pointer to 8 bytes, the shape of GetTimestampFrequency(UINT64*), + // which the console layout with two methods inserted at 14/15 has there (PC slot 16). Forwarded as + // GetDesc it wrote a whole description over the title's 8 bytes and what follows them. The title's call + // therefore goes to the frequency getter, the only reading that cannot overrun its argument; a host + // caller (set_console_caller, as device slots 61 and 74) keeps the PC GetDesc. + if (is_console_caller(_ReturnAddress())) { + using Fn = HRESULT(WINAPI*)(void*, UINT64*); + return hr_to_u64(reinterpret_cast(self->real_vtable[kQueueGetTimestampFrequency])( + self->real, reinterpret_cast(a1))); + } + } if constexpr (K == ChildKind::queue && (Slot == kQueueSignal || Slot == kQueueWait)) a1 = unwrap_object(a1); UnwrappedArray unwrapped_lists; if constexpr (K == ChildKind::queue && Slot == 10) { diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index ab574c226..4e0b509e8 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -1177,6 +1177,22 @@ int check_xbox_queue_slots() { EXPECT(xs::queue_slot_hits(35) == 2 && queue_mock->calls[35] == 0 && queue_mock->calls[10] == 2); EXPECT(queue_mock->args[10][0] == 0 && queue_mock->args[10][1] == 0); + // Queue slot 18. The title's call (one pointer to 8 bytes) is the frequency getter, PC slot 16, and never the + // PC slot 18 (GetDesc), which would write a 16-byte description through that pointer. A host caller, under a + // classifier and with none installed, keeps the PC slot 18. + std::uint64_t frequency[3] = {0xA5A5A5A5A5A5A5A5ull, 0xA5A5A5A5A5A5A5A5ull, 0xA5A5A5A5A5A5A5A5ull}; + xs::set_console_caller([](std::uint64_t) { return true; }); + raw(queue, 18, word(&frequency[1])); + EXPECT(queue_mock->calls[16] == 1 && queue_mock->calls[18] == 0 && queue_mock->args[16][0] == word(&frequency[1])); + EXPECT(frequency[0] == 0xA5A5A5A5A5A5A5A5ull && frequency[2] == 0xA5A5A5A5A5A5A5A5ull); + xs::set_console_caller([](std::uint64_t) { return false; }); + D3D12_COMMAND_QUEUE_DESC host_desc{}; + raw(queue, 18, word(&host_desc)); + EXPECT(queue_mock->calls[16] == 1 && queue_mock->calls[18] == 1 && queue_mock->args[18][0] == word(&host_desc)); + xs::set_console_caller(nullptr); + raw(queue, 18, word(&host_desc)); + EXPECT(queue_mock->calls[16] == 1 && queue_mock->calls[18] == 2); + EXPECT(release(queue) == 0 && release(device) == 0 && mock->refs == 0); std::printf("%s: queue slot 35 routes ExecuteCommandLists(count, lists) to PC slot 10 with UINT count masking\n", g_label);