Skip to main content

PeReader

Trait PeReader 

Source
pub trait PeReader<R: Read + Seek> {
    // Required methods
    fn get_viewer(&mut self) -> &mut R;
    fn add_diagnostics(&mut self, error: impl Into<GaiaError>);
    fn get_section_headers(&mut self) -> Result<&[SectionHeader], GaiaError>;
    fn get_pe_header(&mut self) -> Result<&PeHeader, GaiaError>;
    fn get_program(&mut self) -> Result<&PeProgram, GaiaError>;

    // Provided methods
    fn get_position(&mut self) -> Result<u64, GaiaError>
       where R: Seek { ... }
    fn set_position(&mut self, offset: u64) -> Result<u64, GaiaError>
       where R: Seek { ... }
    fn rva_to_file_offset(
        &self,
        rva: u32,
        sections: &[PeSection],
    ) -> Result<u32, GaiaError> { ... }
    fn parse_import_table(
        &mut self,
        header: &PeHeader,
        sections: &[PeSection],
    ) -> Result<ImportTable, GaiaError> { ... }
    fn parse_export_table(
        &mut self,
        header: &PeHeader,
        sections: &[PeSection],
    ) -> Result<ExportTable, GaiaError> { ... }
    fn create_pe_info(&mut self) -> Result<PeInfo, GaiaError> { ... }
}
Expand description

Common trait for PE file readers

Required Methods§

Source

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

Get a mutable reference to the binary reader

Source

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

Get a mutable reference to diagnostics information

Source

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

Get cached section headers

Source

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

Read PE header information (generic implementation)

Source

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

Force read full PeProgram and cache the result

Provided Methods§

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>

Convert RVA to file offset (generic implementation)

Source

fn parse_import_table( &mut self, header: &PeHeader, sections: &[PeSection], ) -> Result<ImportTable, GaiaError>

Parse import table (generic implementation)

Source

fn parse_export_table( &mut self, header: &PeHeader, sections: &[PeSection], ) -> Result<ExportTable, GaiaError>

Parse export table (generic implementation)

Source

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

Create PE info view (generic implementation)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<R: Read + Seek> PeReader<R> for DllReader<R>

Source§

impl<R: Read + Seek> PeReader<R> for ExeReader<R>