pub struct OptionalHeader {Show 31 fields
pub magic: u16,
pub major_linker_version: u8,
pub minor_linker_version: u8,
pub size_of_code: u32,
pub size_of_initialized_data: u32,
pub size_of_uninitialized_data: u32,
pub address_of_entry_point: u32,
pub base_of_code: u32,
pub base_of_data: Option<u32>,
pub image_base: u64,
pub section_alignment: u32,
pub file_alignment: u32,
pub major_operating_system_version: u16,
pub minor_operating_system_version: u16,
pub major_image_version: u16,
pub minor_image_version: u16,
pub major_subsystem_version: u16,
pub minor_subsystem_version: u16,
pub win32_version_value: u32,
pub size_of_image: u32,
pub size_of_headers: u32,
pub checksum: u32,
pub subsystem: SubsystemType,
pub dll_characteristics: u16,
pub size_of_stack_reserve: u64,
pub size_of_stack_commit: u64,
pub size_of_heap_reserve: u64,
pub size_of_heap_commit: u64,
pub loader_flags: u32,
pub number_of_rva_and_sizes: u32,
pub data_directories: Vec<DataDirectory>,
}Expand description
Optional header structure
Contains loading and runtime information for the PE file, such as entry point address, memory layout, version info, etc. This structure is crucial for the Windows loader to correctly load and execute the program.
Fields§
§magic: u16Magic number identifying PE32 or PE32+ format
major_linker_version: u8Major version of the linker
minor_linker_version: u8Minor version of the linker
size_of_code: u32Total size of the code section in bytes
size_of_initialized_data: u32Total size of initialized data
size_of_uninitialized_data: u32Total size of uninitialized data
address_of_entry_point: u32RVA (Relative Virtual Address) of the program entry point
base_of_code: u32Starting RVA of the code section
base_of_data: Option<u32>Starting RVA of the data section, only valid for PE32
image_base: u64Preferred loading address of the image
section_alignment: u32Alignment granularity of sections in memory
file_alignment: u32Alignment granularity of sections in the file
major_operating_system_version: u16Major version of the required operating system
minor_operating_system_version: u16Minor version of the required operating system
major_image_version: u16Major version of the image
minor_image_version: u16Minor version of the image
major_subsystem_version: u16Major version of the subsystem
minor_subsystem_version: u16Minor version of the subsystem
win32_version_value: u32Reserved field, must be 0
size_of_image: u32Total size of the image, including all headers and sections
size_of_headers: u32Total size of all headers
checksum: u32Checksum of the image, used for kernel mode and system DLLs
subsystem: SubsystemTypeSubsystem type, defining the runtime environment
dll_characteristics: u16DLL characteristics flags, describing various properties of the DLL
size_of_stack_reserve: u64Virtual memory size reserved for the thread stack
size_of_stack_commit: u64Virtual memory size committed for the thread stack
size_of_heap_reserve: u64Virtual memory size reserved for the process heap
size_of_heap_commit: u64Virtual memory size committed for the process heap
loader_flags: u32Reserved field, must be 0
number_of_rva_and_sizes: u32Number of entries in the data directory table
data_directories: Vec<DataDirectory>Data directory table, containing info about various data directories
Implementations§
Source§impl OptionalHeader
impl OptionalHeader
Sourcepub fn new(
entry_point: u32,
image_base: u64,
size_of_code: u32,
size_of_headers: u32,
size_of_image: u32,
subsystem: SubsystemType,
) -> Self
pub fn new( entry_point: u32, image_base: u64, size_of_code: u32, size_of_headers: u32, size_of_image: u32, subsystem: SubsystemType, ) -> Self
Create a standard optional header suitable for .NET programs
Sourcepub fn new_for_architecture(
architecture: &Architecture,
entry_point: u32,
image_base: u64,
size_of_code: u32,
size_of_headers: u32,
size_of_image: u32,
subsystem: SubsystemType,
) -> Self
pub fn new_for_architecture( architecture: &Architecture, entry_point: u32, image_base: u64, size_of_code: u32, size_of_headers: u32, size_of_image: u32, subsystem: SubsystemType, ) -> Self
Create optional header based on architecture
Trait Implementations§
Source§impl Clone for OptionalHeader
impl Clone for OptionalHeader
Source§fn clone(&self) -> OptionalHeader
fn clone(&self) -> OptionalHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more