Line data Source code
1 : //! Module for the COFF file format support in LIEF.
2 : //!
3 : //! The [`Binary`] structure exposes the main API to inspect a COFF file. It can be instantiated,
4 : //! using either: [`crate::coff::parse`], [`crate::coff::Binary::parse`] or [`crate::Binary::parse`]
5 : //!
6 : //! ```
7 : //! let coff = lief::coff::parse("demo.obj").unwrap();
8 : //! for section in coff.sections() {
9 : //! println!("section: {}", section.name());
10 : //! }
11 : //! ```
12 :
13 : use std::path::Path;
14 :
15 : pub mod string;
16 : pub mod symbol;
17 : pub mod binary;
18 : pub mod header;
19 : pub mod section;
20 : pub mod relocation;
21 :
22 : #[doc(inline)]
23 : pub use symbol::Symbol;
24 :
25 : #[doc(inline)]
26 : pub use string::String;
27 :
28 : #[doc(inline)]
29 : pub use binary::Binary;
30 :
31 : #[doc(inline)]
32 : pub use section::Section;
33 :
34 : #[doc(inline)]
35 : pub use relocation::Relocation;
36 :
37 : #[doc(inline)]
38 : pub use header::{Header, RegularHeader, BigObjHeader};
39 :
40 : /// Parse a COFF file from the given file path
41 0 : pub fn parse<P: AsRef<Path>>(path: P) -> Option<Binary> {
42 0 : Binary::parse(path)
43 0 : }
44 :
45 0 : pub fn is_coff<P: AsRef<Path>>(path: P) -> bool {
46 0 : lief_ffi::COFF_Utils::is_coff(path.as_ref().to_str().unwrap())
47 0 : }
|