Static-RE findings for 1.0.2.1 (exe sha256 e95020b2...): TOC layout validated 23/23, stop-13 mechanism (descriptor-heap assert) decoded, full import-map 587x68, exotic-DLL equivalence #1

Open
opened 2026-11-26 20:48:03 +00:00 by github-bot · 1 comment
Owner

@⁠umbraotus7 on GitHub · 2026-11-24 02:35 UTC · original

Hi! Independent RE effort here (working dir: gta-6-linux-engine; we forked/cloned your repo — thanks for known_builds.toml, our retail dump matches your pinned exe sha256 exactly, which made every address directly comparable). Sharing four findings from ~2 days of static analysis (Ghidra 12.2 headless, zero execution). All addresses are RVAs (ImageBase 0x140000000), so they map 1:1 onto your copy of the binary.


1) RPF9 TOC: not encrypted — layout validated at scale (23/23)

We validated the TOC geometry against all 22 .rpf containers of the retail build + pack/story000/story000_script.rpf (78MB) — 23/23 pass both invariants:

  • I1: toc_end - subtable == ceil((8 + b2C) * w24 / 16) * 16 where b2C = byte@0x2C (stride = 8 + b2C; 0x00090F01 → b2C=1 → 9-byte records). 23/23.
  • I3: bytes @⁠0x40 == 32B constant 5f08daabecbdd40258c3516807024c24fb9f756755ef4be458785bfed8aa6989 (4 tags, u16@0x1A=4). 23/23.
  • Also reproduced from the exe (not from your docs): u32@0x1C == 0x150 (directory, 16B records: u64-name-hash + 2×u32); mode word u16@hdr+2 = 0x5250 (>0x13) → cipher_id 0; the case-0 cipher object's vtable (Ghidra: FUN_144c11250 case 0 → 64B object, vtable 0x1466fdb70) resolves to 3-byte stubs → TOC is plaintext; only the streams (zlib/BCPack) are compressed/encoded.

Open question we could NOT close: an extra ~16B per-file delta in the TOC tail (deltas observed: 1, 6, 7, 9, 11, 12, 13, 28, 29, 35, 42, 632... not a function of w24/v_lo/b2C alone — we tried ~10 formulas). If anyone nails the tail-region layout, the TOC is 100% modeled.

2) Stop-13 (descriptor-heap assert) — mechanism decoded

Your boot.md lists this as the one open blocker. We found it statically. It's not a driver-quirk: the game computes its own descriptor addresses and asserts equality.

  • WinMain = RVA 0x2478440 (FUN_142478440, 4661B): RegisterClassExA + CreateWindow (wndproc @⁠0x14247a660) → D3D12XboxCreateDevice (import thunk 0x145f3fd80, 3 imports total from d3d12_xs.dll) → 5-iteration loop creating paired heaps (handles array @⁠0x1475e72a0, pointers @⁠0x1475e7300; device-alloc via slots 0x48/9 → 0x248/73 CreateDescriptorHeap → 0x420/132 reserve 0x700000 (heap0) / 0x100000 (heaps1-4) → 0x418/131 second reserve 0xC3C0/0xC380).
  • The assert lives in RVA 0x1cf3280 (FUN_141cf3280, 300B) — the game's heap-wrapper. Pseudocode:
lVar5 = (*(*heap + 0x48))();                       // GetCPUDescriptorHandleForHeapStart
if (expected != 0 && lVar5 != expected) → int3;    // ← stop 13
obj+0x20 = lVar5;                                  // cpuBase
obj+0x28 = expected + count*incr;                  // cpuEnd
obj+0x30 = (u32)incr;                              // STRIDE
obj+0x38 = (flags&1) ? GetGPUStart(+0x50) - GetCPUStart(+0x48)   // cached GPU-CPU delta
                      : 0xBADADD0000000000;        // = -0x4525230000000000 (GXDK BADADDress sentinel)
  • The expected value comes from the game's own bump-allocator (RVA 0x156c240, FUN_14156c240, 70B, LOCK/CAS): handle = ALIGN(curs+count-1, align) + align * stride@obj+0x30, cap @⁠obj+0x28. The game adopts the placeholder-VA it asked for — a shim must return exactly that VA from GetCPUDescriptorHandleForHeapStart, not its own allocation.
  • Stride = 0x80 (128B) on Scarlett (not the PC 32B). Four registered pools (via FUN_145a54700 → 0x1cf3280): (id=1, 0x80, flags=1), (1, 0x80, 0), (2, 0x1000, 0), (3, 0x800, 0). flags&1 → GPU-delta path; else the 0xBADADD0000000000 sentinel is stored.
  • Memory planner before this (FUN_145c5ff00, 267B): reserves 0x40000 slots × 32B = 8MiB in two segments (mask @⁠0x14615c228 = 0x0000ffff + runtime-adj), cookie @⁠0x14615c1c0 = 02 02 01 00 (vpmovsxbd → [2,2,1,0]).

