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
可选头结构
包含 PE 文件的加载和运行时信息,如入口点地址、内存布局、 版本信息等。这个结构对于 Windows 加载器正确加载和执行程序至关重要。
Fields§
§magic: u16魔数,标识 PE32 或 PE32+ 格式
major_linker_version: u8链接器的主版本号
minor_linker_version: u8链接器的次版本号
size_of_code: u32代码节的总大小(以字节为单位)
size_of_initialized_data: u32已初始化数据的总大小
size_of_uninitialized_data: u32未初始化数据的总大小
address_of_entry_point: u32程序入口点的 RVA(相对虚拟地址)
base_of_code: u32代码节的起始 RVA
base_of_data: Option<u32>数据节的起始 RVA,仅 PE32 格式有效
image_base: u64映像的首选加载地址
section_alignment: u32节在内存中的对齐粒度
file_alignment: u32节在文件中的对齐粒度
major_operating_system_version: u16所需操作系统的主版本号
minor_operating_system_version: u16所需操作系统的次版本号
major_image_version: u16映像的主版本号
minor_image_version: u16映像的次版本号
major_subsystem_version: u16子系统的主版本号
minor_subsystem_version: u16子系统的次版本号
win32_version_value: u32保留字段,必须为 0
size_of_image: u32映像的总大小,包括所有头文件和节
size_of_headers: u32所有头文件的总大小
checksum: u32映像的校验和,用于内核模式和系统 DLL
subsystem: SubsystemType子系统类型,定义程序运行环境
dll_characteristics: u16DLL 特征标志,描述 DLL 的各种属性
size_of_stack_reserve: u64为线程栈保留的虚拟内存大小
size_of_stack_commit: u64为线程栈提交的虚拟内存大小
size_of_heap_reserve: u64为进程堆保留的虚拟内存大小
size_of_heap_commit: u64为进程堆提交的虚拟内存大小
loader_flags: u32保留字段,必须为 0
number_of_rva_and_sizes: u32数据目录表的条目数量
data_directories: Vec<DataDirectory>数据目录表,包含各种数据目录的信息
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
创建一个标准的可选头,适用于 .NET 程序
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
根据架构创建可选头
Trait Implementations§
Source§impl Clone for OptionalHeader
impl Clone for OptionalHeader
Source§fn clone(&self) -> OptionalHeader
fn clone(&self) -> OptionalHeader
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OptionalHeader
impl Debug for OptionalHeader
Source§impl<'de> Deserialize<'de> for OptionalHeader
impl<'de> Deserialize<'de> for OptionalHeader
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for OptionalHeader
impl RefUnwindSafe for OptionalHeader
impl Send for OptionalHeader
impl Sync for OptionalHeader
impl Unpin for OptionalHeader
impl UnwindSafe for OptionalHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more