Why merged: d3d12_bindless_churn and its --validated run now use separate temp folders per process, fixing a race between parallel runs.
Why it's good: security-reviewed; reproduced on main d42773d (the pair failed 4 of 6 runs at -j2); with this PR 8 of 8 runs passed and no stale folders were left.
AI-assisted (Claude Code, Claude Opus 5.5).
Why merged: the fcmpswap fixture now checks memory after the NaN atomic instead of the returned value, which can't tell a match from a miss; a negative control proves it catches an integer compare.
Why it's good: security-reviewed; on main d42773d the new test fails and passes with this PR (5/5); the GPU fixture passes on an RTX 4070 SUPER.
AI-assisted (Claude Code, Claude Opus 5.5).
Why merged: the LDS u8_d16 GPU fixture now has only lane 0 touch shared memory, removing a race between the 32 lanes.
Why it's good: security-reviewed; on main d42773d the new test fails and passes with this PR (3/3); the GPU fixture passes on an RTX 4070 SUPER (driver 621.24).
AI-assisted (Claude Code, Claude Opus 5.5).
Why merged: the PE loader now refuses an import address table or TLS index placed inside the headers, where the write would overwrite e_lfanew.
Why it's good: security-reviewed; built with VS 2022 + Ninja on main d42773d: the 4 new rejection cases fail on main; with this PR pe_loader, pe_loader_bounds and pe_loader_fuzz pass, and 7/7 loader-related ctests pass.
AI-assisted (Claude Code, Claude Opus 5.5).
Both ctest entries run d3d12_bindless_churn_test with one fixed
%TEMP%\leonida_bindless_churn_test folder. Under ctest -j the first to finish
removes the folder and the other fails creating its pipeline ("cannot open
...\index.json"). The folder now carries the process id, as
d3d12_execute_indirect_validation_test does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #462, tools/rdna2spirv.py imports rdna2_decode, which imports rdna2_isa_tables. Neither module was in the
three lists that track what the translator reads: LEONIDA_TRANSLATOR_DEPS (runtime/cmake/translator_deps.cmake),
TRANSLATION_SOURCES (make_game.py) and the runtime workflow's path filters. So test_cmake_translator_deps,
test_shader_stage_resume and test_runtime_paths fail on main, and an edit to the decoder neither rebuilds the GPU
test shaders, nor reruns translation, nor starts the runtime workflow.
Why merged: a minimal gate in the D3D12/Vulkan device test for hosts without D3D12 video support.
Why it's good: security-reviewed (7-line test change). Built and ran d3d12_vulkan_device_test with VS 2022 on an RTX 4070 SUPER (driver 621.24): passes before and after with identical output, as expected on a host that has video (the gate is a no-op there); the change is correct for hosts without it.
AI-assisted (Claude Code, Claude Opus 5.5).
After map_image, the loader writes into the mapped image twice: the bound
address of every import and the image's TLS index. Every step after it
(parse_exports, bind_imports, protect_sections, register_unwind,
initialise, ~Loader) reads the headers back from the mapping. A
FirstThunk or AddressOfIndex below SizeOfHeaders therefore replaced
e_lfanew or the section table, and the next read went outside the image
or used headers nobody validated. The loader already refuses a section
or a base relocation there; this closes the two remaining writes.
An index at RVA 0 is refused too: index_rva doubles as "no index", so the
index was silently never written.
Found by mutation fuzzing rt::Loader::load. The six new cases in
test_pe_loader_bounds build their images by hand; four of them fail
without this change.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The offline XStore table returned E_FAIL synchronously without ever starting the caller's XAsyncBlock, so a title that waits on the block (XAsyncGetStatus wait=true) or on its completion callback hung forever. Each *Async slot now locates its block by argument position and runs it through XAsyncRun, failing with E_FAIL; the Result partners keep returning E_FAIL.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review by @KarolKurzyna in the original repository:
- The host answers DXGI_STATUS_OCCLUDED from Present for a window that isn't on screen, which depends on the
desktop, so compare_failed_resize now counts it as S_OK. The failures stay strict.
- After a failed ResizeBuffers the host checks SetSourceSize against the size that was asked for (RTX 3060 Ti:
after 16x16385, 100x10 is DXGI_ERROR_INVALID_CALL; after 16385x16 it is S_OK), so the layer does too. The
comparison gains those two steps (17 now).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured against the host runtime (RTX 3060 Ti, NVIDIA 610.88, and WARP): once ResizeBuffers accepts its arguments
the old buffers are gone. If the new ones can't be made it fails, and the swap chain stays without buffers. GetDesc1
already reports the requested size and count, GetBuffer and Present are DXGI_ERROR_INVALID_CALL, and the next
successful ResizeBuffers restores everything. A side above 16384 is E_INVALIDARG on the hardware device. A call
refused for its arguments (a back buffer still held) changes nothing.
The layer answered E_FAIL and kept describing the old buffers. It now answers E_INVALIDARG for a side above 16384
before calling Vulkan (it used to pass the extent to vkCreateImage, past the device's limits) and E_OUTOFMEMORY when
Vulkan fails. It reports the requested description, refuses Present, and recovers on the next ResizeBuffers.
dxgi_swapchain_test compares 15 steps of that with the host's default adapter. dxgi_swapchain_count_test gets
failure injection on its fake Vulkan table: whether the offscreen ring or vkCreateSwapchainKHR fails (the latter
retires the old swapchain anyway), on the offscreen and on the direct path, the next resize builds a working
swapchain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Slot 127 is past the PC device vtable and was refused with E_NOTIMPL. It has the argument list of ID3D12Device10::CreateCommittedResource3; the proxy now calls the PC device's with the Xbox layout word and flag bits cleaned as slot 76 does. Measured in #6982.
(cherry picked from commit 8d622049ae)
The slot 25/26 cases added before this block call slot 26 four times, so its absolute counts (3, then 4) failed
on Windows. The counts are now increases from the block's start, and the forwarding check no longer shares a
line with a counter, so a counter failure is not reported as a forwarding failure.
Patch by BadgersMC, from the review of #362 (found and tested on native Windows with WARP; device_proxy_test
does not run under Wine here).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
The mock device answers GetResourceAllocationInfo, and the new case calls slot 25 with the return buffer in RCX
and the device in RDX, then in the PC form: both reach the PC method with the mask, count and descriptions, and
only the struct is written.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
The retail executable calls GetCustomHeapProperties (device slot 26) with the
C convention: the hidden return buffer in RCX and the device in RDX. The
proxy's generic forwarder assumed the PC C++ form (this in RCX, buffer in
RDX), took the buffer for the device and crashed on its vtable right after
D3D12XboxCreateDevice.
Slots 25 (GetResourceAllocationInfo, same rule, inferred) and 26 (measured)
now get thunks that accept either form: whichever of the first two arguments
is the device proxy is `this`. The runtime's own code still calls the proxy
through d3d12.h in the PC form. device_proxy_test calls both slots in both
forms against WARP.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5dbc30bed7)
Adapted to main by Mumogg: slot 26 keeps the thunk it already has (86b8e04e4), so of this commit's two thunks
only slot 25's is installed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0cde63d618)
Adapted to main by Mumogg: main already routes slot 48 through its Xbox slot table (LEONIDA_XS_QUEUE_X_SLOT),
so the route now calls proxy_create_command_queue_xbox instead of a fixed slot 48 branch, and xs_proxy_mock's
check_xbox_slots and the environment case pass the console's 32-byte description.
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 86b8e04e4c)
PAGE_GUARD is an access alarm, not a cache modifier (review on #7492). The comment
also says what the write-combine bit does on Windows, where the view is created
write-combined and #7218's import of those pages refuses it.
(cherry picked from commit 954fcb1061)
Three of the retail executable's five physical-page windows carry 0x400
(PAGE_WRITECOMBINE on the PC) next to PAGE_READWRITE. host_protect drops only the
PAGE_GRAPHICS_* range, so map_page passed PAGE_READWRITE | PAGE_WRITECOMBINE to
MapViewOfFile3, which refuses it with ERROR_INVALID_PARAMETER: the first
XMemMapPhysicalPages into such a window failed and the title's descriptor-heap
setup returned false.
view_protect now drops PAGE_WRITECOMBINE, PAGE_NOCACHE and PAGE_GUARD.
xmem_test maps a page into a window reserved with that protection.
AI-assisted.
(cherry picked from commit 7e8e3c1db1)
2dbcb882c (#6935) routes the Xbox-ABI device proxy's slot 78 to the console's SetFrameIntervalX. On the PC
ABI that slot is ID3D12Device10::CreateReservedResource2, which this test called through the proxy, so the
call answered S_OK with a null resource and GetResourceTiling of it gave 0: "line 6576: tiles == 1"
("d3d12_xs: device slot 78 routed to SetFrameIntervalX" in the log).
The Device10 call now goes through the inner Vulkan device, and the test checks that both resources were
created, so a success without an object fails at the call instead of at the tile count.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
resolve_compat() calls LoadLibraryExW on a file from LEONIDA_COMPAT_DIR. For
a file Windows cannot map (truncated, wrong machine, not a PE image) the
system raises a modal "Bad Image" hard-error box, and LoadLibraryExW does
not return until someone clicks OK. The loader reports that failure itself
one line later, so the box only stalls it: gta6rt hangs on a headless
machine, and loader_test, which writes such a file on purpose, waits for a
click in every unattended ctest run.
The load now runs with SEM_FAILCRITICALERRORS set on the calling thread, and
the thread's previous error mode is restored afterwards. The Windows error
code is read before the mode is put back.
loader_test checks that the mode comes back unchanged, that the message
still carries the error code, and that the refusal does not wait on a box.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The retail executable imports GameInputCreate from GameInput.dll by ordinal 1. The loader looks ordinal imports up
as "#1", which the shim table did not have, so the import bound to the host's GameInput.dll. On Windows the
installed GameInput answers; under Wine it is the builtin stub, the call fails and the title stops on its result.
The alias maps #1 to the same GameInputCreate, and gameinput_test checks it.
(cherry picked from commit 5e45c7da94)
The merge that brought the mirrored pull requests into main (6dece9231) left the DirectStorage shim out, noting
that it "needs the typed-error zlib inflate". The shim's commits (f87d05fdd, ac1843da2, 00551ba00, by
mariuslozo-boop and Kelebek) are ancestors of main, but its files are not in the tree, so the retail
executable's XCRDAPI.dll!DStorageGetFactory import is unimplemented (issue #47, stop 5 of
docs/retail_boot_chain.md).
- shims/dstorage.cpp, shims/dstorage_xs_abi.h, test/dstorage_test.cpp and docs/directstorage.md are back as
those commits left them.
- leonida::zlib_inflate reports why it failed through an optional ZlibError* (header, data, checksum, limit),
which the shim turns into its E_DSTORAGE_ZLIB_* codes. This is the same interface the shim was written
against, added to main's current table-driven inflater; callers that pass no pointer behave as before.
- registry.cpp classes xcrdapi.dll!DStorageGetFactory as an HRESULT import, the retail spelling #47 found
missing.
- CMake and scripts/build_runtime.ps1 build the shim into gta6rt, and CMake builds and registers dstorage_test.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
Since 4da716493 the layer refuses a whole ExecuteCommandLists batch that holds a list whose Close failed, as
D3D12 must not be given one. resolve_and_read recorded the clears, the resolve and the read-back copy in one
list, so a refused resolve now took the clears and the copy with it and the eight refused cases read back an
unwritten buffer: "refused D24S8 depth AVERAGE rect 1: Close 0x80070057, destination changed" and seven more.
The resolve is now a list of its own between a setup list (clears, edge draw, barriers) and a copy list
(barrier, read-back). Each runs as its own batch, so the layer refuses only the resolve and the test checks
that the destination keeps its clears. The host path is unchanged: a resolve whose Close fails is still never
executed there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>