Fix for the shim: CreateDescriptorHeap must (a) accept/record the caller-provided base-VA, (b) return it verbatim from GetCPUDescriptorHandleForHeapStart, (c) keep GetGPU−GetCPU consistent per-heap, (d) report 0xBADADD0000000000 for GPU start when the pool is CPU-only, (e) strides 128/4096/2048 by pool-id. In Wine/VKD3D terms: CreatePlacedResource-style fixed-VA semantics, not regular allocations.

3) Full import-map: 587 imports × 68 DLLs (nothing hidden)

Parsed the static import table (DataDir[1] @⁠RVA 0x6791ab4, 69 descriptors; IAT = DataDir[12] @⁠0x6793490, 655 slots). delay-imports, bound-imports,LoadConfig: all EMPTY — the 587×68 is the complete surface. Top: MSVCP140 113, api-ms-win-crt-math 41, libHttpClient.GDK 38, api-ms-win-crt-string 31, stdio 29, WS2_32 25, crt-runtime 25, Bink2Scarlett 23, VCRUNTIME140 23, core-file 22, core-synch 17, WINHTTP 15, processthreads 12, xmem 12. Exotic: d3d12_xs.dll 3 (D3D12XboxCreateDevice, D3D12ConfigureVirtualMemoryX, D3D12SerializeVersionedRootSignature — confirming all GPU weight is vtable-193, not imports), xg_xs 2, XboxBvhBuilder 7, GameInput.dll 1 (ordinal_1 = GameInputCreate), XCRDAPI 1 (DStorageGetFactory), amd_fidelityfx_loader_xbox 4, AcpHal 9, xapu 5, chad 5, MFPlat 6+1, XCurl 0 (loaded via LoadLibrary; 9 loader-imports present), amd_fidelityfx_upscaler_xbox 0 (same), CetAdvancedCompress/dstorage do not exist in this build.

Rough shim-ontology: 482/587 (82%) = CRT+Win32-core (mechanic); 105/587 (18%) = 15 exotic DLLs, of which 58 (55%) map 1:1 to existing Linux components: Bink23→Bink2/GL-entropy decoder (we use a librempeg/FFmpeg-based pipeline — 12/12 .bk2 from movies.rpf decode), BVH7→VKD3D-AS (vkCreateAccelerationStructureKHR), xmem12→malloc/posix_memalign/mmap, MF7→ffmpeg. Audio-DSP (AcpHal9+xapu5+chad5=19) = stubs+ring-buffer.

Also from MicrosoftGame.Config: TitleId 7952987A, Store 9NL3WWNZLZZN, SMTEnabled true, XboxLockhart/AnacondaTitleMemory = Advanced — the memory-annotations matter for the Series-S/X memory-shim.

4) Because it's the least-documented: 8th XboxBvhBuilder import

The 7 named mangles for XboxBvhBuilder.dll are: ctor/dtor, BuildRaytracingAccelerationStructureBatched2X, CopyRaytracingAccelerationStructure, RehydrateRaytracingAccelerationStructureBatched2X, Set64BitMortonCodes, and (the one that truncates in <200B windows) GetRaytracingAccelerationStructurePrebuildInfo (196+ char mangle). Straight 1:1 onto VKD3D-AS.


If useful, we're happy to: (a) PR our three docs (rpf9-TOC-ghidra.md, d3d12x-stop13-ghidra.md, imports-map.md + exotic-DLL equivalence) into your docs/; (b) contribute the 23/23 TOC-validator (pure-stdlib Python, no deps) under tests/; (c) share the Ghidra hunt logs + full import TSV. Say the word and we'll open the PRs.

