Skip to content

feat(il2cpp): link methods to native addresses and write Ghidra seeds - #5327

Merged
gensokyo-dev merged 6 commits into
morluto:mainfrom
8rulerstar:feat/il2cpp-native-seeds
Oct 20, 2026
Merged

gensokyo-dev merged 6 commits into
morluto:mainfrom
8rulerstar:feat/il2cpp-native-seeds

Conversation

@8rulerstar

@8rulerstar 8rulerstar commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #5112. Link IL2CPP metadata names to native method addresses/type facts and export Ghidra seeds, extending @8rulerstar's implementation and retaining their latest commit e13938233 with follow-ups.

Behavior and boundaries

binary_path selects a matching 64-bit PE/ELF/Mach-O binary. CLI/MCP share the same application/producer implementation. Retained views select batches of indices, addresses or states, fields and pages; every folded-body alternative and both artifact identities remain accessible. Module tables have their own page instead of inflating the default summary; full Evidence remains exportable.

Native readers reuse the container owner's mappings/executable spans and populate facts once. Cooperative scans, lazy generic names, no pointer-table copy, early row/text admission and bounded expansion control work and allocation. The shared application seed workflow reuses the completed report, enforces existing consumer limits, publishes atomically to a new file and retains completed Evidence/output receipts on failure; failed cleanup stays owned. Superseded formatter/writer paths and redundant tests were removed.

Observed metadata, derived static associations, and inferred executable-byte fallback remain distinct. Unknown relocations never become observed-zero/no-body. Unrequested native counts are null; unsupported/partial results retain source identity and reasons. Matching is structural, not cryptographic same-build proof.

Scope: existing local static file reading, caller-requested output and existing Ghidra import; no new execution/injection/provider authority, dependency or installer changes. Domain facts, native adapters, application workflows and CLI/MCP keep inward dependencies. Authored contracts/docs/skill updated; generated outputs stay ignored.

Executed validation

Production verification at 9b6045b26; final head 66bcbfdb0c5d78111364bb2861622039915eed09 only removes one stale acceptance assertion:

  • 381 tests across 17 files passed: IL2CPP producer/service/views/public CLI/actual SDK, shared Go mappings/containers, atomic filesystem, and affected JavaScript/CLI regression suites. SDK schemas validated under JSON Schema2020-12; retained queries work after both source files are removed.
  • npm run check:ci: all 8 tasks and architecture guards passed; docs:generate /docs:check passed, including 5 README tests. No threshold/exclusion changes.
  • Both real Windows x64 and Android arm64 artifacts from MIT-licensed Between Two Worlds 1.0.5, Unity 2023.2.13f1 /metadata 29: 43,198 and 42,098 code rows, zero differences against official Il2CppDumper6.7.46 qualified names and RVA+base. All8 metadata collections match the independent reference API row-for-row; all 4 input hashes unchanged.
  • Final seeds cover 34,485 Windows and 42,098 Android unique addresses and are byte-identical to the earlier qualified files. Real Ghidra 12.1.4 accepted all Windows seeds (5,110 new /29,375 existing /0 failed /0 unmapped), found IngameDebugConsole.DebugLogManager$$ShouldRemoveLogEntryToShow at 0x180c5ca60, and returned its 26-byte body,8 instructions and pseudocode after default auto-analysis. JVM/project removed on close; input unchanged. Ghidra runtime was pinned to 95a20b11a; later changes leave Ghidra and seed rows unchanged.
  • The documented metadata verifier passed actual Windows CLI/MCP complete/summary/page checks. Regression counterexamples proved PE split-array rejection (red→green), overlapping fallback-array loss (red→green), unknown/zero distinctions, bounded generic expansion, cancellation/cleanup, seed consumer limits and historical omission.

An additional acceptance consumer of the same stale URL wording was independently reproduced on built main and corrected. All17 related CLI/path tests and the duplication gate pass; this follow-up changes no production code.

Two reproduced main CI blockers are repaired in a separate follow-up commit: URL rejection tests depended on obsolete wording (3 failures), and exported declarations lost their semantic statement position (1 actual built-worker failure). Statement ownership now normalizes the export wrapper and removes the class-only workaround; URL tests preserve rejection/path assertions. A separately built main with only those repairs passes 74 relevant tests, including branch/activation uncertainty cases. Redundant fixture/setup/response parsing was consolidated with original oracles retained; the global duplication gate passes unchanged.

