You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the debug_data field should ideally be a Option<Vec<DebugData>>, but that would be an api breaking change.
I suppose there could be an additional field name additional_debug_data to hold the entries after the first.
Note that I thought it might be very difficult to read the additional entries, but it's not too bad. One must explicitly add a reference to the scroll crate to use the Pread trait and then you can write something like this:
let pe = PE::parse(&bytes)?;ifletSome(optional_header) = pe.header.optional_header{ifletSome(debug_directory) = optional_header.data_directories.get_debug_table(){let entries = debug_directory.sizeasusize / std::mem::size_of::<debug::ImageDebugDirectory>();let rva = debug_directory.virtual_addressasusize;let opts = options::ParseOptions::default();let offset = utils::find_offset(rva,&pe.sections, optional_header.windows_fields.file_alignment,&opts).ok_or_else(|| {
goblin::error::Error::Malformed(format!("Cannot map ImageDebugDirectory rva {:#x} into offset",
rva
))})?;for i in0..entries {let entry = offset + i * std::mem::size_of::<debug::ImageDebugDirectory>();let idd: debug::ImageDebugDirectory = bytes.pread_with(entry, scroll::LE)?;println!("{:?}", idd);}}}
The text was updated successfully, but these errors were encountered:
Goblin currently parses the first debug directory and ignores any subsequent entries.
A PE debug directory can have multiple entries, for example, a C# program compiled with the option
/debug:embedded
might have 3 entries like:In the above - the pdb data is in the image, not in a separate file. This isn't the only scenario where there may be multiple debug directory entries.
I'm not sure what a fix should look like - the debug_data field returns a singleton Option<DebugData>, and the image_debug_directory field is also a single instance of ImageDebugDirectory.
I think the
debug_data
field should ideally be aOption<Vec<DebugData>>
, but that would be an api breaking change.I suppose there could be an additional field name
additional_debug_data
to hold the entries after the first.Note that I thought it might be very difficult to read the additional entries, but it's not too bad. One must explicitly add a reference to the
scroll
crate to use thePread
trait and then you can write something like this:The text was updated successfully, but these errors were encountered: