Skip to content

Fix bug on macOS#272

Closed
sptndc wants to merge 767 commits into
BepInEx:masterfrom
sptndc:patch-1
Closed

Fix bug on macOS#272
sptndc wants to merge 767 commits into
BepInEx:masterfrom
sptndc:patch-1

Conversation

@sptndc

@sptndc sptndc commented Jun 21, 2026

Copy link
Copy Markdown

Problem

XrefScans.XrefScanMethodDb and InjectorHelpers.Il2CppModule use Process.Modules and ProcessModule which are very limited or return incomplete data on macOS.

Furthermore, InjectorHelpers.Il2CppHandle uses NativeLibrary.Load like this:

NativeLibrary.Load("GameAssembly", typeof(InjectorHelpers).Assembly, null);

The .NET runtime automatically prefixes lib and will throw a DllNotFoundException.

Change

  • Use the native C functions dlopen, dlsym, and dladdr using C# P/Invoke for macOS to get the actual base address and calculate the memory size of a module. Replace the MemoryUtils.FindSignatureInModule method with the MemoryUtils.FindSignatureInBlock method, which takes three parameters: nint, long, and SignatureDefinition.
  • Provide the full file path to NativeLibrary.Load, so the .NET runtime will interpret it exactly as it is and skip the prefixing logic.

ghorsington and others added 30 commits May 23, 2022 22:23
# Conflicts:
#	Il2CppInterop.Runtime/Injection/InjectorHelpers.cs
Using 6.0.0.0 is wrong because it is not a valid mscorlib version. In .NET 5 an higher, mscorlib version is locked to 4.0.0.0
# Conflicts:
#	Directory.Build.props
#	Il2CppInterop.Runtime/Injection/InjectorHelpers.cs
#	UnhollowerBaseLib/Il2CppException.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/Class/Class_24_4.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/Class/Class_27_0.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/Class/Class_27_1.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/Class/Class_27_2.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/Class/Class_27_3.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/Class/Class_29_0.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/Class/Class_29_1.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/Image/Image_27_0.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/ParameterInfo/ParameterInfo_16_0.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/ParameterInfo/ParameterInfo_24_1.cs
#	UnhollowerBaseLib/Runtime/VersionSpecific/ParameterInfo/ParameterInfo_27_3.cs
Major refactor, rename project to Il2CppInterop
ManlyMarco and others added 21 commits September 2, 2025 08:58
* implement IL Hook in Il2CppDetourMethodPatcher to skip managed->native->managed

* update to use detour instead of il hook
…od. (BepInEx#233)

* Added better support for nested classes in GetIl2CppTypeFullName method.

* Switched from a list to a stack.  No more need to reverse the list.

* Only add a . when namespacename exists.

---------

Co-authored-by: SlideDrum <slidedrumofficial@gmail.com>
Il2CppInterop and Il2CppAssemblyUnhollower have always been LGPLv3, simply using the split GPL+LGPL license files. Use the combined license text to avoid confusion.
* Separated Il2CppInterop.Generator

* Fix formatting issues

---------

Co-authored-by: cetotos <cetotospatatos@gmail.com>
…pInEx#255)

* Separated Il2CppInterop.Runtime

* Update Il2CppInterop.Runtime/Injection/Hooks/GenericMethod_GetMethod_Unity6_Hook.cs

remove comments

Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com>

* Update Il2CppInterop.Runtime/Injection/InjectorHelpers.cs

change unity 6 hook name

Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com>

* Update Il2CppInterop.Runtime/Injection/InjectorHelpers.cs

change unity 6 hook name

Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com>

* Revise comment

Honestly, I don't remember removing it anyways

---------

Co-authored-by: cetotos <cetotospatatos@gmail.com>
Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com>
* Unity 6 alignment issue fix for linux

* Fix the Dotnet Formatting issues

* fixup: forgot to add trace log line
* fix: preserve Nullable<T> data in Harmony patches

* style: narrow Nullable check and normalize CopyMemory signature per review
…x#237)"

This reverts commit 350df19.

The patch breaks the managed method body when CopyOriginal called on
detoured Original method body, as CopyOriginal expect to operate on
unmodified Original method body.

This essentially breaks applying more than one Harmony patches on a same
hooking target.
…ltValue-signature', 'fix-HarmonySupport-ref-valuetype' and 'revert-implement-managed-detour' into illgames-fixes
Various fixes for issues with some Illgames games

Co-authored-by: y0soro <y0soro@protonmail.com>
This fixes an issue where `GameAssembly.dylib` was
not loaded for IL2CPP games on macOS.
Comment thread Il2CppInterop.Common/XrefScans/XrefScanMethodDb.cs Outdated
Comment thread Il2CppInterop.Runtime/Injection/InjectorHelpers.cs Outdated
Comment thread Il2CppInterop.Runtime/Injection/InjectorHelpers.cs Outdated
Comment thread Il2CppInterop.Runtime/Injection/InjectorHelpers.cs
@ds5678

ds5678 commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Process.Modules and ProcessModule which are very limited or return incomplete data on macOS.

Is this true on .NET 10?

@sptndc

sptndc commented Jun 21, 2026

Copy link
Copy Markdown
Author

Process.Modules and ProcessModule which are very limited or return incomplete data on macOS.

Is this true on .NET 10?

These APIs are architected around Windows-specific memory models. While .NET 10 offers robust macOS support, the operating system's strict user-space security policies—specifically Hardened Runtime and System Integrity Protection (SIP)—prohibit arbitrary process memory traversal for module enumeration.

@sptndc sptndc closed this Jun 24, 2026
@sptndc sptndc deleted the patch-1 branch June 24, 2026 13:50
@sptndc sptndc restored the patch-1 branch June 24, 2026 14:46
@sptndc sptndc mentioned this pull request Jun 24, 2026
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.