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

All zeros in some regions #11

Closed
xchgrbprsp opened this issue Jan 22, 2017 · 4 comments
Closed

All zeros in some regions #11

xchgrbprsp opened this issue Jan 22, 2017 · 4 comments

Comments

@xchgrbprsp
Copy link

Don't know if I should post a question here but I get zeros in some regions of the dump file when there is clearly executable code in those regions according to CE. I know little about segments and how they are arranged and loaded into memory and I've been struggling figuring out what the problem was.

@glmcdona
Copy link
Owner

glmcdona commented Jan 23, 2017 via email

@xchgrbprsp
Copy link
Author

The missing region turns out to be the entire last section and I got this warning in the output:
"Large section size for section 10 of 0x1649000 being truncated to 0x1648800 to fit within the image size. This could be as a result of a custom code to load a library by means other than LoadLibrary()."

I added some printfs in the function process_disk_image in pe_header.cpp and messed around with the code a bit and found out the problem seemed to be that larger_image_size was not aligned while VirtualSize was, which made larger_image_size smaller than VirtualAddress + SizeOfRawData in the _test_read check for the last section.
I then replaced the line larger_image_size = this->_image_size + new_section_size; with larger_image_size =_section_align((DWORD)_image_size, _header_pe64->OptionalHeader.SectionAlignment) + new_section_size; and everything worked.

I'm not sure if it's the correct way to fix it though.

@glmcdona
Copy link
Owner

Thanks, great analysis! I think your adjustment is right, I will have a look in detail at the code and think on it before committing it. I'm surprised it left the entire section empty as a result of this as well, I need to review the code surrounding that truncation error.

glmcdona pushed a commit that referenced this issue Feb 13, 2017
…etter

page alignment of new section that gets added. Thanks to megastupidmonkey
for discovering and proposing a fix.
@glmcdona
Copy link
Owner

Fixed. This will be released in pd v2.1 which I should have built and uploaded shortly. Thanks for finding the root cause and proposing a solution!

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