pub struct SectionTable<'data> { /* private fields */ }
Expand description
The table of section headers in a COFF or PE file.
Implementations
sourceimpl<'data> SectionTable<'data>
impl<'data> SectionTable<'data>
sourcepub fn parse<R: ReadRef<'data>>(
header: &ImageFileHeader,
data: R,
offset: u64
) -> Result<Self>
pub fn parse<R: ReadRef<'data>>(
header: &ImageFileHeader,
data: R,
offset: u64
) -> Result<Self>
Parse the section table.
data
must be the entire file data.
offset
must be after the optional file header.
sourcepub fn iter(&self) -> Iter<'data, ImageSectionHeader>
pub fn iter(&self) -> Iter<'data, ImageSectionHeader>
Iterate over the section headers.
Warning: sections indices start at 1.
sourcepub fn section(&self, index: usize) -> Result<&'data ImageSectionHeader>
pub fn section(&self, index: usize) -> Result<&'data ImageSectionHeader>
Return the section header at the given index.
The index is 1-based.
sourcepub fn section_by_name<R: ReadRef<'data>>(
&self,
strings: StringTable<'data, R>,
name: &[u8]
) -> Option<(usize, &'data ImageSectionHeader)>
pub fn section_by_name<R: ReadRef<'data>>(
&self,
strings: StringTable<'data, R>,
name: &[u8]
) -> Option<(usize, &'data ImageSectionHeader)>
Return the section header with the given name.
The returned index is 1-based.
Ignores sections with invalid names.
sourcepub fn max_section_file_offset(&self) -> u64
pub fn max_section_file_offset(&self) -> u64
Compute the maximum file offset used by sections.
This will usually match the end of file, unless the PE file has a data overlay
sourceimpl<'data> SectionTable<'data>
impl<'data> SectionTable<'data>
sourcepub fn pe_file_range_at(&self, va: u32) -> Option<(u32, u32)>
pub fn pe_file_range_at(&self, va: u32) -> Option<(u32, u32)>
Return the file offset of the given virtual address, and the size up to the end of the section containing it.
Returns None
if no section contains the address.
sourcepub fn pe_data_at<R: ReadRef<'data>>(
&self,
data: R,
va: u32
) -> Option<&'data [u8]>
pub fn pe_data_at<R: ReadRef<'data>>(
&self,
data: R,
va: u32
) -> Option<&'data [u8]>
Return the data starting at the given virtual address, up to the end of the section containing it.
Ignores sections with invalid data.
Returns None
if no section contains the address.
sourcepub fn pe_data_containing<R: ReadRef<'data>>(
&self,
data: R,
va: u32
) -> Option<(&'data [u8], u32)>
pub fn pe_data_containing<R: ReadRef<'data>>(
&self,
data: R,
va: u32
) -> Option<(&'data [u8], u32)>
Return the data of the section that contains the given virtual address in a PE file.
Also returns the virtual address of that section.
Ignores sections with invalid data.
sourcepub fn section_containing(&self, va: u32) -> Option<&'data ImageSectionHeader>
pub fn section_containing(&self, va: u32) -> Option<&'data ImageSectionHeader>
Return the section that contains a given virtual address.
Trait Implementations
sourceimpl<'data> Clone for SectionTable<'data>
impl<'data> Clone for SectionTable<'data>
sourcefn clone(&self) -> SectionTable<'data>
fn clone(&self) -> SectionTable<'data>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'data> Debug for SectionTable<'data>
impl<'data> Debug for SectionTable<'data>
sourceimpl<'data> Default for SectionTable<'data>
impl<'data> Default for SectionTable<'data>
sourcefn default() -> SectionTable<'data>
fn default() -> SectionTable<'data>
Returns the “default value” for a type. Read more
impl<'data> Copy for SectionTable<'data>
Auto Trait Implementations
impl<'data> RefUnwindSafe for SectionTable<'data>
impl<'data> Send for SectionTable<'data>
impl<'data> Sync for SectionTable<'data>
impl<'data> Unpin for SectionTable<'data>
impl<'data> UnwindSafe for SectionTable<'data>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more