From dabd353bbeac1db15199d75b7712c49940e544e0 Mon Sep 17 00:00:00 2001 From: username <1557729811@qq.com> Date: Wed, 3 Jan 2024 22:40:10 +0800 Subject: [PATCH] fix a bug in PerformBaseRelocation --- MemoryModule.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MemoryModule.c b/MemoryModule.c index 9f95a70..b4c2a0c 100644 --- a/MemoryModule.c +++ b/MemoryModule.c @@ -382,6 +382,7 @@ static BOOL PerformBaseRelocation(PMEMORYMODULE module, ptrdiff_t delta) { unsigned char *codeBase = module->codeBase; + DWORD relocation_size; PIMAGE_BASE_RELOCATION relocation; PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_BASERELOC); @@ -389,11 +390,16 @@ PerformBaseRelocation(PMEMORYMODULE module, ptrdiff_t delta) return (delta == 0); } + relocation_size = directory->Size; relocation = (PIMAGE_BASE_RELOCATION) (codeBase + directory->VirtualAddress); - for (; relocation->VirtualAddress > 0; ) { + + for (;relocation_size; ) { DWORD i; unsigned char *dest = codeBase + relocation->VirtualAddress; unsigned short *relInfo = (unsigned short*) OffsetPointer(relocation, IMAGE_SIZEOF_BASE_RELOCATION); + + relocation_size -= relocation->SizeOfBlock; + for (i=0; i<((relocation->SizeOfBlock-IMAGE_SIZEOF_BASE_RELOCATION) / 2); i++, relInfo++) { // the upper 4 bits define the type of relocation int type = *relInfo >> 12; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy