Struct SectionHeader

Source
#[repr(C)]
pub struct SectionHeader { pub name: [u8; 8], pub virtual_size: u32, pub virtual_address: u32, pub size_of_raw_data: u32, pub pointer_to_raw_data: u32, pub pointer_to_relocations: u32, pub pointer_to_line_numbers: u32, pub number_of_relocations: u16, pub number_of_line_numbers: u16, pub characteristics: u32, }
Expand description

Contains information such as name, size, characteristics and location of a section in the binary

Fields§

§name: [u8; 8]

An 8-byte, null-padded UTF-8 encoded string. If the string is exactly 8 characters long, there is no terminating null. For longer names, this field contains a slash (/) that is followed by an ASCII representation of a decimal number that is an offset into the string table. Executable images do not use a string table and do not support section names longer than 8 characters. Long names in object files are truncated if they are emitted to an executable file.

§virtual_size: u32

The total size of the section when loaded into memory. If this value is greater than size_of_raw_data, the section is zero-padded. This field is valid only for executable images and should be set to zero for object files.

§virtual_address: u32

For executable images, the address of the first byte of the section relative to the image base when the section is loaded into memory. For object files, this field is the address of the first byte before relocation is applied; for simplicity, compilers should set this to zero. Otherwise, it is an arbitrary value that is subtracted from offsets during relocation.

§size_of_raw_data: u32

The size of the section (for object files) or the size of the initialized data on disk (for image files). For executable images, this must be a multiple of file_alignment from the optional header. If this is less than virtual_size, the remainder of the section is zero-filled. Because the size_of_raw_data field is rounded but the virtual_size field is not, it is possible for size_of_raw_data to be greater than virtual_size as well. When a section contains only uninitialized data, this field should be zero.

§pointer_to_raw_data: u32

The file pointer to the first page of the section within the COFF file. For executable images, this must be a multiple of file_alignment from the optional header. For object files, the value should be aligned on a 4-byte boundary for best performance. When a section contains only uninitialized data, this field should be zero.

§pointer_to_relocations: u32

The file pointer to the beginning of relocation entries for the section. This is set to zero for executable images or if there are no relocations.

§pointer_to_line_numbers: u32

The file pointer to the beginning of line-number entries for the section. This is set to zero if there are no COFF line numbers. This value should be zero for an image because COFF debugging information is deprecated.

§number_of_relocations: u16

The number of relocation entries for the section. This is set to zero for executable images.

§number_of_line_numbers: u16

The number of line-number entries for the section. This value should be zero for an image because COFF debugging information is deprecated.

§characteristics: u32

The flags that describe the characteristics of the section.

Implementations§

Source§

impl SectionHeader

Source

pub fn get_name(&self) -> Option<String>

Get the name of a section as a string. Note that this string may contain null characters.

Source

pub fn get_characteristics(&self) -> Option<SectionFlags>

Returns the Section Characteristics as bitflags

Trait Implementations§

Source§

impl Clone for SectionHeader

Source§

fn clone(&self) -> SectionHeader

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 Default for SectionHeader

Source§

fn default() -> SectionHeader

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

impl Display for SectionHeader

Source§

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

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

impl Zeroable for SectionHeader

Source§

fn zeroed() -> Self

Source§

impl Copy for SectionHeader

Source§

impl Pod for SectionHeader

Auto Trait Implementations§

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,