round up reloc image if on boundary

This commit is contained in:
Folkert 2022-10-30 11:15:01 +01:00
parent bb5864c2b8
commit 69fe0464f5
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -1259,8 +1259,10 @@ fn relocate_dummy_dll_entries(executable: &mut [u8], md: &PeMetadata) {
);
// for unclear reasons, we must bump the image directory size here.
// we also need some zeroed-out memory at the end, so if the directory
// ends at a multiple of `file_alignment`, pick the next one.
let new_reloc_directory_size =
next_multiple_of(dir.size.get(LE) as usize, md.file_alignment as usize);
next_multiple_of(dir.size.get(LE) as usize + 4, md.file_alignment as usize);
dir.size.set(LE, new_reloc_directory_size as u32);
}