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

PE raw section size vs virtual size #28

Open
sevaa opened this issue Jan 27, 2020 · 1 comment
Open

PE raw section size vs virtual size #28

sevaa opened this issue Jan 27, 2020 · 1 comment

Comments

@sevaa
Copy link
Contributor

sevaa commented Jan 27, 2020

Found a case where a PE section parser was thrown off by a mismatch between section's raw size and its virtual size. It would read the section bytes sequentially, encounter the padding zeroes in the end, and crash.

PE stores the size of the section in a loaded PE file in the second field of the section header, VirtualSize. Maybe the library should initialize section.bytes with a VirtualSize-sized blob instead. Note the case where VirtualSize is greater than SizeOfRawData ; in those cases the bytes should be zero padded.

The filebytes library surfaces that field as PhysicalAddress_or_VirtualSize. The doc at https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#section-table-section-headers doesn't mention the circumstances when this field can mean PhysicalAddress, but maybe the maintainers know something I don't.

@sashs
Copy link
Owner

sashs commented Feb 10, 2020

Yes. I knew it, but I forgot it. I will look at this.

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

No branches or pull requests

2 participants