Explorar o código

Implement initial MonoExtensions class

Bepis %!s(int64=4) %!d(string=hai) anos
pai
achega
59237ec739
Modificáronse 2 ficheiros con 25 adicións e 0 borrados
  1. 1 0
      BepInEx.IL2CPP/BepInEx.IL2CPP.csproj
  2. 24 0
      BepInEx.IL2CPP/MonoExtensions.cs

+ 1 - 0
BepInEx.IL2CPP/BepInEx.IL2CPP.csproj

@@ -81,6 +81,7 @@
     <Compile Include="EnvVars.cs" />
     <Compile Include="Hook\FastNativeDetour.cs" />
     <Compile Include="IL2CPPChainloader.cs" />
+    <Compile Include="MonoExtensions.cs" />
     <Compile Include="Preloader.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Hook\DetourGenerator.cs" />

+ 24 - 0
BepInEx.IL2CPP/MonoExtensions.cs

@@ -0,0 +1,24 @@
+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("d");
+			}
+			return GetFunctionPointerForDelegateInternal2(d, conv);
+		}
+	}
+}