Skip to content

Commit

Permalink
pe: Fix ImageBase offset
Browse files Browse the repository at this point in the history
According to the PE spec, the ImageBase is 32-bit length and located at
28 byte offset. The current code tries to read 64-bit at 24, which
   causes unaligned access.

Signed-off-by: Akira Moroo <[email protected]>
  • Loading branch information
retrage committed Aug 11, 2023
1 parent 5d377ae commit b54c81d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<'a> Loader<'a> {

let entry_point = optional_region.read_u32(16);

self.image_base = optional_region.read_u64(24);
self.image_base = optional_region.read_u32(28) as u64;
let address = if self.image_base != 0 {
// The image has desired load address
self.image_base
Expand Down

0 comments on commit b54c81d

Please sign in to comment.