Skip to content

il2cpp: symbolize decomp, resolve fields/enums, Ghidra apply-plan, Frida hooks - #15

Merged
Diphome merged 1 commit into
masterfrom
il2cpp-comprehension
Sep 12, 2026
Merged

Diphome merged 1 commit into
masterfrom
il2cpp-comprehension

Conversation

@Diphome

@Diphome Diphome commented Sep 11, 2026

Copy link
Copy Markdown
Owner

What

Four comprehension features that turn raw Ghidra output into meaning, plus a runtime dimension. All reuse data UnityRift already generates (script.json, the Cpp2IL dummy DLLs) — exposed via CLI (-m il2cpp) and MCP.

Features

1. Symbolize decompilation (--il2cpp-clean now does this)
Rewrites Ghidra's FUN_/DAT_/PTR_ address symbols to managed names from script.json, so a raw decompilation reads with real names without applying anything in Ghidra. Combined with the existing boilerplate-strip + constant annotation.

2. Field + enum resolver (--il2cpp-field, --il2cpp-enum)
New il2cpp_types.json — per-type field offsets and enum value maps extracted from the dummy DLLs via Mono.Cecil ([FieldOffset] + enum consts), cached and shipped in the package. Turns *(int *)(param_1 + 0x24) into a field name/type and if (state == 3) into an enum constant (with flag decomposition).

3. Ghidra apply-plan (--il2cpp-apply-plan <regex|*>)
Emits a {va, name, prototype} batch, optionally name-filtered, to drive rename_function / set_function_prototype through the Ghidra MCP — so names/types can be applied to a targeted subset instead of re-running the whole ghidra.py.

4. Frida hook generator (--il2cpp-frida <name|0xRVA>)
Generates a ready-to-run Frida script that hooks matching methods by RVA (resolves the module base itself, ASLR-safe) and logs typed args/return, with an IL2CPP System.String reader helper. Written to <output>/il2cpp/hooks.js. Confirms at runtime what a statically-reversed method actually does.

Why

The static package nails what the code is. These add the iterative comprehension layer: read names inline, resolve pointer math and enum comparisons, apply names surgically in Ghidra, and verify behaviour dynamically.

Notes for reviewer

  • New code is framework-agnostic except Il2CppTypesJson (Cecil, #if !NETFRAMEWORK, matching the existing IL2CPP gating).
  • il2cpp_types.json is built once (cached) from the dummy DLLs and added to the exported package + its README.
  • New MCP tools: il2cpp_field, il2cpp_enum, il2cpp_frida, il2cpp_apply_plan; server bumped to 0.6.0.
  • Managed compile passes; the local build's only failure is the pre-existing UnityRiftFBXNative.dll post-build copy (runnable binaries come from CI).
  • Field/enum accuracy depends on the dummy DLLs being present (they are, in the IL2CPP cache) — I could not run against a real game locally, so the Cecil [FieldOffset]/enum extraction is best-effort against the documented Cpp2IL attribute shape and should get a smoke test on a real target.

…ida hooks

Four comprehension features on top of the Ghidra package, all reusing the
generated script.json / dummy DLLs (CLI -m il2cpp + MCP):

1. Symbolize (Il2CppDecompCleaner): rewrite Ghidra's FUN_/DAT_/PTR_ address
   symbols to managed names from script.json, so a raw decompilation reads with
   real names without applying anything in Ghidra. Folded into --il2cpp-clean.
2. Field + enum resolver (Il2CppTypesJson + Il2CppSymbolIndex): a new
   il2cpp_types.json (field offsets + enum value maps, extracted from the Cpp2IL
   dummy DLLs via Cecil, cached and shipped in the package) powers --il2cpp-field
   (offset -> field name/type) and --il2cpp-enum (value -> constant, with flag
   decomposition).
3. Ghidra apply-plan (--il2cpp-apply-plan): emit a {va, name, prototype} batch,
   optionally name-filtered, to drive rename + set-prototype via the Ghidra MCP
   without re-running the whole ghidra.py.
4. Frida hooks (Il2CppFridaGenerator, --il2cpp-frida): generate a ready-to-run
   Frida script that hooks matching methods by RVA (resolves module base itself)
   and logs typed args/return; written to <output>/il2cpp/hooks.js.

MCP: il2cpp_field, il2cpp_enum, il2cpp_frida, il2cpp_apply_plan; il2cpp_clean now
symbolizes. Server 0.6.0. Docs updated. Managed compile passes (local build's only
failure is the pre-existing native FBX copy step).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Diphome
Diphome merged commit 33d8162 into master Sep 12, 2026
1 check passed
@Diphome
Diphome deleted the il2cpp-comprehension branch September 12, 2026 08:43
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