Skip to content

Injection: resolve Class::Init via il2cpp API xref fallback - #286

Open
XLG-WSM wants to merge 1 commit into
BepInEx:masterfrom
XLG-WSM:classinit-xref-fallback
Open

XLG-WSM wants to merge 1 commit into
BepInEx:masterfrom
XLG-WSM:classinit-xref-fallback

Conversation

@XLG-WSM

@XLG-WSM XLG-WSM commented Sep 5, 2026

Copy link
Copy Markdown

On GameAssembly built with Unity 6000.5.x the two byte signatures in s_ClassInitSignatures no longer match, so FindClassInit() silently falls back to the il2cpp_class_has_references substitute which cannot initialize injected classes, and every RegisterTypeInIl2Cpp call dies with an NRE.

Fallback: il2cpp_class_instance_size, il2cpp_class_value_size and il2cpp_class_num_fields each start with a near call to Class::Init per the il2cpp sources. Take the first E8 call target in each export, reject targets outside the module image, and require a majority vote between exports. Verified on Unity 6000.5.10f1 (Esports Manager 2026): two exports vote for the same target, injected types initialize, and the old substitute is no longer used.

On GameAssembly built with Unity 6000.5.x the two byte signatures in
s_ClassInitSignatures no longer match, so FindClassInit() silently falls
back to the il2cpp_class_has_references substitute — which cannot
initialize injected classes, and every RegisterTypeInIl2Cpp call dies
with an NRE.

Fallback: il2cpp_class_instance_size, il2cpp_class_value_size and
il2cpp_class_num_fields each start with a near call to Class::Init per
the il2cpp sources. Take the first E8 call target in each export,
reject targets outside the module image, and require a majority vote
between exports. Verified on Unity 6000.5.10f1 (Esports Manager 2026):
two exports vote for the same target, injected types initialize, and
the old substitute is no longer used.
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