diff --git a/BepInEx.Core/Bootstrap/BaseChainloader.cs b/BepInEx.Core/Bootstrap/BaseChainloader.cs index 5dc78f315..e4dce14a6 100644 --- a/BepInEx.Core/Bootstrap/BaseChainloader.cs +++ b/BepInEx.Core/Bootstrap/BaseChainloader.cs @@ -486,10 +486,11 @@ private static bool IsAssemblySafe(string assemblyPath) return false; } - if (module.Attributes.Has(ModuleAttributes.ILOnly) == false) + // TODO: better unsafe blocking + /*if (!module.Attributes.Has(ModuleAttributes.ILOnly)) { return false; - } + }*/ if (!method.HasBody) continue; diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/BepInEx.Unity.IL2CPP.csproj b/Runtimes/Unity/BepInEx.Unity.IL2CPP/BepInEx.Unity.IL2CPP.csproj index 01db07fef..8cae8291b 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/BepInEx.Unity.IL2CPP.csproj +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/BepInEx.Unity.IL2CPP.csproj @@ -17,10 +17,10 @@ - - + + - + diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Hook/NativeDetour.cs b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Hook/NativeDetour.cs index b8f8cd04e..bedf68e74 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Hook/NativeDetour.cs +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Hook/NativeDetour.cs @@ -9,18 +9,20 @@ public unsafe class NativeDetour : IDetour public IntPtr Target { get; } public IntPtr Detour { get; } public bool UnityFunction { get; } + public bool SpecialReturnBuffer { get; } public IntPtr OriginalTrampoline { get; private set; } public NativeDetour(IntPtr target, Delegate detour) - : this(target, detour, false) + : this(target, detour, false, false) { } - public NativeDetour(IntPtr target, Delegate detour, bool unityFunction) + public NativeDetour(IntPtr target, Delegate detour, bool unityFunction, bool specialReturnBuffer) { Target = target; Detour = Marshal.GetFunctionPointerForDelegate(detour); UnityFunction = unityFunction; + SpecialReturnBuffer = specialReturnBuffer; Apply(); } @@ -30,7 +32,7 @@ public void Apply() { return; } - OriginalTrampoline = StarlightInterop.hook(Target, Detour, UnityFunction); + OriginalTrampoline = StarlightInterop.hook(Target, Detour, UnityFunction, SpecialReturnBuffer); } public void Dispose() diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Hook/NativeDetourProvider.cs b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Hook/NativeDetourProvider.cs index 7e12bf9c1..637ff24a9 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Hook/NativeDetourProvider.cs +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Hook/NativeDetourProvider.cs @@ -5,9 +5,9 @@ namespace BepInEx.Unity.IL2CPP.Hook; public class NativeDetourProvider : IDetourProvider { - public IDetour Create(IntPtr original, TDelegate target, bool unityFunction) where TDelegate : Delegate + public IDetour Create(IntPtr original, TDelegate target, bool unityFunction, bool specialReturnBuffer) where TDelegate : Delegate { - var detour = new NativeDetour(original, target, unityFunction); + var detour = new NativeDetour(original, target, unityFunction, specialReturnBuffer); return new CacheDetourWrapper(detour, target); } } diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/IL2CPPChainloader.cs b/Runtimes/Unity/BepInEx.Unity.IL2CPP/IL2CPPChainloader.cs index 365856968..d5ee2738c 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/IL2CPPChainloader.cs +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/IL2CPPChainloader.cs @@ -11,6 +11,7 @@ using BepInEx.Unity.IL2CPP.Hook; using BepInEx.Unity.IL2CPP.Logging; using BepInEx.Unity.IL2CPP.Utils; +using Il2CppInterop.HarmonySupport; using Il2CppInterop.Runtime.InteropTypes; using Logger = BepInEx.Logging.Logger; @@ -76,6 +77,8 @@ public override void Execute() { try { + BridgeInterop.Initialize(); + StarlightInterop.init_bridge_helper(BridgeInterop.LibraryPath); StarlightInterop.set_loading(true); var paths = new Dictionary diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/StarlightInterop.cs b/Runtimes/Unity/BepInEx.Unity.IL2CPP/StarlightInterop.cs index 5d99bdcbb..5d821ced8 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/StarlightInterop.cs +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/StarlightInterop.cs @@ -13,7 +13,12 @@ internal static partial class StarlightInterop public static unsafe partial void write_log([MarshalAs(UnmanagedType.LPStr)] string message); [LibraryImport(LIBRARY_NAME)] - public static unsafe partial IntPtr hook(IntPtr target, IntPtr detour, [MarshalAs(UnmanagedType.I1)] bool unityFunction); + public static unsafe partial void init_bridge_helper([MarshalAs(UnmanagedType.LPStr)] string bridgeLibPath); + + [LibraryImport(LIBRARY_NAME)] + public static unsafe partial IntPtr hook(IntPtr target, IntPtr detour, + [MarshalAs(UnmanagedType.I1)] bool unityFunction, + [MarshalAs(UnmanagedType.I1)] bool specialReturnBuffer); [LibraryImport(LIBRARY_NAME)] public static unsafe partial void unhook(IntPtr target); diff --git a/packages/Il2CppInterop.CLI.1.5.2-data-hook.nupkg b/packages/Il2CppInterop.CLI.1.5.2-ci.star.5.nupkg similarity index 98% rename from packages/Il2CppInterop.CLI.1.5.2-data-hook.nupkg rename to packages/Il2CppInterop.CLI.1.5.2-ci.star.5.nupkg index 27af259b5..b9631d70a 100644 Binary files a/packages/Il2CppInterop.CLI.1.5.2-data-hook.nupkg and b/packages/Il2CppInterop.CLI.1.5.2-ci.star.5.nupkg differ diff --git a/packages/Il2CppInterop.Common.1.5.2-ci.star.5.nupkg b/packages/Il2CppInterop.Common.1.5.2-ci.star.5.nupkg new file mode 100644 index 000000000..a032c5d7c Binary files /dev/null and b/packages/Il2CppInterop.Common.1.5.2-ci.star.5.nupkg differ diff --git a/packages/Il2CppInterop.Common.1.5.2-data-hook.nupkg b/packages/Il2CppInterop.Common.1.5.2-data-hook.nupkg deleted file mode 100644 index 16647dc52..000000000 Binary files a/packages/Il2CppInterop.Common.1.5.2-data-hook.nupkg and /dev/null differ diff --git a/packages/Il2CppInterop.Generator.1.5.2-ci.star.5.nupkg b/packages/Il2CppInterop.Generator.1.5.2-ci.star.5.nupkg new file mode 100644 index 000000000..9c6c03759 Binary files /dev/null and b/packages/Il2CppInterop.Generator.1.5.2-ci.star.5.nupkg differ diff --git a/packages/Il2CppInterop.Generator.1.5.2-data-hook.nupkg b/packages/Il2CppInterop.Generator.1.5.2-data-hook.nupkg deleted file mode 100644 index 268bf624d..000000000 Binary files a/packages/Il2CppInterop.Generator.1.5.2-data-hook.nupkg and /dev/null differ diff --git a/packages/Il2CppInterop.HarmonySupport.1.5.2-ci.star.5.nupkg b/packages/Il2CppInterop.HarmonySupport.1.5.2-ci.star.5.nupkg new file mode 100644 index 000000000..75425e463 Binary files /dev/null and b/packages/Il2CppInterop.HarmonySupport.1.5.2-ci.star.5.nupkg differ diff --git a/packages/Il2CppInterop.HarmonySupport.1.5.2-data-hook.nupkg b/packages/Il2CppInterop.HarmonySupport.1.5.2-data-hook.nupkg deleted file mode 100644 index 2062db9d2..000000000 Binary files a/packages/Il2CppInterop.HarmonySupport.1.5.2-data-hook.nupkg and /dev/null differ diff --git a/packages/Il2CppInterop.Runtime.1.5.2-ci.star.5.nupkg b/packages/Il2CppInterop.Runtime.1.5.2-ci.star.5.nupkg new file mode 100644 index 000000000..7eb32e3e1 Binary files /dev/null and b/packages/Il2CppInterop.Runtime.1.5.2-ci.star.5.nupkg differ diff --git a/packages/Il2CppInterop.Runtime.1.5.2-data-hook.nupkg b/packages/Il2CppInterop.Runtime.1.5.2-data-hook.nupkg deleted file mode 100644 index a20d5536c..000000000 Binary files a/packages/Il2CppInterop.Runtime.1.5.2-data-hook.nupkg and /dev/null differ diff --git a/packages/MonoMod.Core.1.3.4-star.nupkg b/packages/MonoMod.Core.1.3.4-star.nupkg new file mode 100644 index 000000000..18ec7e1ab Binary files /dev/null and b/packages/MonoMod.Core.1.3.4-star.nupkg differ diff --git a/packages/MonoMod.RuntimeDetour.25.3.4-star.nupkg b/packages/MonoMod.RuntimeDetour.25.3.4-star.nupkg new file mode 100644 index 000000000..ac46c5e18 Binary files /dev/null and b/packages/MonoMod.RuntimeDetour.25.3.4-star.nupkg differ diff --git a/packages/MonoMod.Utils.25.0.12-star.nupkg b/packages/MonoMod.Utils.25.0.12-star.nupkg new file mode 100644 index 000000000..d9c002d15 Binary files /dev/null and b/packages/MonoMod.Utils.25.0.12-star.nupkg differ