1//! Support for reading Windows COFF files.
2//!
3//! Traits are used to abstract over the difference between COFF object files
4//! and COFF bigobj files. The primary trait for this is [`CoffHeader`].
5//!
6//! ## High level API
7//!
8//! [`CoffFile`] implements the [`Object`](crate::read::Object) trait for
9//! COFF files. [`CoffFile`] is parameterised by [`CoffHeader`].
10//! The default parameter allows reading regular COFF object files,
11//! while the type alias [`CoffBigFile`] allows reading COFF bigobj files.
12//!
13//! [`ImportFile`] allows reading COFF short imports that are used in import
14//! libraries. Currently these are not integrated with the unified read API.
15//!
16//! ## Low level API
17//!
18//! The [`CoffHeader`] trait can be directly used to parse both COFF
19//! object files (which start with [`pe::ImageFileHeader`]) and COFF bigobj
20//! files (which start with [`pe::AnonObjectHeaderBigobj`]).
21//!
22//! ### Example for low level API
23//! ```no_run
24//! use object::pe;
25//! use object::read::coff::{CoffHeader, ImageSymbol as _};
26//! use std::error::Error;
27//! use std::fs;
28//!
29//! /// Reads a file and displays the name of each section and symbol.
30//! fn main() -> Result<(), Box<dyn Error>> {
31//! # #[cfg(feature = "std")] {
32//! let data = fs::read("path/to/binary")?;
33//! let mut offset = 0;
34//! let header = pe::ImageFileHeader::parse(&*data, &mut offset)?;
35//! let sections = header.sections(&*data, offset)?;
36//! let symbols = header.symbols(&*data)?;
37//! for section in sections.iter() {
38//! println!("{}", String::from_utf8_lossy(section.name(symbols.strings())?));
39//! }
40//! for (_index, symbol) in symbols.iter() {
41//! println!("{}", String::from_utf8_lossy(symbol.name(symbols.strings())?));
42//! }
43//! # }
44//! Ok(())
45//! }
46//! ```
47#[cfg(doc)]
48use crate::pe;
49
50mod file;
51pub use file::*;
52
53mod section;
54pub use section::*;
55
56mod symbol;
57pub use symbol::*;
58
59mod relocation;
60pub use relocation::*;
61
62mod comdat;
63pub use comdat::*;
64
65mod import;
66pub use import::*;
67