Skip to content

il2cpp: constant recovery, decomp cleaning & symbol suggestion for Ghidra RE - #13

Merged
Diphome merged 1 commit into
masterfrom
il2cpp-re-helpers
Sep 10, 2026
Merged

il2cpp: constant recovery, decomp cleaning & symbol suggestion for Ghidra RE#13
Diphome merged 1 commit into
masterfrom
il2cpp-re-helpers

Conversation

@Diphome

@Diphome Diphome commented Sep 10, 2026

Copy link
Copy Markdown
Owner

What

Adds a decompile-time reverse-engineering layer on top of the existing Il2CppDumper-compatible Ghidra package. Ported three standalone Python helpers into the C# toolchain so they run in one place (CLI -m il2cpp + MCP), reusing Il2CppSymbolIndex and the game's resolved binary.

Why

The existing exporter produces the static package (types, structs, symbols). What was missing is the iterative layer you actually use while decompiling in Ghidra: recovering the constants Ghidra hides as raw hex, cutting the IL2CPP boilerplate out of a function, and finding which symbols to look at. These fill that gap.

Changes

1. Constant recoveryIl2CppConstantResolver.cs (new)

  • Decodes packed float/double/int immediates shown as raw hex (0x3f19999a3e99999a(0.3f, 0.6f); 0x3f8000001.0f).
  • BinaryImage: VA→file-offset mapper reading DAT_<va> literal-pool loads — PE and ELF, 32/64-bit (the original Python was ELF64-only).
  • CLI --il2cpp-decode, --il2cpp-data; MCP il2cpp_decode, il2cpp_data.

2. Decomp cleanerIl2CppDecompCleaner.cs (new)

  • Strips IL2CPP boilerplate (class-init guards, metadata-init thunks, ctor scaffolding, empty decls) by shape — survives a rebased/rebuilt binary — and annotates hidden constants inline. Project-specific namespace-shortening from the original was intentionally dropped.
  • CLI --il2cpp-clean [--il2cpp-clean-raw]; MCP il2cpp_clean.

3. Fuzzy search / suggestIl2CppSymbolIndex.cs

  • Ratio (Levenshtein), KeywordsFromText, Suggest(), and a fuzzy mode folded into the existing FindByName so it enhances il2cpp_lookup rather than duplicating it.
  • CLI --il2cpp-suggest, --il2cpp-fuzzy; MCP il2cpp_suggest + use_fuzzy on il2cpp_lookup.

Docs updated (main README, tools/mcp/README.md); MCP server bumped to 0.5.0.

Notes for reviewer

  • The new resolver/cleaner/index code is framework-agnostic (no Cpp2IL/LibCpp2IL dependency) — usable on any target and testable in isolation.
  • Managed compile passes; the local build's only failure is the pre-existing UnityRiftFBXNative.dll post-build copy step, so runnable binaries come from CI.
  • Decoder math verified against IEEE-754 ((0.3f, 0.6f), 1.0f).

… for Ghidra RE

Adds a decompile-time RE layer on top of the existing Il2CppDumper-compatible
package, ported from standalone Python helpers into the C# toolchain (CLI + MCP):

- Il2CppConstantResolver / BinaryImage: decode packed float/double/int immediates
  Ghidra shows as raw hex (0x3f19999a3e99999a -> (0.3f, 0.6f)), and resolve
  DAT_<va> literal-pool loads by mapping VA -> file offset (PE and ELF, 32/64-bit).
- Il2CppDecompCleaner: strip IL2CPP boilerplate (class-init guards, metadata-init
  thunks, ctor scaffolding, empty decls) by shape (survives a rebased binary) and
  annotate hidden constants inline.
- Il2CppSymbolIndex: fuzzy name matching + Suggest() to map a feature/keywords (or
  a script file) to ranked Type$$ symbols worth decompiling.

CLI (-m il2cpp): --il2cpp-decode, --il2cpp-data, --il2cpp-clean [--il2cpp-clean-raw],
--il2cpp-suggest, --il2cpp-fuzzy (also applies to --il2cpp-lookup).
MCP: il2cpp_decode, il2cpp_data, il2cpp_clean, il2cpp_suggest tools; use_fuzzy on
il2cpp_lookup. Docs updated.

Co-Authored-By: Clue <noreply@anthropic.com>
@Diphome
Diphome merged commit 85dba26 into master Sep 10, 2026
1 check passed
@Diphome
Diphome deleted the il2cpp-re-helpers branch September 10, 2026 18:08
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