Skip to content

Raise metadata registration sanity limit for Unity 6 games - #604

Open
HHHEEEWWW wants to merge 1 commit into
SamboyCoding:developmentfrom
HHHEEEWWW:fix/unity6-metareg-sanity-limit
Open

Raise metadata registration sanity limit for Unity 6 games#604
HHHEEEWWW wants to merge 1 commit into
SamboyCoding:developmentfrom
HHHEEEWWW:fix/unity6-metareg-sanity-limit

Conversation

@HHHEEEWWW

Copy link
Copy Markdown

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 via typeDefinitionsSizesCount and numTypes, 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 0x70000 for Zenith) and keeps the safety check while accommodating larger modern games.

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