Struct lief::pe::headers::OptionalHeader

pub struct OptionalHeader<'a> { /* private fields */ }
Expand description

Structure which represents the PE OptionalHeader (after Header).

Note that the term optional comes from the COFF specifications but this header is mandatory for a PE binary.

Implementations§

§

impl OptionalHeader<'_>

pub fn major_linker_version(&self) -> u8

The linker major version

pub fn minor_linker_version(&self) -> u8

The linker minor version

pub fn sizeof_code(&self) -> u32

The size of the code .text section or the sum of all the sections that contain code (i.e. sections with CNT_CODE flag)

pub fn sizeof_initialized_data(&self) -> u32

The size of the initialized data which are usually located in the .data section. If the initialized data are split across multiple sections, it is the sum of the sections.

pub fn sizeof_uninitialized_data(&self) -> u32

The size of the uninitialized data which are usually located in the .bss section. If the uninitialized data are split across multiple sections, it is the sum of the sections.

pub fn addressof_entrypoint(&self) -> u32

The address of the entry point relative to the image base when the executable file is loaded into memory. For program images, this is the starting address. For device drivers, this is the address of the initialization function.

An entry point is optional for DLLs. When no entry point is present, this field must be zero.

pub fn baseof_code(&self) -> u32

Address relative to the imagebase where the binary’s code starts.

pub fn baseof_data(&self) -> u32

Address relative to the imagebase where the binary’s data starts.

This value is not present for PE64 files

pub fn imagebase(&self) -> u64

The preferred base address when mapping the binary in memory

pub fn section_alignment(&self) -> u32

The alignment (in bytes) of sections when they are loaded into memory.

It must be greater than or equal to file_alignment and the default is the page size for the architecture.

pub fn file_alignment(&self) -> u32

The section’s file alignment. This value must be a power of 2 between 512 and 64K. The default value is usually 512

pub fn major_operating_system_version(&self) -> u32

The major version number of the required operating system

pub fn minor_operating_system_version(&self) -> u32

The minor version number of the required operating system

pub fn major_image_version(&self) -> u32

The major version number of the image

pub fn minor_image_version(&self) -> u32

The minor version number of the image

pub fn major_subsystem_version(&self) -> u32

The major version number of the subsystem

pub fn minor_subsystem_version(&self) -> u32

The minor version number of the subsystem

pub fn win32_version_value(&self) -> u32

According to the official PE specifications, this value is reserved and should be 0.

pub fn sizeof_image(&self) -> u32

The size (in bytes) of the image, including all headers, as the image is loaded in memory.

It must be a multiple of section_alignment and should match crate::pe::Binary::virtual_size

pub fn sizeof_headers(&self) -> u32

Size of the DosHeader + PE Header + Section headers rounded up to a multiple of the file_alignment

pub fn checksum(&self) -> u32

The image file checksum. The algorithm for computing the checksum is incorporated into IMAGHELP.DLL.

The following are checked for validation at load time all drivers, any DLL loaded at boot time, and any DLL that is loaded into a critical Windows process.

pub fn subsystem(&self) -> Subsystem

Target subsystem like Driver, XBox, Windows GUI, …

pub fn dll_characteristics(&self) -> DllCharacteristics

Some characteristics of the underlying binary like the support of the PIE. The prefix dll comes from the official PE specifications but these characteristics are also used for executables

pub fn sizeof_stack_reserve(&self) -> u64

Size of the stack to reserve when loading the PE binary

Only OptionalHeader::sizeof_stack_commit is committed, the rest available one page at a time until the reserve size is reached.

pub fn sizeof_stack_commit(&self) -> u64

Size of the stack to commit

pub fn sizeof_heap_reserve(&self) -> u64

Size of the heap to reserve when loading the PE binary

pub fn sizeof_heap_commit(&self) -> u64

Size of the stack to commit

pub fn loader_flags(&self) -> u32

According to the PE specifications, this value is reserved and should be 0.

pub fn numberof_rva_and_size(&self) -> u32

The number of DataDirectory that follow this header.

Trait Implementations§

§

impl Debug for OptionalHeader<'_>

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for OptionalHeader<'a>

§

impl<'a> !Send for OptionalHeader<'a>

§

impl<'a> !Sync for OptionalHeader<'a>

§

impl<'a> Unpin for OptionalHeader<'a>

§

impl<'a> UnwindSafe for OptionalHeader<'a>

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