Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ef15471
Initial remix-comp implementation
Kim2091 Mar 29, 2026
685ab4f
Clean up codebase
Kim2091 Mar 29, 2026
3639923
Fix missing dll
Kim2091 Mar 29, 2026
0869a94
Integrate tracer into remix-comp
Kim2091 Mar 30, 2026
2c37ead
Refine prompts
Kim2091 Mar 30, 2026
120548c
Clean up build process
Kim2091 Mar 30, 2026
9797851
Update build.bat
Kim2091 Mar 30, 2026
8ef1c07
Make build.bat even easier
Kim2091 Mar 30, 2026
52dae7c
Overhaul remix-comp workflow and fix FFP bugs
Kim2091 Mar 31, 2026
b9dff84
Fix logging issues
Kim2091 Mar 31, 2026
32b0dad
Clean up logging system
Kim2091 Mar 31, 2026
52ded3b
Various bug & QoL fixes
Kim2091 Mar 31, 2026
937b669
Fix more bugs, skill files, prompts
Kim2091 Mar 31, 2026
576cd71
Add pointers to dx9 skill so agents know about if it hasnt triggerd
Night1099 Mar 31, 2026
357840a
move remix-comp-context.md rule to a refernce
Night1099 Mar 31, 2026
5a3bde9
Optimize context usage for prompts + skills
Kim2091 Apr 1, 2026
bb2ed93
Potentially reduce context usage
Kim2091 Apr 1, 2026
f49200e
Split out drawcall context
Kim2091 Apr 1, 2026
c8e9a69
New DX9 RE scripts
Kim2091 Apr 1, 2026
00c7a1d
Clarify common FFP conversion issues in skill files
Kim2091 Apr 1, 2026
5167031
Move ffp registers from config to hardcoded
Kim2091 Apr 1, 2026
6456cd3
Convert from asi to proxy
Kim2091 Apr 2, 2026
de1c0cf
Rename remix-comp to remix-comp-proxy, enhance tracer
Kim2091 Apr 2, 2026
c9d0946
Replace berry icon with optional custom icon
Kim2091 Apr 2, 2026
1bed293
Fix FFP toggle bug
Kim2091 Apr 2, 2026
8b605c3
Move ini file location (next to DLL), enhance logging warnings
Kim2091 Apr 2, 2026
b4e7a9d
Merge upstream master: add dataflow, indirect calls, switch tables, CI
Kim2091 Apr 2, 2026
5a608e7
distinguished the remix-comp-proxy template (copied per-game) from sh…
Night1099 Apr 2, 2026
0974f51
bring other agents into sync
Night1099 Apr 2, 2026
6f29551
Fix correctness bugs, finish DX script migration, harden proxy
Kim2091 Apr 2, 2026
f74c504
Merge branch 'remix-comp-integration' of https://github.com/Kim2091/V…
Kim2091 Apr 2, 2026
205f386
Add scripts to assist with skinning conversion
Kim2091 Apr 2, 2026
19985c3
Bug fixes for skinning scripts
Kim2091 Apr 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 31 additions & 4 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# Vibe Reverse Engineering -- Claude Code Instructions

## Read-Only Templates

These directories are **shared tooling and templates**. Do not modify them for game-specific work — per-game changes go in `patches/<GameName>/`.

- `rtx_remix_tools/dx/remix-comp-proxy/` — proxy framework **template** (copied per-game)
- `rtx_remix_tools/dx/scripts/` — DX9 analysis scripts (shared tooling)
- `retools/` — static analysis toolkit (shared tooling)
- `livetools/` — Frida-based dynamic analysis (shared tooling)
- `graphics/` — DX9 tracer framework (shared tooling)

**Per-game work goes in `patches/<GameName>/`.** When starting a new game, copy `rtx_remix_tools/dx/remix-comp-proxy/` (excluding `build/`) to `patches/<GameName>/` and edit the copy. If the user says "edit remix-comp-proxy code" without specifying, ask whether they mean the template or a game copy.

Shared tooling can be modified to improve the tools themselves — just not for game-specific customization.

---

## Delegation Rule

