Struct object::read::coff::SectionTable

source ·
pub struct SectionTable<'data> { /* private fields */ }
Expand description

The table of section headers in a COFF or PE file.

Implementations§

source§

impl<'data> SectionTable<'data>

source

pub fn parse<Coff: CoffHeader, R: ReadRef<'data>>( header: &Coff, 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.

source

pub fn iter(&self) -> Iter<'data, ImageSectionHeader>

Iterate over the section headers.

Warning: sections indices start at 1.

source

pub fn is_empty(&self) -> bool

Return true if the section table is empty.

source

pub fn len(&self) -> usize

The number of section headers.

source

pub fn section(&self, index: usize) -> Result<&'data ImageSectionHeader>

Return the section header at the given index.

The index is 1-based.

source

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.

source

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

source§

impl<'data> SectionTable<'data>

source

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.

source

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.

source

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.

source

pub fn section_containing(&self, va: u32) -> Option<&'data ImageSectionHeader>

Return the section that contains a given virtual address.

Trait Implementations§

source§

impl<'data> Clone for SectionTable<'data>

source§

fn clone(&self) -> SectionTable<'data>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'data> Debug for SectionTable<'data>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'data> Default for SectionTable<'data>

source§

fn default() -> SectionTable<'data>

Returns the “default value” for a type. Read more
source§

impl<'data> Copy for SectionTable<'data>

Auto Trait Implementations§

§

impl<'data> Freeze for SectionTable<'data>

§

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.