A question that keeps coming back on the boot path is "what is actually on screen", and the window is not a reliable
answer: under Wine it is not mapped at all, and even on Windows a compositor or a capture-blocked surface can hide
the content. The presenter already copies every presented frame into a staging buffer when capture is enabled, so
this adds the disk side: `LEONIDA_CAPTURE=<dir>` writes each captured frame as a binary PPM and appends the extent
and the mean RGB to `<dir>/index.txt`, with `LEONIDA_CAPTURE_EVERY` and `LEONIDA_CAPTURE_LIMIT` bounding the run.
Off unless set, and created with the folder if it is missing. The write happens on the fence that already covers the
copy, so the present path is untouched.
d3d12_present_test turns it on and checks the files against the colour the test clears to: at least half the captured
frames (it resizes and injects failures on purpose, so a frame caught mid-transition is a near miss), and no frame
black. A capture that reads the wrong or a stale buffer fails there instead of in a report months later.
xgameruntime.lib's XGameRuntimeInitialize looks up "XErrorReport" with
GetProcAddress next to QueryApiImpl, the InitializeApiImpl* entries and
UninitializeApiImpl, and refuses to initialise when it is missing. In the
retail executable that is the lookup at +0x55e2b7e and the null check at
+0x55e2c08, after which boot stops at an int3 (+0x5a91c21).
The shim now exports XErrorReport(HRESULT, const char*) as a DLL export,
forwarding to the IXErrorImpl report it already served (callback, S_OK).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The retail game_scarlett_master.exe is built with /GA: it reads its TLS as
ThreadLocalStoragePointer[0] directly, without _tls_index, because the process
EXE always owns index 0. Mapped into gta6rt, index 0 belongs to gta6rt.exe, so
the game's allocator read gta6rt's TLS block and faulted at exe+0x104075.
load() now rewrites each `mov r64, gs:[58h]` in the EXE's executable sections
(53,246 sites in the retail exe) to `mov r64, gs:[1480h + 8 * slot]`, reading a
TlsAlloc slot (TEB->TlsSlots). Each thread's value there is a small view with
the image's TLS block at [0] and at [tls_index]. The rewrite is the same length
and runs before any of the image's code, TLS callbacks included. DLLs and
images whose index is already 0 are left alone; LEONIDA_TLS_GA_PATCH=0 turns it
off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Loader::initialise(Module&) called every DllMain(DLL_PROCESS_ATTACH) with
lpvReserved NULL. Microsoft's DllMain reference: "If fdwReason is
DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads and non-NULL for
static loads." The executable gta6rt maps and the DLLs it imports are the
static case; a run-time LoadLibrary (load_runtime_module) and a
GetProcAddress forwarder (resolve_module_export) are dynamic.
Each Module now records whether it was mapped inside a run-time load, and a
static module's DllMain gets a pointer to a CONTEXT captured for the call.
TLS callbacks and the process detach in ~Loader (an unload: NULL) are
unchanged.
loader_test: a host load() + initialise() must give a non-NULL lpvReserved
(fails on main), the same image through load_runtime_module NULL. The
lifecycle observer checks lpvReserved on detach only.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Squash-merged after diff review of PR #6724 - mods: a mod.json with a UTF-8 byte-order mark loads; UTF-16 is named; contexts are bounded before the cast
Squash-merged after diff review of PR #6751 - RT-5: the retail executable reaches 17 GDK runtime classes through 161 linked thunks, and imports no xgameruntime.dll