mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
BepInEx.IL2CPP: Remove old MonoExtensions
This commit is contained in:
1 parent
b80f29784c
commit
7a54a77946
3 files changed
+3
-28
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user