Artifact identities and complete-task cost evidence
Artifact Metadata SHA-256 Binary SHA-256
Windows 5691bdd9161d054db69cc842397c7a42c6bf4a544060f05d741e99a6a3a07d29 a3ae7f6ecd1f671297b7d98d12713ef024062d93cd7a4205298102656c93b67a
Android 3814d666a9f83388a71d7ad7ffb67b2cdaf7f2fef5c48c021ddf43373cdad64e 9fa9170439ccdca152bfb86ea5d1ee2fae62c476b226c4251fec9fc935c88d9e

Task: find DebugLogManager.get_IsLogWindowVisible, address 0x180c56ed0, both shared-body definitions (indices 39403/45972), their names/owners/return types, and export full Evidence. Legacy scans 512-row address pages; selected uses the exact address filter. Both final variants retain identical requested facts/Evidence access. Revision 95a alternated both orders; small fixtures also ran both orders (representative rows below). Revision 9b repeats the equivalent complete real task after review fixes.

Tokenx estimates include used/all input declarations, arguments and full replies, with all extra calls. Final whole-wire estimates, including catalog output schemas: legacy 4,063,553, selected 1,057,887. Actual model usage/rendering/tool selection are unmeasured.

Revision /task RPCs Used-declaration estimated tokens All-input-declaration estimated tokens Wall s Family CPU s Sampled family RSS GiB
fc14dbaab /baseline-real-legacy 103 2,998,739 3,223,018 21.997 26.543 2.391
95a20b1 /final-real-legacy-1 103 3,039,891 3,264,969 17.616 22.373 2.291
95a20b1 /final-real-selected-1 8 38,969 264,047 12.077 14.730 1.080
95a20b1 /final-real-selected-2 8 38,969 264,047 12.022 14.652 1.113
95a20b1 /final-real-legacy-2 103 3,039,891 3,264,969 17.287 22.224 2.326
95a20b1 /final-small-legacy-1 8 38,411 263,489 7.161 8.878 0.901
95a20b1 /final-small-selected-1 8 38,239 263,317 6.988 8.743 0.926
9b6045b /integration-real-legacy 103 3,039,888 3,264,966 22.707 24.743 2.424
9b6045b /integration-real-selected-only 8 38,972 264,050 12.143 14.895 1.158

Separate 24 warm retained-address probes: median 17.51ms, range 15.80–26.35ms, excluded from the primary rows above. Whole-task profiles include SDK/client/server, catalog/AJV, decoding, queries, export and teardown. Engine-only costs unmeasured; fresh runtime caches, OS caches/host load uncontrolled. Baseline fc14 includes an older main, so its timing change is not attributed solely to this feature. Small input is authored, not real-engine coverage.

Linux/Node 24.18.0; two-CPU affinity,3 GiB V8 heaps,8 GiB sampled process-family guard; no OOM/guard stops/retries. RSS sampled20 ms may double-count shared pages or miss brief peaks. Report budgets are not total-RSS bounds. Reference tools lived privately, outside REA dependencies.

Ghidra default cold analysis is expensive: 1395.88s wall /1705.24s familyCPU /7.218 GiB sampled familyRSS,2 CPUs/4 GiB JVM heap/8 GiB guard; no guard stop. No Ghidra speedup is claimed.

Coverage limits: generic instances/thunks/invokers,32-bit images, packed ELF relocations and Mach-O chained fixups remain unsupported. Original contributor-reported non-v29/platform runs remain credited in the discussion/docs and were not rerun here. Reference omission does not prove no-body/unknown semantics. Fallback bytes do not prove instruction boundaries/runtime use. No game executed or executable modified.

Author readiness

Human owner: @gensokyo-dev

Original contribution: @8rulerstar. The human owner authorized the work, delegated technical review/validation to Codex and directed these declarations and ready submission. This records that instruction; it does not assert an independent human review of follow-ups or review of later commits by the original contributor.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

