Raise metadata registration sanity limit for Unity 6 games - #604
Open
HHHEEEWWW wants to merge 1 commit into
Open
Raise metadata registration sanity limit for Unity 6 games#604HHHEEEWWW wants to merge 1 commit into
HHHEEEWWW wants to merge 1 commit into
Conversation
Unity 6 (6000.x) games can have metadata registration count fields above the old 0xC0000 sanity limit (e.g. Pax Autocratica after its 2026-08 update had ~0xD04C4). Candidates were rejected, so LibCpp2IL failed with 'Failed to find code registration or metadata registration!' and BepInEx could not generate interop assemblies. Subsequent validation (typeDefinitionsSizesCount / numTypes vs the metadata file) still checks candidates, so the limit only acts as a coarse filter. Raise it to 0x400000 to cover larger games.
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.
Problem
Unity 6 (6000.x) games can have metadata registration count fields above the hardcoded sanity limit of
0xC0000(786,432). When that happens, real registrations get rejected and LibCpp2IL fails with:LibCpp2ILInitializationException: Fatal Exception initializing LibCpp2IL! ---> System.Exception: Failed to find code registration or metadata registration!Repro: Pax Autocratica after its 2026-08-15 update (Unity 6000.0.37f1). Cpp2IL verbose output:
Found 2 potential metadata registrations: [18E905CA0, 18E905CB0] Rejected Metadata registration at 0x18E905CA0, because it has a count field 0xCFE2E at offset 0 which is above sanity limit of 0xC0000. Rejected Metadata registration at 0x18E905CB0, because it has a count field 0xD04C4 at offset 8 which is above sanity limit of 0xC0000.This breaks BepInEx interop generation for affected games (
Failed to generate Il2Cpp interop assemblies).Fix
Raise the sanity limit to
0x400000(4,194,304). Subsequent validation still applies: candidates are checked against the metadata file viatypeDefinitionsSizesCountandnumTypes, so this value only acts as a coarse pre-filter — it cannot accept a bogus registration.This mirrors the 2022 precedent (commit history: limit was previously raised to
0x70000for Zenith) and keeps the safety check while accommodating larger modern games.