pub trait PeTrait {
// Required methods
fn data(&self) -> &[u8] ⓘ;
fn num_sections(&self) -> usize;
fn section_data_range(
&self,
index: usize,
) -> Result<Range<usize>, PeOffsetError>;
fn certificate_table_range(
&self,
) -> Result<Option<Range<usize>>, PeOffsetError>;
fn offsets(&self) -> Result<PeOffsets, PeOffsetError>;
}
Expand description
Trait for reading a PE file.
Note that this trait (and this crate as a whole) does not validate
the PE file. It’s up to the user to do that, if necessary. PeTrait
is used only to get data directly relevant to authenticode. For
example, this crate doesn’t check for the magic bytes that indicate
whether a file is a PE. However, bounds checking is always used, so
an invalid PE file can only cause an error to be returned, never
memory unsafety or a panic.
If the object
feature is enabled then PeTrait
will be
implemented for PeFile
from the object
crate.
Required Methods§
Sourcefn num_sections(&self) -> usize
fn num_sections(&self) -> usize
Get the number of sections.
Sourcefn section_data_range(
&self,
index: usize,
) -> Result<Range<usize>, PeOffsetError>
fn section_data_range( &self, index: usize, ) -> Result<Range<usize>, PeOffsetError>
Get a section’s data range.
The section index
starts at 1.
The start of the range is PointerToRawData
, and the size of
the range is SizeOfRawData
.
§Panics
Panics if the index is zero or greater than num_sections()
.
Sourcefn certificate_table_range(&self) -> Result<Option<Range<usize>>, PeOffsetError>
fn certificate_table_range(&self) -> Result<Option<Range<usize>>, PeOffsetError>
Get the certificate table’s data range, if present.
Sourcefn offsets(&self) -> Result<PeOffsets, PeOffsetError>
fn offsets(&self) -> Result<PeOffsets, PeOffsetError>
Get various offsets within the PE file needed for authenticode hashing.
Implementations on Foreign Types§
Source§impl<'data, I> PeTrait for PeFile<'data, I>where
I: ImageNtHeaders,
Available on crate feature object
only.
impl<'data, I> PeTrait for PeFile<'data, I>where
I: ImageNtHeaders,
object
only.