-
Notifications
You must be signed in to change notification settings - Fork 163
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
Calculate number of read bytes for sections using file alignment #101
Conversation
ac50988
to
fae9100
Compare
heh; i assumed the update branch button would rebase your commits on top; but it does not... what a pain in the ass |
I think this looks good to me, but I don't really have the bandwidth at the moment to fully review this. @philipc @willglynn (or anyone else) do you have any comments here? I'm inclined to just merge since it seems more or less fine. |
src/pe/utils.rs
Outdated
read_size | ||
} else { | ||
raw_data_round_size | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is clearer to do: cmp::min(read_size, round_size(size_of_raw_data))
(and same for virtual size).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@philipc thanks for your comments. It's is indeed clearer with cmp::min
Looks fine, assuming the linked stackoverflow answer is correct (which is not something I can judge, this is all undocumented, in fact it's disallowed by the documentation...). From what I've read, this only applies to PE executables, not COFF objects, so this will need changing if we reuse this code for COFF. |
2639349
to
ed4f1ab
Compare
@tathanhdinh Can you rebase this to remove the extra 3 commits? |
ed4f1ab
to
4a9f2ca
Compare
@philipc Thanks for the remarks, the rebase has been done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience!
Hello all,
The
pointer_to_raw_data
of each section should be rounded down to a multiple of 512. Moreover, the valid address range of each section should be calculated using alsosize_of_raw_data
andfile_alignment
, e.g. quine.exe hasvirtual_size
(of its unique section) is zero, but it is a valid PE.To make the review becomes easier, I split the previous PR (which is closed), into parts.
Many thanks for any comments.