**Never run static analysis tools directly.** Delegate to a `static-analyzer` subagent. Only exceptions — run these inline:
- `sigdb.py identify` / `fingerprint` (single-function ID, <5s)
- `context.py assemble` / `postprocess` (context gathering, <5s)
- `context.py assemble` / `postprocess` (context gathering, <5s; use `--no-dataflow` on large functions)
- `dataflow.py --constants` / `--slice` (single-function analysis, <5s)
- `readmem.py` (single typed read from PE, <5s)
- `asi_patcher.py build` (build step, not analysis)
Expand Down Expand Up @@ -72,9 +88,20 @@ Each file reads as if it was always designed this way. Comments guide the next d

---

## DX9 FFP Porting

When working on any of the following — invoke the **`dx9-ffp-port` skill** immediately before starting:
- Editing `renderer.cpp`, `ffp_state.cpp`, `remix-comp-proxy.ini`, or draw routing logic
- Porting a game for RTX Remix / fixed-function pipeline
- Diagnosing VS constant registers, vertex declarations, matrix mapping, skinning
- Building, deploying, or iterating on a remix-comp-proxy patch (`build.bat`, `diagnostics.log`, ImGui F4)

---

## References

- **Tool catalog, decision guide, and caveats**: @.claude/rules/tool-catalog.md
- **Tool dispatch (which tool, run vs delegate)**: @.claude/rules/tool-dispatch.md
- **Full tool syntax tables and caveats**: `.claude/references/tool-catalog.md` (read on demand, not auto-loaded)
- **Subagent workflow and delegation rules**: @.claude/rules/subagent-workflow.md
- **DX9 FFP proxy porting for RTX Remix**: `/dx9-ffp-port` skill
- **Frida-based dynamic analysis**: `/dynamic-analysis` skill
- **DX9 FFP proxy porting for RTX Remix**: `.claude/skills/dx9-ffp-port/SKILL.md` (invoke `dx9-ffp-port` skill, not auto-loaded)
- **Frida-based dynamic analysis**: `/dynamic-analysis` skill
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ These are fast (<5s) and allowed inline:

Everything else. Tell the subagent WHAT you need, not HOW to run it — it has the full tool catalog.

**D3D9-specific questions?** Check the DX analysis scripts section below first — they're faster and more targeted than general retools for D3D API usage, device calls, shader constants, and vertex formats.

- "What does this function do?" → decompile + callgraph + xrefs + dataflow --constants
- "Who calls this function?" → xrefs or callgraph --up
- "What does this function call?" → callgraph --down (add --indirect for vtable calls)
Expand All @@ -57,6 +59,31 @@ Everything else. Tell the subagent WHAT you need, not HOW to run it — it has t
- "How many draw calls happen?" → `livetools dipcnt`
- "Who writes to this memory address?" → `livetools memwatch`

### DX analysis scripts (main agent, fast first-pass)

These are targeted D3D9 scanners under `rtx_remix_tools/dx/scripts/`. They run in seconds and surface D3D-specific patterns that general-purpose retools would take longer to find. **Use these BEFORE retools** when the question is about D3D9 API usage, device calls, shaders, or vertex formats. Run as `python rtx_remix_tools/dx/scripts/<script> <args>`.

