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

Expose PeFile data, section_table and data_directory #324

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/read/pe/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ where
self.nt_headers
}

fn data_directory(&self, id: usize) -> Option<&'data pe::ImageDataDirectory> {
/// Returns the section table of this binary.
pub fn section_table(&self) -> SectionTable<'data> {
self.common.sections
}

/// Returns the data directory at the given index.
pub fn data_directory(&self, id: usize) -> Option<&'data pe::ImageDataDirectory> {
self.data_directories
.get(id)
.filter(|d| d.size.get(LE) != 0)
Expand All @@ -84,6 +90,11 @@ where
fn data_at(&self, va: u32) -> Option<Bytes<'data>> {
self.common.sections.pe_data_at(self.data, va).map(Bytes)
}

/// Returns this binary data.
pub fn data(&self) -> R {
self.data
}
}

impl<'data, Pe, R> read::private::Sealed for PeFile<'data, Pe, R>
Expand Down