diff --git a/Il2CppInterop.HarmonySupport/Il2CppInterop.HarmonySupport.csproj b/Il2CppInterop.HarmonySupport/Il2CppInterop.HarmonySupport.csproj
index 6e8e09f1c..1c80e5421 100644
--- a/Il2CppInterop.HarmonySupport/Il2CppInterop.HarmonySupport.csproj
+++ b/Il2CppInterop.HarmonySupport/Il2CppInterop.HarmonySupport.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/Il2CppInterop.Runtime/Injection/DetourProvider.cs b/Il2CppInterop.Runtime/Injection/DetourProvider.cs
index 24ce64baa..7a1cf79b3 100644
--- a/Il2CppInterop.Runtime/Injection/DetourProvider.cs
+++ b/Il2CppInterop.Runtime/Injection/DetourProvider.cs
@@ -1,4 +1,5 @@
using System;
+using System.Runtime.InteropServices;
using Il2CppInterop.Runtime.Startup;
namespace Il2CppInterop.Runtime.Injection;
@@ -10,7 +11,6 @@ public interface IDetour : IDisposable
nint OriginalTrampoline { get; }
void Apply();
- T GenerateTrampoline() where T : Delegate;
}
public interface IDetourProvider
@@ -23,8 +23,8 @@ internal static class Detour
public static IDetour Apply(nint original, T target, out T trampoline) where T : Delegate
{
var detour = Il2CppInteropRuntime.Instance.DetourProvider.Create(original, target);
- trampoline = detour.GenerateTrampoline();
detour.Apply();
+ trampoline = Marshal.GetDelegateForFunctionPointer(detour.OriginalTrampoline);
return detour;
}
}