- "How does the game use D3D9?" → `find_d3d_calls.py <game.exe>` (imports + call sites)
- "Which VS constant registers hold matrices?" → `find_vs_constants.py <game.exe>` (SetVertexShaderConstantF call sites with register/count)
- "Which PS constant registers are used?" → `find_ps_constants.py <game.exe>` (SetPixelShaderConstantF/I/B with register/count)
- "Where does the game call the D3D device?" → `find_device_calls.py <game.exe>` (vtable call patterns + device pointer refs)
- "What render states does the game set?" → `find_render_states.py <game.exe>` (SetRenderState args: culling, blending, depth, fog)
- "How does the texture pipeline work?" → `find_texture_ops.py <game.exe>` (SetTexture stages, TSS ops, sampler filter/address modes)
- "Which transform types are used?" → `find_transforms.py <game.exe>` (SetTransform: World, View, Projection, Texture)
- "What surface formats does the game create?" → `find_surface_formats.py <game.exe>` (CreateTexture/RT/DS format extraction)
- "Does the game use state blocks?" → `find_stateblocks.py <game.exe>` (state block creation/recording/apply)
- "Does the game use FVF or vertex declarations?" → `decode_fvf.py <game.exe>` (FVF bitfield decoding)
- "What vertex formats does the game use?" → `decode_vtx_decls.py <game.exe> --scan` (vertex declarations, detects skinning)
- "Are shaders embedded in the binary?" → `find_shader_bytecode.py <game.exe>` (shader bytecode extraction with version/size)
- "What's the FFP vs shader draw call mix?" → `classify_draws.py <game.exe>` (draw call classification by state context)
- "Which registers are View/Proj/World?" → `find_matrix_registers.py <game.exe>` (CTAB names + frequency heuristics + layout suggestion)
- "D3DX constant table or vtable calls?" → `find_vtable_calls.py <game.exe>` (D3DX CTAB usage + D3D9 vtable calls)
- "Does the game have skinned meshes? What config does the proxy need?" → `find_skinning.py <game.exe>` (skinned decls, bone palettes, blend states, suggested INI)
- "Does the game use FFP vertex blending?" → `find_blend_states.py <game.exe>` (D3DRS_VERTEXBLEND + INDEXEDVERTEXBLENDENABLE + WORLDMATRIX)
- "Map all D3D calls in a code region" → `scan_d3d_region.py <game.exe> 0xSTART 0xEND`

These are fast first-pass scanners — they surface candidate addresses. Follow up with `retools` (decompiler, xrefs) and `livetools` (trace, bp) for deep analysis of the addresses they find.

### dx9tracer (main agent for capture, delegate analysis)

- "Trigger a frame capture" → main agent: `python -m graphics.directx.dx9.tracer trigger`
Expand Down Expand Up @@ -162,15 +189,16 @@ python -m livetools status # check connection

