فهرست منبع

Implement initial MonoExtensions class

Bepis 4 سال پیش
والد
کامیت
59237ec739
2فایلهای تغییر یافته به همراه25 افزوده شده و 0 حذف شده
  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);
+		}
+	}
+}