il2cpp: constant recovery, decomp cleaning & symbol suggestion for Ghidra RE - #13
Merged
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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), reusingIl2CppSymbolIndexand 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 recovery —
Il2CppConstantResolver.cs(new)0x3f19999a3e99999a→(0.3f, 0.6f);0x3f800000→1.0f).BinaryImage: VA→file-offset mapper readingDAT_<va>literal-pool loads — PE and ELF, 32/64-bit (the original Python was ELF64-only).--il2cpp-decode,--il2cpp-data; MCPil2cpp_decode,il2cpp_data.2. Decomp cleaner —
Il2CppDecompCleaner.cs(new)--il2cpp-clean [--il2cpp-clean-raw]; MCPil2cpp_clean.3. Fuzzy search / suggest —
Il2CppSymbolIndex.csRatio(Levenshtein),KeywordsFromText,Suggest(), and afuzzymode folded into the existingFindByNameso it enhancesil2cpp_lookuprather than duplicating it.--il2cpp-suggest,--il2cpp-fuzzy; MCPil2cpp_suggest+use_fuzzyonil2cpp_lookup.Docs updated (main README,
tools/mcp/README.md); MCP server bumped to 0.5.0.Notes for reviewer
UnityRiftFBXNative.dllpost-build copy step, so runnable binaries come from CI.(0.3f, 0.6f),1.0f).