Skip to main content

DllReader

Struct DllReader 

Source
pub struct DllReader<'config, R> { /* private fields */ }

Implementations§

Source§

impl<'config, R> DllReader<'config, R>

Source

pub fn new(reader: R, options: &'config DllReadConfig) -> Self

使用泛型 PE 读取器构造 .NET 读取器(DLL)

注意:这是惰性构造函数,不会立即执行解析工作流程

Source§

impl<'config, R> DllReader<'config, R>
where R: Read + Seek,

Source

pub fn get_assembly_info(&mut self) -> Result<DotNetAssemblyInfo, GaiaError>

从文件读取 .NET 程序集

该方法读取并解析 .NET 程序集文件,步骤如下:

  1. 将整个文件读入内存
  2. 创建 PE 视图以访问 PE 结构
  3. 创建读取器实例
  4. 执行解析工作流程
§参数
  • 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) - 读取过程中的错误
Source

pub fn to_clr_program(&mut self) -> Result<ClrProgram, GaiaError>

完整解析为 CLR 程序

解析整个 .NET 程序集,包括所有类型、方法、字段等信息。 这是一个重量级操作,会消耗较多内存和时间。

§返回
  • Ok(ClrProgram) - 完整的 CLR 程序表示
  • Err(GaiaError) - 解析过程中的错误
Source

pub fn validate_assembly(&mut self) -> Result<Vec<String>, GaiaError>

验证程序集完整性

检查解析后的 .NET 程序集是否包含所有必需的组件:

  • CLR 头:包含运行时信息
  • 元数据头:描述类型系统
  • 元数据流:包含实际的元数据
§返回
  • Ok(Vec<String>) - 警告信息列表,空列表表示验证通过
  • Err(GaiaError) - 验证过程中的错误
Source

pub fn get_assembly_summary(&mut self) -> String

获取程序集摘要信息

以友好的格式返回程序集的基本信息,适合用于显示或日志记录。 如果程序集信息不可用,返回相应的错误消息。

§返回
  • String - 格式化的程序集信息,包含名称、版本、文化、公钥标记和运行时版本

Trait Implementations§

Source§

impl<'config, R: Debug> Debug for DllReader<'config, R>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'config, R: Read + Seek> PeReader<R> for DllReader<'config, R>

Source§

fn get_viewer(&mut self) -> &mut R

获取二进制读取器的可变引用
Source§

fn add_diagnostics(&mut self, error: impl Into<GaiaError>)

获取诊断信息的可变引用
Source§

fn get_section_headers(&mut self) -> Result<&[SectionHeader], GaiaError>

获取缓存的节头信息
Source§

fn get_pe_header(&mut self) -> Result<&PeHeader, GaiaError>

读取 PE 头部信息(通用实现)
Source§

fn get_program(&mut self) -> Result<&PeProgram, GaiaError>

强制读取完整的 PeProgram,并缓存结果
Source§

fn get_position(&mut self) -> Result<u64, GaiaError>
where R: Seek,

Source§

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>

将 RVA 转换为文件偏移(通用实现)
Source§

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>

解析导出表(通用实现)
Source§

fn create_pe_info(&mut self) -> Result<PeInfo, GaiaError>

创建 PE 信息视图(通用实现)

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,