LCOV - code coverage report
Current view: top level - src/pe - parser_config.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 65.7 % 35 23
Test Date: 2026-04-12:00:00:00 Functions: 28.6 % 7 2

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : /// This structure is used to configure the behavior of the PE Parser: [`crate::pe::Binary::parse_with_config`]
       4            0 : #[derive(Debug, Clone, PartialEq, Eq, Hash)]
       5              : pub struct Config {
       6              :     /// Whether to parse the PE Authenticode signature.
       7              :     pub parse_signature: bool,
       8              : 
       9              :     /// Whether to parse the PE Export Directory.
      10              :     pub parse_exports: bool,
      11              : 
      12              :     /// Whether to parse the PE Import Directory.
      13              :     pub parse_imports: bool,
      14              : 
      15              :     /// Whether to parse the PE resources tree.
      16              :     pub parse_rsrc: bool,
      17              : 
      18              :     /// Whether to parse PE relocations.
      19              :     pub parse_reloc: bool,
      20              : 
      21              :     /// Whether to parse in-depth exception metadata.
      22              :     ///
      23              :     /// This option is disabled by default because it can introduce significant
      24              :     /// parsing overhead.
      25              :     pub parse_exceptions: bool,
      26              : 
      27              :     /// Whether to parse nested ARM64X binaries.
      28              :     ///
      29              :     /// This option is disabled by default because it can introduce significant
      30              :     /// parsing overhead.
      31              :     pub parse_arm64x_binary: bool,
      32              : }
      33              : 
      34              : impl Default for Config {
      35            0 :     fn default() -> Config {
      36            0 :         Config {
      37            0 :             parse_signature: true,
      38            0 :             parse_exports: true,
      39            0 :             parse_imports: true,
      40            0 :             parse_rsrc: true,
      41            0 :             parse_reloc: true,
      42            0 :             parse_exceptions: false,
      43            0 :             parse_arm64x_binary: false,
      44            0 :         }
      45            0 :     }
      46              : }
      47              : 
      48              : impl Config {
      49              :     #[doc(hidden)]
      50          156 :     pub fn to_ffi(&self) -> cxx::UniquePtr<ffi::PE_ParserConfig> {
      51          156 :         let mut ptr = ffi::PE_ParserConfig::create();
      52          156 :         ptr.pin_mut().set_parse_signature(self.parse_signature);
      53          156 :         ptr.pin_mut().set_parse_exports(self.parse_exports);
      54          156 :         ptr.pin_mut().set_parse_imports(self.parse_imports);
      55          156 :         ptr.pin_mut().set_parse_rsrc(self.parse_rsrc);
      56          156 :         ptr.pin_mut().set_parse_reloc(self.parse_reloc);
      57          156 :         ptr.pin_mut().set_parse_exceptions(self.parse_exceptions);
      58          156 :         ptr.pin_mut()
      59          156 :             .set_parse_arm64x_binary(self.parse_arm64x_binary);
      60          156 :         ptr
      61          156 :     }
      62              : 
      63              :     /// Configuration that enables all optional parsing features.
      64          156 :     pub fn with_all_options() -> Self {
      65          156 :         Self {
      66          156 :             parse_signature: true,
      67          156 :             parse_exports: true,
      68          156 :             parse_imports: true,
      69          156 :             parse_rsrc: true,
      70          156 :             parse_reloc: true,
      71          156 :             parse_exceptions: true,
      72          156 :             parse_arm64x_binary: true,
      73          156 :         }
      74          156 :     }
      75              : }
        

Generated by: LCOV version 2.1-1