1//! Support for reading PE files.
2//!
3//! Traits are used to abstract over the difference between PE32 and PE32+.
4//! The primary trait for this is [`ImageNtHeaders`].
5//!
6//! ## High level API
7//!
8//! [`PeFile`] implements the [`Object`](crate::read::Object) trait for
9//! PE files. [`PeFile`] is parameterised by [`ImageNtHeaders`] to allow
10//! reading both PE32 and PE32+. There are type aliases for these parameters
11//! ([`PeFile32`] and [`PeFile64`]).
12//!
13//! ## Low level API
14//!
15//! The [`ImageNtHeaders`] trait can be directly used to parse both
16//! [`pe::ImageNtHeaders32`] and [`pe::ImageNtHeaders64`].
17//!
18//! ### Example for low level API
19//! ```no_run
20//! use object::pe;
21//! use object::read::pe::ImageNtHeaders;
22//! use std::error::Error;
23//! use std::fs;
24//!
25//! /// Reads a file and displays the name of each section.
26//! fn main() -> Result<(), Box<dyn Error>> {
27//! # #[cfg(feature = "std")] {
28//! let data = fs::read("path/to/binary")?;
29//! let dos_header = pe::ImageDosHeader::parse(&*data)?;
30//! let mut offset = dos_header.nt_headers_offset().into();
31//! let (nt_headers, data_directories) = pe::ImageNtHeaders64::parse(&*data, &mut offset)?;
32//! let sections = nt_headers.sections(&*data, offset)?;
33//! let symbols = nt_headers.symbols(&*data)?;
34//! for section in sections.iter() {
35//! println!("{}", String::from_utf8_lossy(section.name(symbols.strings())?));
36//! }
37//! # }
38//! Ok(())
39//! }
40//! ```
41#[cfg(doc)]
42use crate::pe;
43
44mod file;
45pub use file::*;
46
47mod section;
48pub use section::*;
49
50mod data_directory;
51pub use data_directory::*;
52
53mod export;
54pub use export::*;
55
56mod import;
57pub use import::*;
58
59mod relocation;
60pub use relocation::*;
61
62mod resource;
63pub use resource::*;
64
65mod rich;
66pub use rich::*;
67
68pub use super::coff::{SectionTable, SymbolTable};
69