Pārlūkot izejas kodu

Add initial MemoryBuffer API

ghorsington 4 gadi atpakaļ
vecāks
revīzija
33d488f3f4

+ 23 - 0
BepInEx.IL2CPP/Hook/Buffer/MemoryBuffer.cs

@@ -0,0 +1,23 @@
+using System;
+using MonoMod.Utils;
+
+namespace BepInEx.IL2CPP
+{
+	public abstract class MemoryBuffer
+	{
+		public abstract IntPtr Allocate(IntPtr func);
+		public abstract void Free(IntPtr buffer);
+
+		private static MemoryBuffer instance;
+		public static MemoryBuffer Instance => instance ??= Init();
+
+		private static MemoryBuffer Init()
+		{
+			if (PlatformHelper.Is(Platform.Windows))
+				return new WindowsMemoryBuffer();
+			if (PlatformHelper.Is(Platform.Unix))
+				return new UnixMemoryBuffer();
+			throw new NotImplementedException();
+		} 
+	}
+}

+ 17 - 0
BepInEx.IL2CPP/Hook/Buffer/UnixMemoryBuffer.cs

@@ -0,0 +1,17 @@
+using System;
+
+namespace BepInEx.IL2CPP
+{
+	public class UnixMemoryBuffer : MemoryBuffer
+	{
+		public override IntPtr Allocate(IntPtr func)
+		{
+			throw new NotImplementedException();
+		}
+
+		public override void Free(IntPtr buffer)
+		{
+			throw new NotImplementedException();
+		}
+	}
+}

+ 17 - 0
BepInEx.IL2CPP/Hook/Buffer/WindowsMemoryBuffer.cs

@@ -0,0 +1,17 @@
+using System;
+
+namespace BepInEx.IL2CPP
+{
+	public class WindowsMemoryBuffer : MemoryBuffer
+	{
+		public override IntPtr Allocate(IntPtr func)
+		{
+			throw new NotImplementedException();
+		}
+
+		public override void Free(IntPtr buffer)
+		{
+			throw new NotImplementedException();
+		}
+	}
+}