Skip to content

Commit 5ff56c2

Browse files
committed
WindowsPageAllocator: don't throw on invalid address resolving
1 parent eaf38ef commit 5ff56c2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

BepInEx.IL2CPP/Hook/Allocator/WindowsPageAllocator.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.ComponentModel;
33
using System.Runtime.CompilerServices;
44
using System.Runtime.InteropServices;
5+
using BepInEx.Logging;
56

67
namespace BepInEx.IL2CPP.Hook.Allocator;
78

@@ -26,7 +27,11 @@ protected override nint AllocateChunk(nint hint)
2627
{
2728
var mbi = new WinApi.MEMORY_BASIC_INFORMATION();
2829
if (WinApi.VirtualQuery(hint, ref mbi, Marshal.SizeOf<WinApi.MEMORY_BASIC_INFORMATION>()) == 0)
29-
throw Win32Error($"Failed to query memory information of 0x{(long) hint:X9}");
30+
{
31+
Logger.Log(LogLevel.Debug,
32+
$"Skipping analysing 0x{(long) hint:X8} because VirtualQuery failed: {Win32Error()}");
33+
goto next;
34+
}
3035

3136
if (mbi.State == WinApi.PageState.MEM_FREE)
3237
{
@@ -39,6 +44,7 @@ protected override nint AllocateChunk(nint hint)
3944
}
4045
}
4146

47+
next:
4248
hint = mbi.BaseAddress + mbi.RegionSize;
4349
}
4450

0 commit comments

Comments
 (0)