Skip to content

docs(d3d12x): stop-13 mechanism fully mapped via Ghidra (placeholder-VA-adopt, 128B stride, 0xBADADD sentinel, 8MiB planner) - #2

Open
yeifer125 wants to merge 1 commit into
avivetech:mainfrom
yeifer125:stop13-ghidra
Open

yeifer125 wants to merge 1 commit into
avivetech:mainfrom
yeifer125:stop13-ghidra

Conversation

@yeifer125

Copy link
Copy Markdown

What

Full Ghidra RE of the D3D12X stop-13 blocker (black window after 512+ PRESENTX frames / 408,781 draws on the FORGE #8851 integration branch). Mechanism, function chain, invariants, and the 4-rule FIX the emulation layer must satisfy. No game assets — documentation + evidence only (GPL-3.0-compatible).

Function chain (RVAs, retail 1.0.2.1 game_scarlett_master.exe)

  • FUN_141cf3280 — assertion helper: lVar5 = (*heap + 0x48)(); if (expected && lVar5 != expected) → int3. This is the crash you're seeing: the CPU-side compute-heap VA the engine caches must EQUAL the value the driver returns.
  • FUN_14156c240 — bump-allocator (CAS): the game computes placement VAs ITSELF and requires the driver to agree ("CPU handle must equal the value it already holds" — #313).
  • FUN_140fc2540 @RvA 0xFC2540 — constructs the in-memory RPF entry; the TOC record lives at entry+0x28; record writer = ROUTER FUN_14087aec0 ← this fn, with values from FUN_141fb2600 (stream offset+size).

Invariants (stop-13 FIX — 4 rules)

  1. placeholder-VA-adopt: if driver returns a different VA, ADOPT the driver's (never rewrite the game's).
  2. Physical stride = 0x80 (128B) — NOT the 32B PC convention. (Measured across all 22 .rpf TOCs.)
  3. Delta consistency: 3rd+ allocation offsets must maintain the delta the allocator computed.
  4. 8MiB planner: FUN_145c5ff00 reserves 8MiB via XMemAlloc; honor alignment/heap-flags EXACTLY (64K-aligned pages).

Sentinel

Physical-mapping markers use 0xBADADD0000000000 (verified: (u64)(-0x4525...) mod 2^64 wraps to it in the relocation loop).

Evidence

  • 17 hunts, 79 artefacts, Ghidra 12.2 headless scripts (24 Hunters) — corpus: 22/22 retail .rpf TOCs parsed geometrically (100%).
  • Additional finding: TOC records are AES-encrypted (payload entropy 7.953; key arrives from a 16B blob INSIDE each .rpf header via setter FUN_144c11710 → FUN_14215f06c (AES-SETKEY) → FUN_14216127c (AES-NI keyexp, 14 rounds = AES-256); 19-suite table at DAT_1462fe860). Affects anyone reimplementing the TOC reader.

Testing

  • Static: Ghidra 12.2 headless, decompiles attached as evidence files (no binary redistribution).
  • Does NOT touch runtime code — docs-only PR (safe, no-merge-risk).

Refs: #313 (D3D12→Vulkan, critical path), #8851 (FORGE integration / FORGE #8851)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T06:54:11.915354Z b5d72d3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5d72d3b62

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

xxh64(0/1) × 36,952 nombres = 0 hits; también AES-128 ECB/CBC/CTR/CFB/OFB ×
5 keys × 6 IVs × 5 subranges = 0 plausibles).
- Los primeros 32B @0x40 = CONSTANTES en todos los .rpf:
5f08daabecbdd40258c3516807024c24fb9f756755ef4be458785bfed8aa6989

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the literal retail TOC bytes

This 32-byte string is explicitly identified as bytes from offset 0x40 of the .rpf archives, so the report contains a literal archive fragment rather than only a derived layout. Remove the raw bytes and keep only the description of their tag values; repository policy forbids game-file contents in commits and reports.

AGENTS.md reference: AGENTS.md:L25-L27

Useful? React with 👍 / 👎.

Comment on lines +34 to +37
FUN_140193f90(MAGIC,id,1) = key-lookup (hash→key)
FUN_144c11250(&cipher,id) = dispatcher; id 1/2/3→FUN_145e90390(1/2/3):
416B obj, init FUN_141b43cb5, AES-NI (FUN_14215f06c setkey 128/192/256;
FUN_14216127c AESKEYGENASSIST; 10/12/14 rounds @+0xF0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the AES decryption trace

These lines trace the nonzero cipher branch from key lookup through AES key setup, expansion, and round selection; this is implementation-level decryption analysis, not merely a note that a format is encrypted. Repository policy says to record encryption in docs/design.md and stop, so remove these cipher-branch details rather than providing a runtime shim with a decryption path.

AGENTS.md reference: AGENTS.md:L30-L31

Useful? React with 👍 / 👎.

Comment on lines +43 to +44
- FUN_140536ac0(u16) → 0 si u16 ≥ 0x13. En TODOS nuestros .rpf, u16@hdr+2 = 0x5046
("FP" del magic, LE) → SIEMPRE 0 → siempre no-op.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify the cipher-ID field before declaring every TOC a no-op

Per docs/rpf.md:10-11, the RPF9 magic occupies bytes 0–3 and the data offset is at +4, so u16@hdr+2 is signature data, not an independent cipher ID; the documented RPF9/9FPR magic also cannot yield the claimed 0x5046 there. This read therefore cannot prove every archive selects id 0, yet it is used to conclude that every TOC is a no-op; identify and validate the actual field before presenting that runtime contract as measured.

AGENTS.md reference: AGENTS.md:L62-L63

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant