Skip to content

feat(il2cpp): link generic method instances behind --generic-instances - #5785

Merged
gensokyo-dev merged 23 commits into
morluto:mainfrom
8rulerstar:feat/il2cpp-generic-instances
Oct 24, 2026
Merged

gensokyo-dev merged 23 commits into
morluto:mainfrom
8rulerstar:feat/il2cpp-generic-instances

Conversation

@8rulerstar

@8rulerstar 8rulerstar commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Adds opt-in generic_instances / --generic-instances to link IL2CPP generic method instances through the existing static native reader, expose instance/issue views, and include valid instances in existing Ghidra seeds. Metadata 27/29/31 with static registration is supported; unsupported layouts remain typed failures. No target executes and no new provider is introduced. Related #3607; follow-up to #5112/#5327.

The contributor's review fixes keep issue arrays out of summaries and read generic containers on demand. Maintenance verification also found and corrected an unreadable method-spec index becoming -1: unreadable is now null, a recorded -1 stays recorded, and named rows/method filters preserve that distinction. The author's later cleanup commit is incorporated, along with main 98ec00f4068bab894639d0d1d83ac0bfc428bcbf.

Validation: all 285 selected registration/metadata/ownership/view/CLI/actual-stdio-MCP checks pass, plus check:fast, full format:check and docs:check. Twelve completed MCP query tasks preserve requested facts and artifact identities and validate SDK-converted schemas. Paging adds calls, CPU and memory; its whole-RPC estimate rises 0.59% for a small report and falls only 0.75% for a long-name report. These are payload token estimates, not billed tokens or measured model context. Exact pins, ranges, cold/warm scope, full-catalog costs and exclusions are in the verification report.

Real Unity verification remains contributor-reported on two private Android arm64 version-31 builds; this maintenance run did not reproduce the Il2CppDumper comparison, whose version was not recorded. Authored boundary fixtures do not establish real Unity dispatch, metadata-27/29 production behavior or a real Ghidra seed import. The original human-readiness declarations are preserved below.

Author readiness

Human owner: @8rulerstar

  • 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.

Thanks for taking a look.

…c names

Generic container indices and records are demand readers on the same metadata snapshot, so links that do not ask for generic instances allocate nothing. Type rendering keeps one graph walk with its workspace, depth and cycle guards; the C#-like names and the Il2CppDumper GetMethodSpecName names are two styles over it.
…pt issues

generic_instances links every genericMethodTable row through methodSpecs, genericInsts and genericMethodPointers, choosing the one CodeRegistration layout whose counts bound every row. The table is reserved against the report budget before any row is resolved; rows and issues are admitted before retention, and a contradicting row stays unknown with an address-backed issue instead of failing the link. Views page the rows by definition, state, address and name, unrequested and historical collections stay unknown, and Ghidra seeds fold instances after the definitions.
A method spec that contradicted the metadata still reported its pointer slot as code, while the schema and provider limitation promised unknown. Such rows now keep no address, every issue carries its genericMethodTable row, the domain validator requires unknown exactly on issued rows, and shared specs name one other row instead of all of them. The row-size lower bound moves to the metadata admission owner, the hex helper is shared, and budget wording says checked rather than reserved.
@8rulerstar
8rulerstar marked this pull request as ready for review October 21, 2026 05:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-21T05:34:56.387790Z
We couldn’t complete this review. Comment @codex review to try again.
a7d61de 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 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge based on the reviewed changes.

Summary

Adds opt-in generic method linking through generic_instances and CLI --generic-instances.

  • Generic method instances now link to named code addresses and report rows.
  • Ghidra seeds now include linked generic method names.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Metadata and native binary] --> B{Generic instances requested?}
  B -- No --> C[Keep new fields null]
  B -- Yes --> D[Choose one supported registration layout]
  D --> E[Read method specs and arguments]
  E --> F[Name each instance and read its code slot]
  F --> G[Code, no body, or unknown with an issue]
  G --> H[Complete Evidence and paged views]
  G --> I[Append linked instances to Ghidra seeds]
Loading

Reviews (5) · Last reviewed commit: "fix(il2cpp): report generic entries past..." · Reviewed by Greptile

Comment thread src/il2cpp/Il2cppBinaryGenerics.ts Resolved
Comment thread src/il2cpp/Il2cppBinaryTypes.ts Resolved
Comment thread docs/il2cpp-metadata.md Resolved
…d arguments

Layout selection no longer requires every genericMethodPointers slot to be
mapped; each row reads its own slot, so one unmapped slot leaves only that
row unknown with an issue. Method specs whose class or method argument count
differs from the owner's declared generic container are issued and unnamed.
Fixtures now declare the containers their generic rows fill.
…summaries

Summaries keep generic_methods without its issues and count them in
counts.generic_method_issues; the generic_method_issues collection pages
them by rows, indices and fields, as code_gen_modules already does. Docs
also name the method_indices filter the request schema accepts.
Comment thread src/il2cpp/Il2cppMetadataFile.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P1 Readable generic methods disappear src/il2cpp/Il2cppBinaryTypes.ts:171 ▶

    If an Il2CppGenericInst argument array crosses two loader mappings, instanceArguments rejects it even when each pointer is readable. isMapped(image, argv, count * 8) requires the whole array to fit in one mapping. The rendering failure then clears the instance name and marks its code unknown, so its address and Ghidra seed are lost.

    Check coverage across mappings, then read each pointer through the existing reader.

…ers on demand

Generic argument arrays may span adjacent loader ranges: admit them with
hasPointerArrayCoverage and read each slot through readPointer, instead of
requiring the whole array in one mapping.

Method generic container indices are read on demand from the method record,
like type containers, so no link path allocates a per-method column. An owner
whose container index is out of range now leaves the method spec unnamed with
an issue instead of naming it unchecked.
@8rulerstar

Copy link
Copy Markdown
Contributor Author

Thanks, this was right: instanceArguments required the whole Il2CppGenericInst argument array to sit in one mapping, so an array crossing two adjacent loader ranges failed the render and left the row unnamed and unknown. It now admits the array with hasPointerArrayCoverage, the shared owner the method pointer tables already use (chunks across loader ranges, refusing a gap or a split slot), and keeps reading each argument through readPointer. Confirmed with an authored image whose <Größe<int>, int> argument array is split between two adjacent segments: the previous reader left row 1 unknown with no name (62 passed / 1 failed), and now all three rows match the unsplit fixture with 0 issues (63/63). I also searched the branch diff for other whole-array isMapped checks and found none; the remaining isMapped array checks in Il2cppBinaryRegistration.ts predate this PR. Both real Android samples produce the same normalized result as before, 0 issues and 0/0 pair differences against Il2CppDumper. Would this be the right owner to reuse here?

Comment thread src/il2cpp/Il2cppBinaryGenerics.ts Resolved
A damaged methodSpecs or genericMethodPointers pointer could make a spec or
slot address exceed 64 bits. The issue kept that address, which the address
schema rejects, so inspection failed instead of leaving the row unknown.
Check the entry range first and attach the issue to the genericMethodTable
row (or its slot field).
8rulerstar and others added 3 commits October 24, 2026 14:38
…-instances

# Conflicts:
#	docs/il2cpp-metadata.md
#	src/cli/il2cppCommands.ts
#	src/contracts/analysisViewToolContracts.ts
#	src/il2cpp/Il2cppBinaryTypes.ts
#	tests/acceptance/il2cppMetadataCli.test.ts
#	tests/boundary/il2cpp/il2cppBinaryFile.test.ts
#	tests/boundary/il2cpp/il2cppMetadataProvider.test.ts
#	tests/fixtures/il2cpp/binary.ts
#	tests/fixtures/il2cpp/metadata.ts
The merge commit's lint-staged run rewrote these two main files: oxlint --fix
dropped the escape in [+\-], which is invalid under the RegExp v flag.
@8rulerstar

Copy link
Copy Markdown
Contributor Author

Heads-up: my merge of main here ran lint-staged, and oxlint --fix rewrote two files that belong to main (the [+\-] regex in adbDeviceAnalysis.ts, which breaks under the v flag, and a test fixture). 3dd803b restores both from main, so this PR's diff no longer touches them. I committed that restore with --no-verify because the hook re-applies the rewrite.

@gensokyo-dev

Copy link
Copy Markdown
Collaborator

Final head 8c4e43b4ca5af30891954593df36b3447ea2ac93 passes all current required CI and all eight shards, with no unresolved review threads. Both superseded metadata jobs had no runner/steps; same-head replacements pass. Existing human-owner readiness is preserved.

Local integration with merged IPS and both feature branches (53f13b8cb1d553387b297b1d485f689e22c8743d, tree 07519195b464890dbf771199817d9a3824d0a353) passes type/lint and runtime build. The 23-file selection has 672 passes and one existing Android retained-manifest MCP 30-second timeout; that unchanged three-case MCP file then passes separately without increasing its deadline. All 285 IL2CPP checks pass in the combined selection. Earlier authored-fixture actual SDK query costs and private contributor-only Unity limitations remain pinned and qualified in the report. Merging the validated IL2CPP head under normal check enforcement.

@gensokyo-dev
gensokyo-dev merged commit 3ce3117 into morluto:main Oct 24, 2026
40 of 42 checks passed
@morluto morluto mentioned this pull request Oct 25, 2026
3 tasks done
@8rulerstar
8rulerstar deleted the feat/il2cpp-generic-instances branch October 30, 2026 00:08
@morluto morluto added enhancement New feature or request provider: il2cpp Analysis provider / engine: il2cpp labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request provider: il2cpp Analysis provider / engine: il2cpp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants