BepInEx.IL2CPP: Remove old MonoExtensions

This commit is contained in:
ghorsington committed 2022-08-14 17:18:58 +03:00
1 parent b80f29784c
commit 7a54a77946
3 files changed
+3 -28

No files matched your search

+2 -5
View File
@@ -163,12 +163,9 @@ public class FastNativeDetour : IDetour
public static FastNativeDetour CreateAndApply<T>(IntPtr from,
T to,
out T original,
CallingConvention? callingConvention = null) where T : Delegate
out T original) where T : Delegate
{
var toPtr = callingConvention != null
? MonoExtensions.GetFunctionPointerForDelegate(to, callingConvention.Value)
: Marshal.GetFunctionPointerForDelegate(to);
var toPtr = Marshal.GetFunctionPointerForDelegate(to);
var result = new FastNativeDetour(from, toPtr);
original = result.GenerateTrampoline<T>();
result.Apply();
+1 -2
View File
@@ -77,8 +77,7 @@ public class IL2CPPChainloader : BaseChainloader<BasePlugin>
gameAssemblyModule.BaseAddress.TryGetFunction("il2cpp_runtime_invoke", out var runtimeInvokePtr);
PreloaderLogger.Log.Log(LogLevel.Debug, $"Runtime invoke pointer: 0x{runtimeInvokePtr.ToInt64():X}");
RuntimeInvokeDetour =
FastNativeDetour.CreateAndApply(runtimeInvokePtr, OnInvokeMethod, out originalInvoke,
CallingConvention.Cdecl);
FastNativeDetour.CreateAndApply(runtimeInvokePtr, OnInvokeMethod, out originalInvoke);
PreloaderLogger.Log.Log(LogLevel.Debug, "Runtime invoke patched");
}
-21
View File
@@ -1,21 +0,0 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace BepInEx;
/// <summary>
/// Contains unofficial extensions to the underlying Mono runtime.
/// </summary>
public static class MonoExtensions
{
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern IntPtr GetFunctionPointerForDelegateInternal2(Delegate d, CallingConvention conv);
public static IntPtr GetFunctionPointerForDelegate(Delegate d, CallingConvention conv)
{
if (d == null) throw new ArgumentNullException(nameof(d));
return GetFunctionPointerForDelegateInternal2(d, conv);
}
}