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

Support PE32+ optional header #84

Merged
merged 2 commits into from Apr 5, 2023
Merged

Conversation

Morilli
Copy link
Contributor

@Morilli Morilli commented Apr 5, 2023

I'm using hachoir in my project and just recently came across a failure because the PE exe parser only supports the optional PE32 header, not the PE32+ one.

Interestingly this is already marked in the code with a TODO, and adding support for it is relatively simple by just following the specification in https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#optional-header-image-only.

I've tested that with these changes applied, the previously failing exe file can now be parsed correctly.

@nneonneo
Copy link
Collaborator

nneonneo commented Apr 5, 2023

Sorry, CI was broken. Can you rebase it and push again?

yield UInt8(self, "maj_lnk_ver", "Major linker version")
yield UInt8(self, "min_lnk_ver", "Minor linker version")
yield filesizeHandler(UInt32(self, "size_code", "Size of code"))
yield filesizeHandler(UInt32(self, "size_init_data", "Size of initialized data"))
yield filesizeHandler(UInt32(self, "size_uninit_data", "Size of uninitialized data"))
yield textHandler(UInt32(self, "entry_point", "Address (RVA) of the code entry point"), hexadecimal)
yield textHandler(UInt32(self, "base_code", "Base (RVA) of code"), hexadecimal)
yield textHandler(UInt32(self, "base_data", "Base (RVA) of data"), hexadecimal)
yield textHandler(UInt32(self, "image_base", "Image base (RVA)"), hexadecimal)
if not is_pe32plus: yield textHandler(UInt32(self, "base_data", "Base (RVA) of data"), hexadecimal)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use two separate lines here

@nneonneo nneonneo merged commit f010fcb into vstinner:main Apr 5, 2023
2 checks passed
@Morilli Morilli deleted the support-pe32+ branch April 5, 2023 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants