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