— GH0ST (oscena), independent, no affiliation.

**@⁠umbraotus7** on GitHub · 2026-11-24 02:35 UTC · [original](https://github.com/Kajcsi/G6Recomp/issues/1) Hi! Independent RE effort here (working dir: gta-6-linux-engine; we forked/cloned your repo — thanks for known_builds.toml, our retail dump matches your pinned exe sha256 exactly, which made every address directly comparable). Sharing four findings from ~2 days of static analysis (Ghidra 12.2 headless, zero execution). All addresses are RVAs (ImageBase 0x140000000), so they map 1:1 onto your copy of the binary. --- ## 1) RPF9 TOC: not encrypted — layout validated at scale (23/23) We validated the TOC geometry against **all 22 .rpf containers of the retail build + pack/story000/story000_script.rpf (78MB)** — 23/23 pass both invariants: - **I1**: `toc_end - subtable == ceil((8 + b2C) * w24 / 16) * 16` where `b2C = byte@0x2C` (stride = 8 + b2C; 0x00090F01 → b2C=1 → 9-byte records). 23/23. - **I3**: bytes @⁠0x40 == 32B constant `5f08daabecbdd40258c3516807024c24fb9f756755ef4be458785bfed8aa6989` (4 tags, u16@0x1A=4). 23/23. - Also reproduced from the exe (not from your docs): u32@0x1C == 0x150 (directory, 16B records: u64-name-hash + 2×u32); mode word u16@hdr+2 = 0x5250 (>0x13) → **cipher_id 0**; the case-0 cipher object's vtable (Ghidra: FUN_144c11250 case 0 → 64B object, vtable 0x1466fdb70) resolves to 3-byte stubs → **TOC is plaintext**; only the streams (zlib/BCPack) are compressed/encoded. Open question we could NOT close: an extra **~16B per-file delta** in the TOC tail (deltas observed: 1, 6, 7, 9, 11, 12, 13, 28, 29, 35, 42, 632... not a function of w24/v_lo/b2C alone — we tried ~10 formulas). If anyone nails the tail-region layout, the TOC is 100% modeled. ## 2) Stop-13 (descriptor-heap assert) — mechanism decoded Your boot.md lists this as the one open blocker. We found it statically. It's not a driver-quirk: **the game computes its own descriptor addresses and asserts equality**. - **WinMain = RVA 0x2478440** (FUN_142478440, 4661B): RegisterClassExA + CreateWindow (wndproc @⁠0x14247a660) → `D3D12XboxCreateDevice` (import thunk 0x145f3fd80, 3 imports total from d3d12_xs.dll) → 5-iteration loop creating *paired* heaps (handles array @⁠0x1475e72a0, pointers @⁠0x1475e7300; device-alloc via slots 0x48/9 → 0x248/73 CreateDescriptorHeap → 0x420/132 reserve 0x700000 (heap0) / 0x100000 (heaps1-4) → 0x418/131 second reserve 0xC3C0/0xC380). - **The assert lives in RVA 0x1cf3280** (FUN_141cf3280, 300B) — the game's heap-wrapper. Pseudocode: ```c lVar5 = (*(*heap + 0x48))(); // GetCPUDescriptorHandleForHeapStart if (expected != 0 && lVar5 != expected) → int3; // ← stop 13 obj+0x20 = lVar5; // cpuBase obj+0x28 = expected + count*incr; // cpuEnd obj+0x30 = (u32)incr; // STRIDE obj+0x38 = (flags&1) ? GetGPUStart(+0x50) - GetCPUStart(+0x48) // cached GPU-CPU delta : 0xBADADD0000000000; // = -0x4525230000000000 (GXDK BADADDress sentinel) ``` - **The expected value comes from the game's own bump-allocator** (RVA 0x156c240, FUN_14156c240, 70B, LOCK/CAS): `handle = ALIGN(curs+count-1, align) + align * stride@obj+0x30`, cap @⁠obj+0x28. The game *adopts the placeholder-VA it asked for* — a shim must return exactly that VA from GetCPUDescriptorHandleForHeapStart, not its own allocation. - **Stride = 0x80 (128B) on Scarlett** (not the PC 32B). Four registered pools (via FUN_145a54700 → 0x1cf3280): `(id=1, 0x80, flags=1)`, `(1, 0x80, 0)`, `(2, 0x1000, 0)`, `(3, 0x800, 0)`. flags&1 → GPU-delta path; else the 0xBADADD0000000000 sentinel is stored. - Memory planner before this (FUN_145c5ff00, 267B): reserves **0x40000 slots × 32B = 8MiB** in two segments (mask @⁠0x14615c228 = 0x0000ffff + runtime-adj), cookie @⁠0x14615c1c0 = `02 02 01 00` (vpmovsxbd → [2,2,1,0]). **Fix for the shim**: CreateDescriptorHeap must (a) accept/record the caller-provided base-VA, (b) return it verbatim from GetCPUDescriptorHandleForHeapStart, (c) keep GetGPU−GetCPU consistent per-heap, (d) report 0xBADADD0000000000 for GPU start when the pool is CPU-only, (e) strides 128/4096/2048 by pool-id. In Wine/VKD3D terms: CreatePlacedResource-style fixed-VA semantics, not regular allocations. ## 3) Full import-map: 587 imports × 68 DLLs (nothing hidden) Parsed the static import table (DataDir[1] @⁠RVA 0x6791ab4, 69 descriptors; IAT = DataDir[12] @⁠0x6793490, 655 slots). **delay-imports, bound-imports,LoadConfig: all EMPTY** — the 587×68 is the complete surface. Top: MSVCP140 113, api-ms-win-crt-math 41, libHttpClient.GDK 38, api-ms-win-crt-string 31, stdio 29, WS2_32 25, crt-runtime 25, **Bink2Scarlett 23**, VCRUNTIME140 23, core-file 22, core-synch 17, WINHTTP 15, processthreads 12, **xmem 12**. Exotic: d3d12_xs.dll **3** (D3D12XboxCreateDevice, D3D12ConfigureVirtualMemoryX, D3D12SerializeVersionedRootSignature — confirming all GPU weight is vtable-193, not imports), xg_xs 2, XboxBvhBuilder 7, GameInput.dll **1 (ordinal_1 = GameInputCreate)**, XCRDAPI 1 (DStorageGetFactory), amd_fidelityfx_loader_xbox 4, AcpHal 9, xapu 5, chad 5, MFPlat 6+1, XCurl **0** (loaded via LoadLibrary; 9 loader-imports present), amd_fidelityfx_upscaler_xbox 0 (same), CetAdvancedCompress/dstorage **do not exist** in this build. Rough shim-ontology: 482/587 (82%) = CRT+Win32-core (mechanic); 105/587 (18%) = 15 exotic DLLs, of which **58 (55%) map 1:1 to existing Linux components**: Bink23→Bink2/GL-entropy decoder (we use a librempeg/FFmpeg-based pipeline — 12/12 .bk2 from movies.rpf decode), BVH7→VKD3D-AS (vkCreateAccelerationStructureKHR), xmem12→malloc/posix_memalign/mmap, MF7→ffmpeg. Audio-DSP (AcpHal9+xapu5+chad5=19) = stubs+ring-buffer. Also from MicrosoftGame.Config: TitleId 7952987A, Store 9NL3WWNZLZZN, SMTEnabled true, **XboxLockhart/AnacondaTitleMemory = Advanced** — the memory-annotations matter for the Series-S/X memory-shim. ## 4) Because it's the least-documented: 8th XboxBvhBuilder import The 7 named mangles for XboxBvhBuilder.dll are: ctor/dtor, BuildRaytracingAccelerationStructureBatched2X, CopyRaytracingAccelerationStructure, RehydrateRaytracingAccelerationStructureBatched2X, Set64BitMortonCodes, and (the one that truncates in <200B windows) **GetRaytracingAccelerationStructurePrebuildInfo** (196+ char mangle). Straight 1:1 onto VKD3D-AS. --- If useful, we're happy to: (a) PR our three docs (rpf9-TOC-ghidra.md, d3d12x-stop13-ghidra.md, imports-map.md + exotic-DLL equivalence) into your docs/; (b) contribute the 23/23 TOC-validator (pure-stdlib Python, no deps) under tests/; (c) share the Ghidra hunt logs + full import TSV. Say the word and we'll open the PRs. — GH0ST (oscena), independent, no affiliation.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:48:03 +00:00
Author
Owner

@⁠umbraotus7 on GitHub · 2026-11-24 02:51 UTC · original

Follow-up — the TOC-geometry question I left open in the original post is now CLOSED (except one variable). Independent arithmetic identity, verified 22/22 on the retail containers:

toc_end = 0x40
        + 8*ntags                      (tags,  ntags = u16@0x1A = 4)
        + 16*21                        (root-dir,  u32@0x1C = 0x150 → 21 records, CONSTANT)
        + 24*v_lo                      (v_lo = u16@0x20)
        + pad16
        + 32*w24                       (w24 = u32@0x24)
        + 16*R                         (5th section — see below)
        + ceil((8+b2C)*w24/16)*16      (9B-records, b2C = byte@0x2C)
        = toc_end (EXACT, resid==0, 22/22)

Residual is literally 0 on all 22 files (from 80B appdata0 to 0x1B070 levels.rpf). My earlier 0/22 was a pad8-vs-pad16 + missing-section modeling error — the 16B-alignment everywhere is the invariant.

What remains data-driven is only R (count of 16B-records of a 5th section between the 32B-entries and the 9B-table; observed 0,0,5,6,8,10,10,12,13,28,29,35,41,323,394,540,632,653,1258,1428,2105,2485). Tests that failed: linear fits on (w24, v_lo, v_hi, b2C, tr0C) incl. exhaustive ±4 coefficient search; sums of the root-dir u32 fields (they are hashes — values ~4e9, sums ~4e10, 0/22 hits). The 5th-section records have the SAME shape as root-dir records (u64,u32,u32), all fields hash-like — consistent with FUN_1406bd110's second 16B-table at [f(gen)+0x40+0x150, hdr_len). If anyone gets the semantics of that table (my guess: (entryHash, dirHash, langHash) or a second (nameHash,offset,size) column), the TOC layout is 100% mapped.

So the honest state: geometry 100% (every byte of every TOC accounted, 22/22 resid==0), semantics of the 5th section = open. Everything else from the original post stands.

**@⁠umbraotus7** on GitHub · 2026-11-24 02:51 UTC · [original](https://github.com/Kajcsi/G6Recomp/issues/1#issuecomment-7120544922) Follow-up — the TOC-geometry question I left open in the original post is now CLOSED (except one variable). Independent arithmetic identity, verified 22/22 on the retail containers: ``` toc_end = 0x40 + 8*ntags (tags, ntags = u16@0x1A = 4) + 16*21 (root-dir, u32@0x1C = 0x150 → 21 records, CONSTANT) + 24*v_lo (v_lo = u16@0x20) + pad16 + 32*w24 (w24 = u32@0x24) + 16*R (5th section — see below) + ceil((8+b2C)*w24/16)*16 (9B-records, b2C = byte@0x2C) = toc_end (EXACT, resid==0, 22/22) ``` Residual is literally 0 on all 22 files (from 80B appdata0 to 0x1B070 levels.rpf). My earlier 0/22 was a pad8-vs-pad16 + missing-section modeling error — the 16B-alignment everywhere is the invariant. What remains data-driven is only **R** (count of 16B-records of a 5th section between the 32B-entries and the 9B-table; observed 0,0,5,6,8,10,10,12,13,28,29,35,41,323,394,540,632,653,1258,1428,2105,2485). Tests that failed: linear fits on (w24, v_lo, v_hi, b2C, tr0C) incl. exhaustive ±4 coefficient search; sums of the root-dir u32 fields (they are hashes — values ~4e9, sums ~4e10, 0/22 hits). The 5th-section records have the SAME shape as root-dir records (u64,u32,u32), all fields hash-like — consistent with FUN_1406bd110's second 16B-table at [f(gen)+0x40+0x150, hdr_len). If anyone gets the semantics of that table (my guess: (entryHash, dirHash, langHash) or a second (nameHash,offset,size) column), the TOC layout is 100% mapped. So the honest state: geometry 100% (every byte of every TOC accounted, 22/22 resid==0), semantics of the 5th section = open. Everything else from the original post stands.
This discussion has been locked. Commenting is limited to contributors.
No description provided.