Skip to content

Commit

Permalink
Merge pull request gimli-rs#324 from roblabla/expose-pefile-fields
Browse files Browse the repository at this point in the history
Expose PeFile data, section_table and data_directory
  • Loading branch information
philipc authored Jun 15, 2021
2 parents 23c0149 + 758e5c5 commit b36dab4
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit b36dab4

Please sign in to comment.