pub struct ExeReader<R> { /* private fields */ }Expand description
.NET PE 文件惰性读取器
该类负责读取和解析 .NET 程序集文件,提供以下功能:
- 检查文件是否为有效的 .NET 程序集
- 解析 CLR 头和元数据
- 提取程序集的基本信息
- 验证程序集的完整性
- 支持惰性读取和完整解析两种模式
Implementations§
Source§impl<R> ExeReader<R>
impl<R> ExeReader<R>
Sourcepub fn get_assembly_info(&mut self) -> Result<DotNetAssemblyInfo, GaiaError>
pub fn get_assembly_info(&mut self) -> Result<DotNetAssemblyInfo, GaiaError>
Sourcepub fn to_clr_program(&mut self) -> Result<ClrProgram, GaiaError>
pub fn to_clr_program(&mut self) -> Result<ClrProgram, GaiaError>
检查文件是否为 .NET 程序集
快速检查方法,无需完整解析,仅通过检查 PE 数据目录:
- 读取 PE 文件并创建视图
- 检查第 15 个数据目录(索引 14)是否为 CLR 运行时头
- 如果该目录存在且有效,则为 .NET 程序集
§参数
file_path- 要检查的 PE 文件路径
§返回
Ok(true)- 是 .NET 程序集Ok(false)- 不是 .NET 程序集Err(GaiaError)- 检查过程中的错误 完整解析为 CLR 程序
解析整个 .NET 程序集,包括所有类型、方法、字段等信息。 这是一个重量级操作,会消耗较多内存和时间。
§返回
Ok(ClrProgram)- 完整的 CLR 程序表示Err(GaiaError)- 解析过程中的错误
Sourcepub fn get_assembly_summary(&mut self) -> Result<String, GaiaError>
pub fn get_assembly_summary(&mut self) -> Result<String, GaiaError>
Trait Implementations§
Source§impl<R: Read + Seek> PeReader<R> for ExeReader<R>
impl<R: Read + Seek> PeReader<R> for ExeReader<R>
Source§fn get_viewer(&mut self) -> &mut R
fn get_viewer(&mut self) -> &mut R
获取二进制读取器的可变引用
Source§fn add_diagnostics(&mut self, error: impl Into<GaiaError>)
fn add_diagnostics(&mut self, error: impl Into<GaiaError>)
获取诊断信息的可变引用
Source§fn get_section_headers(&mut self) -> Result<&[SectionHeader], GaiaError>
fn get_section_headers(&mut self) -> Result<&[SectionHeader], GaiaError>
获取缓存的节头信息
fn get_position(&mut self) -> Result<u64, GaiaError>where
R: Seek,
fn set_position(&mut self, offset: u64) -> Result<u64, GaiaError>where
R: Seek,
Source§fn rva_to_file_offset(
&self,
rva: u32,
sections: &[PeSection],
) -> Result<u32, GaiaError>
fn rva_to_file_offset( &self, rva: u32, sections: &[PeSection], ) -> Result<u32, GaiaError>
将 RVA 转换为文件偏移(通用实现)
Source§fn parse_import_table(
&mut self,
header: &PeHeader,
sections: &[PeSection],
) -> Result<ImportTable, GaiaError>
fn parse_import_table( &mut self, header: &PeHeader, sections: &[PeSection], ) -> Result<ImportTable, GaiaError>
解析导入表(通用实现)
Source§fn parse_export_table(
&mut self,
header: &PeHeader,
sections: &[PeSection],
) -> Result<ExportTable, GaiaError>
fn parse_export_table( &mut self, header: &PeHeader, sections: &[PeSection], ) -> Result<ExportTable, GaiaError>
解析导出表(通用实现)
Auto Trait Implementations§
impl<R> Freeze for ExeReader<R>where
R: Freeze,
impl<R> !RefUnwindSafe for ExeReader<R>
impl<R> Send for ExeReader<R>where
R: Send,
impl<R> Sync for ExeReader<R>where
R: Sync,
impl<R> Unpin for ExeReader<R>where
R: Unpin,
impl<R> !UnwindSafe for ExeReader<R>
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