Expand description
Support for reading PE files.
Traits are used to abstract over the difference between PE32 and PE32+.
The primary trait for this is ImageNtHeaders.
§High level API
PeFile implements the Object trait for
PE files. PeFile is parameterised by ImageNtHeaders to allow
reading both PE32 and PE32+. There are type aliases for these parameters
(PeFile32 and PeFile64).
§Low level API
The ImageNtHeaders trait can be directly used to parse both
pe::ImageNtHeaders32 and pe::ImageNtHeaders64.
§Example for low level API
use object::pe;
use object::read::pe::ImageNtHeaders;
use std::error::Error;
use std::fs;
/// Reads a file and displays the name of each section.
fn main() -> Result<(), Box<dyn Error>> {
let data = fs::read("path/to/binary")?;
let dos_header = pe::ImageDosHeader::parse(&*data)?;
let mut offset = dos_header.nt_headers_offset().into();
let (nt_headers, data_directories) = pe::ImageNtHeaders64::parse(&*data, &mut offset)?;
let sections = nt_headers.sections(&*data, offset)?;
let symbols = nt_headers.symbols(&*data)?;
for section in sections.iter() {
println!("{}", String::from_utf8_lossy(section.name(symbols.strings())?));
}
Ok(())
}Re-exports§
pub use super::coff::SectionTable;pub use super::coff::SymbolTable;
Structs§
- Data
Directories - The table of data directories in a PE file.
- Delay
Load Descriptor Iterator - A fallible iterator for the descriptors in the delay-load data directory.
- Delay
Load Import Table - Information for parsing a PE delay-load import table.
- Export
- An export from a PE file.
- Export
Table - A partially parsed PE export table.
- Import
Descriptor Iterator - A fallible iterator for the descriptors in the import data directory.
- Import
Table - Information for parsing a PE import table.
- Import
Thunk List - A list of import thunks.
- PeComdat
- A COMDAT section group in a
PeFile. - PeComdat
Iterator - An iterator for the COMDAT section groups in a
PeFile. - PeComdat
Section Iterator - An iterator for the sections in a COMDAT section group in a
PeFile. - PeFile
- A PE image file.
- PeRelocation
Iterator - An iterator for the relocations in an
PeSection. - PeSection
- A section in a
PeFile. - PeSection
Iterator - An iterator for the sections in a
PeFile. - PeSegment
- A loadable section in a
PeFile. - PeSegment
Iterator - An iterator for the loadable sections in a
PeFile. - Relocation
- A relocation in the
.relocsection of a PE file. - Relocation
Block Iterator - An iterator over the relocation blocks in the
.relocsection of a PE file. - Relocation
Iterator - An iterator of the relocations in a block in the
.relocsection of a PE file. - Resource
Directory - The
.rsrcsection of a PE file. - Resource
Directory Table - A table of resource entries.
- Resource
Name - A resource name.
- Rich
Header Entry - A PE rich header entry after it has been unmasked.
- Rich
Header Info - Parsed information about a Rich Header.
Enums§
- Export
Target - Where an export is pointing to.
- Import
- A parsed import thunk.
- Resource
Directory Entry Data - Data associated with a resource directory entry.
- Resource
Name OrId - A resource name or ID.
Traits§
- Image
NtHeaders - A trait for generic access to
pe::ImageNtHeaders32andpe::ImageNtHeaders64. - Image
Optional Header - A trait for generic access to
pe::ImageOptionalHeader32andpe::ImageOptionalHeader64. - Image
Thunk Data - A trait for generic access to
pe::ImageThunkData32andpe::ImageThunkData64.
Functions§
- optional_
header_ magic - Find the optional header and read its
magicfield.
Type Aliases§
- PeComdat32
- A COMDAT section group in a
PeFile32. - PeComdat64
- A COMDAT section group in a
PeFile64. - PeComdat
Iterator32 - An iterator for the COMDAT section groups in a
PeFile32. - PeComdat
Iterator64 - An iterator for the COMDAT section groups in a
PeFile64. - PeComdat
Section Iterator32 - An iterator for the sections in a COMDAT section group in a
PeFile32. - PeComdat
Section Iterator64 - An iterator for the sections in a COMDAT section group in a
PeFile64. - PeFile32
- A PE32 (32-bit) image file.
- PeFile64
- A PE32+ (64-bit) image file.
- PeSection32
- A section in a
PeFile32. - PeSection64
- A section in a
PeFile64. - PeSection
Iterator32 - An iterator for the sections in a
PeFile32. - PeSection
Iterator64 - An iterator for the sections in a
PeFile64. - PeSegment32
- A loadable section in a
PeFile32. - PeSegment64
- A loadable section in a
PeFile64. - PeSegment
Iterator32 - An iterator for the loadable sections in a
PeFile32. - PeSegment
Iterator64 - An iterator for the loadable sections in a
PeFile64.