diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-23 15:34:37 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-23 15:34:37 -0500 |
| commit | b7a3fed28d53bb8c53b74eeff2ab65165a0d1c92 (patch) | |
| tree | 88b5c7b70af7a793feb37091873c9a26e1ac8a33 /runtime/src/host_cpu.cpp | |
| parent | 867d922f09b86583859796a174df89555fb32da8 (diff) | |
pe_loader: give a /GA executable its own TLS at index 0 (retail boot AV at exe+0x104075)
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>
Diffstat (limited to 'runtime/src/host_cpu.cpp')
0 files changed, 0 insertions, 0 deletions