pub struct DllReader<'config, R> { /* private fields */ }Implementations§
Source§impl<'config, R> DllReader<'config, R>
impl<'config, R> DllReader<'config, R>
Sourcepub fn new(reader: R, options: &'config DllReadConfig) -> Self
pub fn new(reader: R, options: &'config DllReadConfig) -> Self
使用泛型 PE 读取器构造 .NET 读取器(DLL)
注意:这是惰性构造函数,不会立即执行解析工作流程
Source§impl<'config, R> DllReader<'config, R>
impl<'config, R> DllReader<'config, R>
Sourcepub fn get_assembly_info(&mut self) -> Result<DotNetAssemblyInfo, GaiaError>
pub fn get_assembly_info(&mut self) -> Result<DotNetAssemblyInfo, GaiaError>
从文件读取 .NET 程序集
该方法读取并解析 .NET 程序集文件,步骤如下:
- 将整个文件读入内存
- 创建 PE 视图以访问 PE 结构
- 创建读取器实例
- 执行解析工作流程
§参数
file_path- .NET 程序集文件路径
§返回
Ok(DotNetReader)- 成功解析的读取器Err(GaiaError)- 读取或解析过程中的错误 检查文件是否为 .NET 程序集
快速检查方法,无需完整解析,仅通过检查 PE 数据目录:
- 读取 PE 文件并创建视图
- 检查第 15 个数据目录(索引 14)是否为 CLR 运行时头
- 如果该目录存在且有效,则为 .NET 程序集
§参数
file_path- 要检查的 PE 文件路径
§返回
Ok(true)- 是 .NET 程序集Ok(false)- 不是 .NET 程序集Err(GaiaError)- 检查过程中的错误 惰性读取程序集基本信息
仅读取程序集的基本标识信息,不解析完整的类型系统。 适用于快速获取程序集名称、版本等信息的场景。
§返回
Ok(DotNetAssemblyInfo)- 程序集基本信息Err(GaiaError)- 读取过程中的错误
Sourcepub fn to_clr_program(&mut self) -> Result<ClrProgram, GaiaError>
pub fn to_clr_program(&mut self) -> Result<ClrProgram, GaiaError>
完整解析为 CLR 程序
解析整个 .NET 程序集,包括所有类型、方法、字段等信息。 这是一个重量级操作,会消耗较多内存和时间。
§返回
Ok(ClrProgram)- 完整的 CLR 程序表示Err(GaiaError)- 解析过程中的错误
Sourcepub fn validate_assembly(&mut self) -> Result<Vec<String>, GaiaError>
pub fn validate_assembly(&mut self) -> Result<Vec<String>, GaiaError>
验证程序集完整性
检查解析后的 .NET 程序集是否包含所有必需的组件:
- CLR 头:包含运行时信息
- 元数据头:描述类型系统
- 元数据流:包含实际的元数据
§返回
Ok(Vec<String>)- 警告信息列表,空列表表示验证通过Err(GaiaError)- 验证过程中的错误
Sourcepub fn get_assembly_summary(&mut self) -> String
pub fn get_assembly_summary(&mut self) -> String
获取程序集摘要信息
以友好的格式返回程序集的基本信息,适合用于显示或日志记录。 如果程序集信息不可用,返回相应的错误消息。
§返回
String- 格式化的程序集信息,包含名称、版本、文化、公钥标记和运行时版本
Trait Implementations§
Source§impl<'config, R: Read + Seek> PeReader<R> for DllReader<'config, R>
impl<'config, R: Read + Seek> PeReader<R> for DllReader<'config, 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<'config, R> Freeze for DllReader<'config, R>where
R: Freeze,
impl<'config, R> !RefUnwindSafe for DllReader<'config, R>
impl<'config, R> Send for DllReader<'config, R>where
R: Send,
impl<'config, R> Sync for DllReader<'config, R>where
R: Sync,
impl<'config, R> Unpin for DllReader<'config, R>where
R: Unpin,
impl<'config, R> !UnwindSafe for DllReader<'config, 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