Skip to content

feat: support optional IL2CPP symbols for Unity 6+#9

Open
jhq223 wants to merge 1 commit into
Batchhh:mainfrom
jhq223:feat/optional-symbols
Open

feat: support optional IL2CPP symbols for Unity 6+#9
jhq223 wants to merge 1 commit into
Batchhh:mainfrom
jhq223:feat/optional-symbols

Conversation

@jhq223

@jhq223 jhq223 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Unity 6 dropped three exported symbols from libil2cpp.so:

  • il2cpp_thread_get_all_attached_threads
  • il2cpp_class_get_bitmap_size
  • il2cpp_class_get_bitmap

The 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 to optional. When an optional symbol is missing, its wrapper logs a warning and returns Default::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.

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