A proxy DLL that intercepts all 119 `IDirect3DDevice9` methods, capturing every call with arguments, backtraces, pointer-followed data (matrices, constants, shader bytecodes), and in-process shader disassembly (via the game's own d3dx9 DLL). Outputs JSONL for offline analysis.

**Architecture**: Python codegen (`d3d9_methods.py`) → C proxy DLL (`src/`) → JSONL → Python analyzer (`analyze.py`). The proxy chains to the real d3d9 (or another wrapper) and adds near-zero overhead when not capturing.
**Architecture**: Python codegen (`d3d9_methods.py`) → C proxy DLL (`src/`) or C++ remix-comp-proxy dispatch (`tracer_dispatch.inc`) → JSONL → Python analyzer (`analyze.py`). The standalone proxy chains to the real d3d9 (or another wrapper) and adds near-zero overhead when not capturing. The remix-comp-proxy integrated tracer records from within the dinput8.dll hook.

### Setup and Capture

```
python -m graphics.directx.dx9.tracer codegen -o d3d9_trace_hooks.inc # regenerate C hooks
cd graphics/directx/dx9/tracer/src && build.bat # build proxy DLL
python -m graphics.directx.dx9.tracer codegen -o d3d9_trace_hooks.inc # C hooks (standalone proxy)
python -m graphics.directx.dx9.tracer codegen -f cpp -o tracer_dispatch.inc # C++ dispatch (remix-comp module)
cd graphics/directx/dx9/tracer/src && build.bat # build standalone proxy DLL
# Deploy d3d9.dll + proxy.ini to game directory
python -m graphics.directx.dx9.tracer trigger --game-dir <GAME_DIR> # trigger capture (3s countdown)
python -m graphics.directx.dx9.tracer trigger --game-dir <GAME_DIR> # trigger capture (3s countdown)
```

**proxy.ini** settings: `CaptureFrames=N` (frames to record), `CaptureInit=1` (capture boot-time calls like shader creation), `Chain.DLL=<wrapper.dll>` (chain to another d3d9 wrapper, or leave empty for system d3d9).
Expand Down Expand Up @@ -210,6 +238,31 @@ All analysis: `python -m graphics.directx.dx9.tracer analyze <JSONL> [OPTIONS]`
| `--filter EXPR` | Filter records by field (e.g. `frame==0`, `slot==83`) |
| `--export-csv FILE` | Export raw records to CSV |

## DX Analysis Scripts (`rtx_remix_tools/dx/scripts/`) -- fast D3D9 scanners

Targeted first-pass scanners for D3D9 games. Run from repo root. Output is candidate addresses and patterns — always follow up with retools/livetools for confirmation.

| Script | What it surfaces | Example |
|--------|-----------------|---------|
| `find_d3d_calls.py $B` | D3D9/D3DX imports and call sites | `python rtx_remix_tools/dx/scripts/find_d3d_calls.py game.exe` |
| `find_vs_constants.py $B` | `SetVertexShaderConstantF` call sites with register/count args | `python rtx_remix_tools/dx/scripts/find_vs_constants.py game.exe` |
| `find_ps_constants.py $B` | `SetPixelShaderConstantF/I/B` call sites with register/count args | `python rtx_remix_tools/dx/scripts/find_ps_constants.py game.exe` |
| `find_device_calls.py $B` | Device vtable call patterns and device pointer refs | `python rtx_remix_tools/dx/scripts/find_device_calls.py game.exe` |
| `find_render_states.py $B` | SetRenderState arguments decoded by category (culling, blending, depth, fog) | `python rtx_remix_tools/dx/scripts/find_render_states.py game.exe` |
| `find_texture_ops.py $B` | Texture pipeline: SetTexture stages, TSS color/alpha ops, sampler states | `python rtx_remix_tools/dx/scripts/find_texture_ops.py game.exe` |
| `find_transforms.py $B` | SetTransform/MultiplyTransform types (World, View, Projection, Texture) | `python rtx_remix_tools/dx/scripts/find_transforms.py game.exe` |
| `find_surface_formats.py $B` | CreateTexture/RenderTarget/DepthStencil D3DFMT extraction | `python rtx_remix_tools/dx/scripts/find_surface_formats.py game.exe` |
| `find_stateblocks.py $B` | State block creation, recording, and apply patterns | `python rtx_remix_tools/dx/scripts/find_stateblocks.py game.exe` |
| `decode_fvf.py $B` | FVF bitfield decode from SetFVF calls (or `--decode 0xNNN` manual) | `python rtx_remix_tools/dx/scripts/decode_fvf.py game.exe` |
| `find_vtable_calls.py $B` | D3DX constant table usage and D3D9 vtable calls | `python rtx_remix_tools/dx/scripts/find_vtable_calls.py game.exe` |
| `decode_vtx_decls.py $B --scan` | Vertex declaration formats (BLENDWEIGHT/BLENDINDICES = skinning) | `python rtx_remix_tools/dx/scripts/decode_vtx_decls.py game.exe --scan` |
| `find_shader_bytecode.py $B` | Embedded shader bytecode extraction (version, size, `--dump-dir`) | `python rtx_remix_tools/dx/scripts/find_shader_bytecode.py game.exe` |
| `classify_draws.py $B` | Draw call classification by state context (FFP/shader/hybrid %) | `python rtx_remix_tools/dx/scripts/classify_draws.py game.exe` |
| `find_matrix_registers.py $B` | Identify View/Proj/World registers (CTAB + frequency + layout suggestion) | `python rtx_remix_tools/dx/scripts/find_matrix_registers.py game.exe` |
| `find_skinning.py $B` | Consolidated skinning analysis: skinned decls, bone palettes, blend states, suggested INI | `python rtx_remix_tools/dx/scripts/find_skinning.py game.exe` |
| `find_blend_states.py $B` | D3DRS_VERTEXBLEND + INDEXEDVERTEXBLENDENABLE + WORLDMATRIX transforms | `python rtx_remix_tools/dx/scripts/find_blend_states.py game.exe` |
| `scan_d3d_region.py $B 0xSTART 0xEND` | Map all D3D9 vtable calls in a code region | `python rtx_remix_tools/dx/scripts/scan_d3d_region.py game.exe 0x401000 0x500000` |

## Tool Caveats

### `rtti.py` -- MSVC RTTI only
Expand Down
Loading
Loading