Browse Source

Clean up code

ghorsington 3 years ago
parent
commit
52482590f1

+ 0 - 1
BepInEx.IL2CPP/Hook/Allocator/LinuxPageAllocator.cs

@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using System.Globalization;
 using System.IO;
-using MonoMod.Utils;
 
 namespace BepInEx.IL2CPP.Allocator
 {

+ 22 - 19
BepInEx.IL2CPP/Hook/Allocator/MacOsPageAllocator.cs

@@ -23,33 +23,18 @@ namespace BepInEx.IL2CPP.Allocator
 				yield return (start, end);
 			}
 		}
-		
+
 		private static class LibSystem
 		{
-			public static readonly IntPtr TaskSelf;
 			public const int VM_REGION_BASIC_INFO_64 = 9;
 			public const int KERN_SUCCESS = 0;
+			public static readonly IntPtr TaskSelf;
 
-			[StructLayout(LayoutKind.Sequential)]
-			public struct vm_region_basic_info_64
-			{
-				public int protection;
-				public int max_protection;
-				public uint inheritance;
-				[MarshalAs(UnmanagedType.I4)]
-				public bool shared;
-				[MarshalAs(UnmanagedType.I4)]
-				public bool reserved;
-				public ulong offset;
-				public int behavior;
-				public ushort user_wired_count;
-			}
+			[DynDllImport("libSystem")]
+			public static vm_region_64Delegate vm_region_64;
 
 			public delegate int vm_region_64Delegate(IntPtr target_task, ref IntPtr address, ref IntPtr size, int flavor, ref vm_region_basic_info_64 info, ref uint infoCnt, ref uint object_name);
 
-			[DynDllImport("libSystem")]
-			public static vm_region_64Delegate vm_region_64;
-			
 			static LibSystem()
 			{
 				typeof(LibSystem).ResolveDynDllImports(new Dictionary<string, List<DynDllMapping>>
@@ -63,6 +48,24 @@ namespace BepInEx.IL2CPP.Allocator
 				var libsystem = DynDll.OpenLibrary("/usr/lib/libSystem.dylib");
 				TaskSelf = libsystem.GetFunction("mach_task_self_"); // This isn't a function but rather an exported symbol
 			}
+
+			[StructLayout(LayoutKind.Sequential)]
+			public struct vm_region_basic_info_64
+			{
+				public readonly int protection;
+				public readonly int max_protection;
+				public readonly uint inheritance;
+
+				[MarshalAs(UnmanagedType.I4)]
+				public readonly bool shared;
+
+				[MarshalAs(UnmanagedType.I4)]
+				public readonly bool reserved;
+
+				public readonly ulong offset;
+				public readonly int behavior;
+				public readonly ushort user_wired_count;
+			}
 		}
 	}
 }