Fix relocation handling

This commit is contained in:
momo5502
2024-09-09 17:16:31 +02:00
parent 9d21fd83d5
commit 29ad787b6b

View File

@@ -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<IMAGE_BASE_RELOCATION>(relocation_offset).get();
if (relocation.VirtualAddress <= 0 || relocation.SizeOfBlock <= 0)
if (relocation.VirtualAddress <= 0 || relocation.SizeOfBlock <= sizeof(IMAGE_BASE_RELOCATION))
{
break;
}