Parcourir la source

Implement initial MonoExtensions class

Bepis il y a 3 ans
Parent
commit
59237ec739
2 fichiers modifiés avec 25 ajouts et 0 suppressions
  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);
+		}
+	}
+}