From 252e628a71e9f817288b10bc68e24316d81d7917 Mon Sep 17 00:00:00 2001 From: Boring <1079299053@qq.com> Date: Wed, 3 Jul 2024 12:49:50 +0800 Subject: [PATCH] base relocation --- MemoryModule/MemoryModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MemoryModule/MemoryModule.cpp b/MemoryModule/MemoryModule.cpp index 18db5a1f..34573acf 100644 --- a/MemoryModule/MemoryModule.cpp +++ b/MemoryModule/MemoryModule.cpp @@ -285,7 +285,7 @@ NTSTATUS MemoryLoadLibrary( PIMAGE_BASE_RELOCATION_HEADER relocation = (PIMAGE_BASE_RELOCATION_HEADER)(LPBYTE(base) + dir->VirtualAddress); if (dir->Size && dir->VirtualAddress) { - while (relocation->VirtualAddress > 0) { + while ((LPBYTE(relocation) < LPBYTE(base) + dir->VirtualAddress + dir->Size) && relocation->VirtualAddress > 0) { auto relInfo = (_REBASE_INFO*)&relocation->TypeOffset; for (DWORD i = 0; i < relocation->TypeOffsetCount(); ++i, ++relInfo) { switch (relInfo->Type) {