Expand description
Support for reading Windows COFF files.
Traits are used to abstract over the difference between COFF object files
and COFF bigobj files. The primary trait for this is CoffHeader
.
§High level API
CoffFile
implements the Object
trait for
COFF files. CoffFile
is parameterised by CoffHeader
.
The default parameter allows reading regular COFF object files,
while the type alias CoffBigFile
allows reading COFF bigobj files.
ImportFile
allows reading COFF short imports that are used in import
libraries. Currently these are not integrated with the unified read API.
§Low level API
The CoffHeader
trait can be directly used to parse both COFF
object files (which start with pe::ImageFileHeader
) and COFF bigobj
files (which start with pe::AnonObjectHeaderBigobj
).
§Example for low level API
use object::pe;
use object::read::coff::{CoffHeader, ImageSymbol as _};
use std::error::Error;
use std::fs;
/// Reads a file and displays the name of each section and symbol.
fn main() -> Result<(), Box<dyn Error>> {
let data = fs::read("path/to/binary")?;
let mut offset = 0;
let header = pe::ImageFileHeader::parse(&*data, &mut offset)?;
let sections = header.sections(&*data, offset)?;
let symbols = header.symbols(&*data)?;
for section in sections.iter() {
println!("{}", String::from_utf8_lossy(section.name(symbols.strings())?));
}
for (_index, symbol) in symbols.iter() {
println!("{}", String::from_utf8_lossy(symbol.name(symbols.strings())?));
}
Ok(())
}
Structs§
- A COMDAT section group in a
CoffFile
. - An iterator for the COMDAT section groups in a
CoffFile
. - An iterator for the sections in a COMDAT section group in a
CoffFile
. - A COFF object file.
- An iterator for the relocations in a
CoffSection
. - A section in a
CoffFile
. - An iterator for the sections in a
CoffFile
. - A loadable section in a
CoffFile
. - An iterator for the loadable sections in a
CoffFile
. - A Windows short form description of a symbol to import.
- The data following
pe::ImportObjectHeader
. - The table of section headers in a COFF or PE file.
- An iterator for symbol entries in a COFF or PE file.
- A table of symbol entries in a COFF or PE file.
Enums§
- The name or ordinal to import from a DLL.
- The kind of import symbol.
Traits§
- A trait for generic access to
pe::ImageFileHeader
andpe::AnonObjectHeaderBigobj
. - A trait for generic access to
pe::ImageSymbol
andpe::ImageSymbolEx
.
Functions§
- Read the
class_id
field from ape::AnonObjectHeader
.
Type Aliases§
- A COMDAT section group in a
CoffBigFile
. - An iterator for the COMDAT section groups in a
CoffBigFile
. - An iterator for the sections in a COMDAT section group in a
CoffBigFile
. - A COFF bigobj object file with 32-bit section numbers.
- An iterator for the relocations in a
CoffBigSection
. - A section in a
CoffBigFile
. - An iterator for the sections in a
CoffBigFile
. - A loadable section in a
CoffBigFile
. - An iterator for the loadable sections in a
CoffBigFile
. - A symbol in a
CoffBigFile
. - An iterator for the symbols in a
CoffBigFile
. - A symbol table in a
CoffBigFile
.