From 29ad787b6b0fa2869750f5ca938b19ecdad02ddc Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 9 Sep 2024 17:16:31 +0200 Subject: [PATCH] Fix relocation handling --- src/windows_emulator/module/module_mapping.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/windows_emulator/module/module_mapping.cpp b/src/windows_emulator/module/module_mapping.cpp index a07a2227..a4233636 100644 --- a/src/windows_emulator/module/module_mapping.cpp +++ b/src/windows_emulator/module/module_mapping.cpp @@ -85,12 +85,13 @@ namespace } auto relocation_offset = directory->VirtualAddress; + const auto relocation_end = relocation_offset + directory->Size; - while (relocation_offset < directory->Size) + while (relocation_offset < relocation_end) { const auto relocation = buffer.as(relocation_offset).get(); - if (relocation.VirtualAddress <= 0 || relocation.SizeOfBlock <= 0) + if (relocation.VirtualAddress <= 0 || relocation.SizeOfBlock <= sizeof(IMAGE_BASE_RELOCATION)) { break; }