With binary_path naming the matching Mach-O, PE or ELF IL2CPP binary, method addresses (with a code, no-body or unknown state) and field, parameter and return type names are read from its code-generation modules and type table without running it; ELF RELATIVE relocations are applied and x86-64 builds without a static CodeRegistration are linked through the instruction that loads the module array. --ghidra-seeds writes REA_GHIDRA_SEED_FILE function seeds, with folded methods listed as comments. Linking yields between batches and keeps the metadata source facts when it fails.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-20T12:52:45.629356Z e139382 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking findings remain.

Summary

Adds static IL2CPP method-address linking, retained native queries, and Ghidra seed export.

  • IL2CPP reports can link metadata methods and types to addresses in a selected native binary.
  • A linked IL2CPP report can produce function-name seeds for Ghidra.
  • Exported JavaScript declarations keep their place in the statement order.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  M[Metadata file] --> S[Shared inspection service]
  B[Optional native binary] --> S
  S --> E[Complete Evidence]
  E --> V[Summary and selected pages]
  E --> W[Optional seed export]
  W --> F[New Ghidra seed file]
Loading

Reviews (4) · Last reviewed commit: "test(cli): assert file URL rejection ind..." · Reviewed by Greptile

Comment thread src/il2cpp/Il2cppBinaryFile.ts Resolved
Comment thread src/il2cpp/Il2cppBinaryFile.ts Resolved
Comment thread src/cli/il2cppCommands.ts Resolved
Comment thread src/domain/il2cpp/il2cppGhidraSeeds.ts Resolved
Comment thread src/il2cpp/Il2cppBinaryFile.ts Resolved
Comment thread src/domain/il2cpp/il2cppMetadata.ts Resolved
Comment thread src/il2cpp/Il2cppMetadataFile.ts Resolved
Comment thread src/il2cpp/Il2cppMetadataProvider.ts Resolved
Comment thread src/il2cpp/Il2cppBinaryRegistration.ts Resolved
Comment thread scripts/verify-il2cpp-metadata.mjs Resolved
Repair independently reproduced main CI failures: normalize exported statements at their position owner and assert URL rejection independently of schema wording. Existing boundary regression and 74 relevant tests pass on a separately built main with these repairs.
@gensokyo-dev
gensokyo-dev merged commit 52d1a72 into morluto:main Oct 20, 2026
5 of 7 checks passed
@8rulerstar

8rulerstar commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you very much, @gensokyo-dev, for merging this and for the follow-up commits that kept my original commit in the history. I re-ran the real samples on the merged head 66bcbfdb0 and compared them with e13938233:

Build code / no-body / unknown vs Il2CppDumper 6.7.46 Method rows changed from e139382
macOS arm64 + x86_64, Unity 2020.3 to 6000.0 (12 runs) e.g. 6000.0.84f1: 14,511 / 1,822 / 0 all named addresses equal none
Android arm64 2022.3.62f3 10,057 / 1,471 / 0 10,057 / 10,057 equal none
Between Two Worlds Windows x64 43,198 / 5,950 / 0 44,933 / 44,933 names equal (incl. 1,735 folded groups) none
Between Two Worlds Linux x64 (inlined CodeRegistration) 42,607 / 5,940 / 0 Il2CppDumper fails; Cpp2IL with StrippedCodeRegSupport finds the same array 0x3582e80 none

Every method row (address, state and type names) is identical on all 15 runs, and every seed file parses back with parseGhidraSeeds. The normalized results and seed files of 66bcbfdb0 are byte for byte the same as those of 95a20b11a, so f00959146 did not change the output on these samples. The only differences from my commit are the intended ones: the new provenance header lines in the seed file, the derived/inferred confidence and the extra limitation text. On an idle machine the Linux build takes about 3.4 to 3.5 s of user CPU on both e13938233 and 66bcbfdb0, with peak memory around 610 MB.

Thanks again for all the careful hardening work on this.

@morluto morluto added the provider: il2cpp Analysis provider / engine: il2cpp label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra provider: il2cpp Analysis provider / engine: il2cpp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Resolve Unity IL2CPP method addresses and emit Ghidra seeds (follow-up to #3784)

3 participants