Skip to content

Commit

Permalink
Fix relocation handling
Browse files Browse the repository at this point in the history
  • Loading branch information
momo5502 committed Sep 9, 2024
1 parent 9d21fd8 commit 29ad787
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/windows_emulator/module/module_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 29ad787

Please sign in to comment.