mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 13:38:36 +00:00
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>