Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed "section is misaligned" error on certain CLR executables #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pe_tools/pe_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<H', fin.read(2))
if opt_sig == IMAGE_NT_OPTIONAL_HDR32_MAGIC:
opt = _IMAGE_OPTIONAL_HEADER32.unpack_from_io(fin)
Expand All @@ -299,6 +300,8 @@ def __init__(self, blob, verify_checksum=False):

dds = [_IMAGE_DATA_DIRECTORY.unpack_from_io(fin) for dd_idx in range(opt.NumberOfRvaAndSizes)]

fin.seek(sect_offs)

def make_pe_section(idx, hdr):
name = hdr.Name.rstrip(b'\0')

Expand Down