feat: support optional IL2CPP symbols for Unity 6+#9
Open
jhq223 wants to merge 1 commit into
Open
Conversation
Unity 6 (libil2cpp.so) no longer exports three symbols:
- il2cpp_thread_get_all_attached_threads
- il2cpp_class_get_bitmap_size
- il2cpp_class_get_bitmap
Previously, any missing symbol caused load() to fail entirely, making
the library unusable on Unity 6 games.
Refactor define_il2cpp_functions! macro to accept two groups:
required {} — must all resolve or load() returns Err
optional {} — missing symbols are stored as None
Optional symbol wrappers log a warning and return Default::default()
when the symbol is not loaded, allowing graceful degradation.
This is fully backward compatible: older Unity versions load all
symbols as before (required ones required, optional ones now optional
but present).
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.
Unity 6 dropped three exported symbols from libil2cpp.so:
il2cpp_thread_get_all_attached_threadsil2cpp_class_get_bitmap_sizeil2cpp_class_get_bitmapThe current code treats every symbol as mandatory — one missing export and
load()fails, so the whole library is dead on Unity 6.This PR splits the macro into
required {}/optional {}groups. The three symbols above move tooptional. When an optional symbol is missing, its wrapper logs a warning and returnsDefault::default()instead of crashing.Old Unity still loads everything as before — the symbols are still there, just no longer fatal if absent.
Verified on device with FGO (Unity 6): library loads, optional symbols degrade gracefully, all hooks work.