LCOV - code coverage report
Current view: top level - src/pe - parser_config.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 64.7 % 34 22
Test Date: 2025-02-23: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 tweak the PE parser: [`lief::pe::Binary::parse_with_config`]
       4            0 : #[derive(Debug, Clone, PartialEq, Eq, Hash)]
       5              : pub struct Config {
       6              :     /// Parse PE authenticode signature
       7              :     pub parse_signature: bool,
       8              : 
       9              :     /// Parse PE Exports Directory
      10              :     pub parse_exports: bool,
      11              : 
      12              :     /// Parse PE Import Directory
      13              :     pub parse_imports: bool,
      14              : 
      15              :     /// Parse PE resources tree
      16              :     pub parse_rsrc: bool,
      17              : 
      18              :     /// Parse PE relocations
      19              :     pub parse_reloc: bool,
      20              : 
      21              :     /// Whether it should parse in-depth exceptions metadata.
      22              :     ///
      23              :     /// This option is set to off by default since it can introduce a certain
      24              :     /// overhead.
      25              :     pub parse_exceptions: bool,
      26              : 
      27              :     /// Whether it should parse nested ARM64X binary
      28              :     ///
      29              :     /// This option is set to off by default since it can introduce a certain
      30              :     /// 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          120 :     pub fn to_ffi(&self) -> cxx::UniquePtr<ffi::PE_ParserConfig> {
      51          120 :         let mut ptr = ffi::PE_ParserConfig::create();
      52          120 :         ptr.pin_mut().set_parse_signature(self.parse_signature);
      53          120 :         ptr.pin_mut().set_parse_exports(self.parse_exports);
      54          120 :         ptr.pin_mut().set_parse_imports(self.parse_imports);
      55          120 :         ptr.pin_mut().set_parse_rsrc(self.parse_rsrc);
      56          120 :         ptr.pin_mut().set_parse_reloc(self.parse_reloc);
      57          120 :         ptr.pin_mut().set_parse_exceptions(self.parse_exceptions);
      58          120 :         ptr.pin_mut().set_parse_arm64x_binary(self.parse_arm64x_binary);
      59          120 :         ptr
      60          120 :     }
      61              : 
      62              :     /// Configuration with **all** the options enabled
      63          120 :     pub fn with_all_options() -> Self {
      64          120 :         Self {
      65          120 :             parse_signature: true,
      66          120 :             parse_exports: true,
      67          120 :             parse_imports: true,
      68          120 :             parse_rsrc: true,
      69          120 :             parse_reloc: true,
      70          120 :             parse_exceptions: true,
      71          120 :             parse_arm64x_binary: true,
      72          120 :         }
      73          120 :     }
      74              : }
        

Generated by: LCOV version 2.1-1