Browse Source

Format code

ghorsington 3 years ago
parent
commit
3092ae08ae

+ 6 - 8
BepInEx.IL2CPP/Hook/Allocator/LinuxPageAllocator.cs

@@ -24,23 +24,21 @@ namespace BepInEx.IL2CPP.Allocator
 			}
 		}
 
-		static class Unix
+		private static class Unix
 		{
-			public delegate IntPtr mmapDelegate(IntPtr addr, UIntPtr length, int prot, int flags, int fd, int offset);
-
 			[DynDllImport("mmap")]
 			public static mmapDelegate mmap;
 
-			public delegate int munmapDelegate(IntPtr addr, UIntPtr length);
-
 			[DynDllImport("munmap")]
 			public static munmapDelegate munmap;
 
-			public delegate IntPtr fdopenDelegate(int fd, string mode);
-
 			[DynDllImport("libc")]
 			public static fdopenDelegate fdopen;
 
+			public delegate IntPtr fdopenDelegate(int fd, string mode);
+			public delegate IntPtr mmapDelegate(IntPtr addr, UIntPtr length, int prot, int flags, int fd, int offset);
+			public delegate int munmapDelegate(IntPtr addr, UIntPtr length);
+
 			static Unix()
 			{
 				typeof(Unix).ResolveDynDllImports(new Dictionary<string, List<DynDllMapping>>
@@ -48,7 +46,7 @@ namespace BepInEx.IL2CPP.Allocator
 					["libc"] = new List<DynDllMapping>
 					{
 						"libc.so.6", // Ubuntu glibc
-						"libc",      // Linux glibc
+						"libc"       // Linux glibc
 					}
 				});
 			}

+ 1 - 1
BepInEx.IL2CPP/Hook/Allocator/MacOsPageAllocator.cs

@@ -6,7 +6,7 @@ namespace BepInEx.IL2CPP.Allocator
 	{
 		protected override IMemoryMapper OpenMemoryMap()
 		{
-			throw new System.NotImplementedException();
+			throw new NotImplementedException();
 		}
 
 		protected class MacOsMemoryMapper : IMemoryMapper

+ 10 - 5
BepInEx.IL2CPP/Hook/Allocator/PageAllocator.cs

@@ -32,6 +32,8 @@ namespace BepInEx.IL2CPP.Allocator
 
 		private static PageAllocator instance;
 
+		private readonly List<PageChunk> allocatedChunks = new List<PageChunk>();
+
 		/// <summary>
 		///     Platform-specific instance of page allocator.
 		/// </summary>
@@ -116,14 +118,16 @@ namespace BepInEx.IL2CPP.Allocator
 			return int.MinValue <= diff && diff <= int.MaxValue;
 		}
 
-		private static PageAllocator Init() =>
-			PlatformHelper.Current switch
+		private static PageAllocator Init()
+		{
+			return PlatformHelper.Current switch
 			{
 				var v when v.Is(Platform.Windows) => new WindowsPageAllocator(),
 				var v when v.Is(Platform.Linux)   => new LinuxPageAllocator(),
 				var v when v.Is(Platform.MacOS)   => new MacOsPageAllocator(),
 				_                                 => throw new NotImplementedException()
 			};
+		}
 
 		private class PageChunk
 		{
@@ -136,12 +140,13 @@ namespace BepInEx.IL2CPP.Allocator
 				return BaseAddress + index * PAGE_SIZE;
 			}
 		}
-
-		private readonly List<PageChunk> allocatedChunks = new List<PageChunk>();
 	}
 
 	internal static class PlatformExt
 	{
-		public static bool Is(this Platform pl, Platform val) => (pl & val) == val;
+		public static bool Is(this Platform pl, Platform val)
+		{
+			return (pl & val) == val;
+		}
 	}
 }

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

@@ -1,5 +1,4 @@
 using System;
-using System.Collections.Generic;
 using System.ComponentModel;
 using System.Runtime.InteropServices;