zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f7bc8900bfef87f67230ac5af7edb2d7766b3ba3 (tree)
parent 6f4343b61afe36a709e713735947561a2b76bce8
Author: Erik Hugne <erik.hugne@gmail.com>
Date:   Mon, 25 Apr 2022 22:45:12 +0200

std.coff: parse out codebase and entrypoint from optionalheader

Diffstat:
Mlib/std/coff.zig | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/std/coff.zig b/lib/std/coff.zig @@ -197,7 +197,11 @@ pub const Coff = struct { const opt_header_pos = try self.in_file.getPos(); self.pe_header.magic = try in.readIntLittle(u16); - // All we care about is the image base value and PDB info + try self.in_file.seekTo(opt_header_pos + 16); + self.pe_header.entry_addr = try in.readIntLittle(u32); + try self.in_file.seekTo(opt_header_pos + 20); + self.pe_header.code_base = try in.readIntLittle(u32); + // The header structure is different for 32 or 64 bit var num_rva_pos: u64 = undefined; if (self.pe_header.magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { @@ -374,6 +378,8 @@ const OptionalHeader = struct { magic: u16, data_directory: [IMAGE_NUMBEROF_DIRECTORY_ENTRIES]DataDirectory, + entry_addr: u32, + code_base: u32, image_base: u64, };