#[repr(C)]
pub struct ImageSectionHeader { pub name: [u8; 8], pub virtual_size: U32<LE>, pub virtual_address: U32<LE>, pub size_of_raw_data: U32<LE>, pub pointer_to_raw_data: U32<LE>, pub pointer_to_relocations: U32<LE>, pub pointer_to_linenumbers: U32<LE>, pub number_of_relocations: U16<LE>, pub number_of_linenumbers: U16<LE>, pub characteristics: U32<LE>, }

Fields§

§name: [u8; 8]§virtual_size: U32<LE>§virtual_address: U32<LE>§size_of_raw_data: U32<LE>§pointer_to_raw_data: U32<LE>§pointer_to_relocations: U32<LE>§pointer_to_linenumbers: U32<LE>§number_of_relocations: U16<LE>§number_of_linenumbers: U16<LE>§characteristics: U32<LE>

Implementations§

source§

impl ImageSectionHeader

source

pub fn name_offset(&self) -> Result<Option<u32>>

Return the string table offset of the section name.

Returns Ok(None) if the name doesn’t use the string table and can be obtained with raw_name instead.

source

pub fn name<'data, R: ReadRef<'data>>( &'data self, strings: StringTable<'data, R> ) -> Result<&'data [u8]>

Return the section name.

This handles decoding names that are offsets into the symbol string table.

source

pub fn raw_name(&self) -> &[u8]

Return the raw section name.

source

pub fn coff_file_range(&self) -> Option<(u32, u32)>

Return the offset and size of the section in a COFF file.

Returns None for sections that have no data in the file.

source

pub fn coff_data<'data, R: ReadRef<'data>>( &self, data: R ) -> Result<&'data [u8], ()>

Return the section data in a COFF file.

Returns Ok(&[]) if the section has no data. Returns Err for invalid values.

source

pub fn coff_alignment(&self) -> u64

Return the section alignment in bytes.

This is only valid for sections in a COFF file.

source

pub fn coff_relocations<'data, R: ReadRef<'data>>( &self, data: R ) -> Result<&'data [ImageRelocation]>

Read the relocations in a COFF file.

data must be the entire file data.

source§

impl ImageSectionHeader

source

pub fn pe_file_range(&self) -> (u32, u32)

Return the offset and size of the section in a PE file.

The size of the range will be the minimum of the file size and virtual size.

source

pub fn pe_file_range_at(&self, va: u32) -> Option<(u32, u32)>

Return the file offset of the given virtual address, and the remaining size up to the end of the section.

Returns None if the section does not contain the address.

source

pub fn pe_address_range(&self) -> (u32, u32)

Return the virtual address and size of the section.

source

pub fn pe_data<'data, R: ReadRef<'data>>(&self, data: R) -> Result<&'data [u8]>

Return the section data in a PE file.

The length of the data will be the minimum of the file size and virtual size.

source

pub fn pe_data_at<'data, 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.

Ignores sections with invalid data.

Returns None if the section does not contain the address.

source

pub fn contains_rva(&self, va: u32) -> bool

Tests whether a given RVA is part of this section

source

pub fn pe_data_containing<'data, R: ReadRef<'data>>( &self, data: R, va: u32 ) -> Option<(&'data [u8], u32)>

Return the section data if it contains the given virtual address.

Also returns the virtual address of that section.

Ignores sections with invalid data.

Trait Implementations§

source§

impl Clone for ImageSectionHeader

source§

fn clone(&self) -> ImageSectionHeader

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 Debug for ImageSectionHeader

source§

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

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

impl Default for ImageSectionHeader

source§

fn default() -> ImageSectionHeader

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

impl Copy for ImageSectionHeader

source§

impl Pod for ImageSectionHeader

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.