Overview
Frida is a dynamic instrumentation toolkit that allows:- Function hooking - Intercept calls and inspect arguments/return values
- Memory inspection - Read struct fields and global state at runtime
- Call tracing - Record function call sequences (RNG, damage calculations)
- State capture - Snapshot game state at specific ticks for differential testing
Setup
Installation
Attach to Process
Frida scripts run by attaching to the running game:-n (attach by name) instead of spawn. Spawning caused texture crashes in testing.
Basic Hooking
Intercepting a Function
Reading Memory
Writing Memory
Capture Scripts
Thescripts/frida/ directory contains specialized instrumentation scripts:
gameplay_diff_capture.js
Tick-aligned state capture for differential testing:gameplay_diff_capture.json with tick-by-tick state.
grim_hooks.js
Grim2D engine call tracing:survival_autoplay.js
Automated gameplay for unattended capture runs:Evidence Collection Patterns
RNG Call Tracing
Damage Calculation Validation
Pool Iteration
Workflow
1. Instrument and Run
Attach script and play the game:C:\share\frida\gameplay_diff_capture.json.
2. Copy Logs to Repo
3. Reduce to Evidence
Normalize captures into machine-readable facts:analysis/frida/facts.jsonl- Normalized evidenceanalysis/frida/evidence_summary.json- Per-function call countsanalysis/frida/name_map_candidates.json- Suggested symbol names
4. Promote to Maps
Review candidates and merge into authoritative maps:Advanced Techniques
Conditional Breakpoints
Backtraces
Unknown Field Discovery
Output Formats
JSONL (JSON Lines)
One JSON object per line:- Streamable (process line-by-line)
- Appendable (no array wrapper)
- Grep-friendly
Structured JSON
Full state snapshots:Just Shortcuts
Common capture workflows:Troubleshooting
Frida fails to attach
Frida fails to attach
Symptom:
Failed to attach: process not foundSolution: Ensure game is running first, then attach:Texture corruption after spawn
Texture corruption after spawn
Symptom: Black screen or crashed texturesSolution: Use
-n (attach) instead of -f (spawn):Script output not saved
Script output not saved
Symptom: Console output disappears on detachSolution: Log to file in script:
Related Pages
WinDbg Debugging
Complementary debugger-based inspection
Differential Testing
Using captures to verify rewrite parity
Struct Recovery
Cross-referencing runtime data with static analysis