diff --git a/BepInEx.IL2CPP/BepInEx.IL2CPP.csproj b/BepInEx.IL2CPP/BepInEx.IL2CPP.csproj index 596c356..95da5de 100644 --- a/BepInEx.IL2CPP/BepInEx.IL2CPP.csproj +++ b/BepInEx.IL2CPP/BepInEx.IL2CPP.csproj @@ -26,9 +26,9 @@ - + - + diff --git a/BepInEx.IL2CPP/Hook/FastNativeDetour.cs b/BepInEx.IL2CPP/Hook/FastNativeDetour.cs index b2ba35b..5848207 100644 --- a/BepInEx.IL2CPP/Hook/FastNativeDetour.cs +++ b/BepInEx.IL2CPP/Hook/FastNativeDetour.cs @@ -4,7 +4,6 @@ using System.Runtime.InteropServices; using BepInEx.IL2CPP.Hook.Allocator; using BepInEx.Logging; using MonoMod.RuntimeDetour; -using MonoMod.Utils; namespace BepInEx.IL2CPP.Hook; @@ -80,7 +79,9 @@ public class FastNativeDetour : IDetour if (!typeof(Delegate).IsAssignableFrom(typeof(T))) throw new InvalidOperationException($"Type {typeof(T)} not a delegate type."); - return GenerateTrampoline(typeof(T).GetMethod("Invoke")).CreateDelegate(typeof(T)) as T; + _ = GenerateTrampoline(typeof(T).GetMethod("Invoke")); + + return Marshal.GetDelegateForFunctionPointer(TrampolinePtr); } public void Dispose()