From 596aa58c162e68c9485eb6d9ec76c0ed2b50684a Mon Sep 17 00:00:00 2001 From: imag0r Date: Tue, 11 Jun 2024 07:14:27 -0700 Subject: [PATCH] Fixed "section is misaligned" error on certain CLR executables where SizeOfOptionalHeader in the file header is different than the size of IMAGE_OPTIONAL_HEADER struct --- pe_tools/pe_parser.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pe_tools/pe_parser.py b/pe_tools/pe_parser.py index 4f8620f..9bd6663 100644 --- a/pe_tools/pe_parser.py +++ b/pe_tools/pe_parser.py @@ -275,6 +275,7 @@ def __init__(self, blob, verify_checksum=False): raise RuntimeError('Not a PE file: PE signature is missing.') hdr = _IMAGE_FILE_HEADER.unpack_from_io(fin) + sect_offs = fin.tell() + hdr.SizeOfOptionalHeader opt_sig, = struct.unpack('