-
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
PE: Support multiple debug directories and VCFeature, Repro, ExDllCharacteristics, POGO parsers #403
base: master
Are you sure you want to change the base?
Conversation
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.
this seems fine to me, other than the fixes w.r.t. &Vec<T>
-> &[T]
@kkent030315 thanks for this PR, I think if we fix the basic nits this is ready to go, thank you! |
I'd also like to see this one go in for sure :) |
@m4b Thank you for the review! I'm going to mess with this PR very soon. |
- Added decent docs for `pe::debug` structs and constants - Added integration tests for `pe::debug::DebugData`
@m4b Hi, this PR has been refactored, please take a look #403 (comment) for up-to-date changelists. |
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.
initial review, did not dive in deeply; main concern was initially with the allocations; I can't recall offhand, but there is probably some trait you can implement to allow find
to work with your iterator, to prevent the allocation; you'll likely need clone/copy on the iterator since it'll likely consume it, but that should be fine.
also would like to understand why the breaking change is necessary, can you give some motivation for that?
lastly, thank you so much (as usual!) for your incredible documentation on the code you commit, truly outstanding stuff!
Self::parse_with_opts(bytes, idd, &options::ParseOptions::default()) | ||
} | ||
|
||
pub fn parse_with_opts( | ||
bytes: &'a [u8], | ||
idd: &ImageDebugDirectory, | ||
idd: ImageDebugDirectoryIterator<'_>, |
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.
breaking change; is this avoidable?
))); | ||
} | ||
let filename_length = filename_length as usize; | ||
// calculate how long the eventual filename will be, which doubles as a check of the record 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 looks like whitespace error was introduced here? i'm surprised CI doesn't catch this via rustfmt
?
pub fn parse(bytes: &'a [u8], idd: &ImageDebugDirectory) -> error::Result<Option<Self>> { | ||
pub fn parse( | ||
bytes: &'a [u8], | ||
idd: ImageDebugDirectoryIterator<'_>, |
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.
breaking change, for same reasons below
idd: ImageDebugDirectoryIterator<'_>, | ||
opts: &options::ParseOptions, | ||
) -> error::Result<Option<Self>> { | ||
let idd = idd.collect::<Result<Vec<_>, _>>()?; |
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.
do you really need to allocate the vec here? even iterating twice is probably better
pub fn parse(bytes: &'a [u8], idd: &ImageDebugDirectory) -> error::Result<Option<Self>> { | ||
pub fn parse( | ||
bytes: &'a [u8], | ||
idd: ImageDebugDirectoryIterator<'_>, |
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.
ditto same breaking change
if idd.data_type != IMAGE_DEBUG_TYPE_CODEVIEW { | ||
// not a codeview debug directory | ||
// that's not an error, but it's not a CodeviewPDB20DebugInfo either | ||
let idd = idd.collect::<Result<Vec<_>, _>>()?; |
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.
same concern about allocation
idd: ImageDebugDirectoryIterator<'_>, | ||
opts: &options::ParseOptions, | ||
) -> error::Result<Option<Self>> { | ||
let idd = idd.collect::<Result<Vec<_>, _>>()?; |
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.
ditto allocation concern
idd: ImageDebugDirectoryIterator<'_>, | ||
opts: &options::ParseOptions, | ||
) -> error::Result<Option<Self>> { | ||
let idd = idd.collect::<Result<Vec<_>, _>>()?; |
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.
ditto allocation; it seems like all of these allocate simply to call find
on the type iiuc?
This PR addresses the issue #314.
- The change is straightforward. It makes theDebugData::image_debug_directory: ImageDebugDirectory
intoVec<ImageDebugDirectory>
as someone pointed out in the #314 (comment). So this is to be an breaking change.- There is another addition of VC feature metadataIMAGE_DEBUG_TYPE_VC_FEATURE
(IMAGE_DEBUG_VC_FEATURE_ENTRY
) in the debug directory.If anyone have suggestion of making this semantics without breaking the backward compatibility I am open to discuss.
update:
DebugData
and its parsers for comfortable code that makes multiple debug directories in mind.TE::fixup_debug_data
has been merged toDebugData::parse_*
: AsDebugData
is now more compatible with TE (Terse Executable) by addingDebugData::parse_with_opts_and_fixup
and fixup RVA field inDebugData
andImageDebugDirectoryIterator
in order if any fixup is required forImageDebugDirectory::address_of_raw_data
andImageDebugDirectory::pointer_to_raw_data
.pe::debug
.IMAGE_DEBUG_TYPE_VC_FEATURE
.IMAGE_DEBUG_TYPE_REPRO
.IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS
.IMAGE_DEBUG_TYPE_POGO
.DebugData
parsers.impl ImageDebugDirectory
and it has been merged toDebugData::parse_*
.