LCOV - code coverage report
Current view: top level - src/pe - builder.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 0.0 % 38 0
Test Date: 2025-02-23:00:00:00 Functions: 0.0 % 6 0

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : /// Structure used to configure the [`crate::pe::Binary::write_with_config`] operation
       4              : ///
       5              : /// The default value of these attributes is set to `false` if the
       6              : /// operation modifies the binary layout even though nothing changed.
       7              : /// For instance, building the import table **always** requires relocating the
       8              : /// table to another place. Thus, the default value is false and must
       9              : /// be explicitly set to true.
      10            0 : #[derive(Debug, Clone, PartialEq, Eq, Hash)]
      11              : pub struct Config {
      12              :     /// Whether the builder should reconstruct the imports table. This option should be turned on
      13              :     /// if you modify imports.
      14              :     ///
      15              :     /// Please check LIEF website for more details
      16              :     pub imports: bool,
      17              : 
      18              :     /// Whether the builder should reconstruct the export table This option should be turned on if
      19              :     /// you modify exports.
      20              :     ///
      21              :     /// Please check LIEF website for more details
      22              :     pub exports: bool,
      23              : 
      24              :     /// Whether the builder should regenerate the resources tree
      25              :     pub resources: bool,
      26              : 
      27              :     /// Whether the builder should regenerate relocations
      28              :     pub relocations: bool,
      29              : 
      30              :     /// Whether the builder should regenerate the load config
      31              :     pub load_configuration: bool,
      32              : 
      33              :     /// Whether the builder should regenerate the TLS info
      34              :     pub tls: bool,
      35              : 
      36              :     /// Whether the builder should write back any overlay data
      37              :     pub overlay: bool,
      38              : 
      39              :     /// Whether the builder should regenerate debug entries
      40              :     pub debug: bool,
      41              : 
      42              :     /// Whether the builder should write back dos stub (including the rich
      43              :     /// header)
      44              :     pub dos_stub: bool,
      45              : 
      46              :     /// If the resources tree needs to be relocated, this defines the name of
      47              :     /// the new section that contains the relocated tree.
      48              :     pub rsrc_section: String,
      49              : 
      50              :     /// Section that holds the relocated import table (IAT/ILT)
      51              :     pub idata_section: String,
      52              : 
      53              :     /// Section that holds the relocated TLS info
      54              :     pub tls_section: String,
      55              : 
      56              :     /// Section that holds the relocated relocations
      57              :     pub reloc_section: String,
      58              : 
      59              :     /// Section that holds the export table
      60              :     pub export_section: String,
      61              : 
      62              :     /// Section that holds the debug entries
      63              :     pub debug_section: String,
      64              : }
      65              : 
      66              : impl Default for Config {
      67            0 :     fn default() -> Config {
      68            0 :         Config {
      69            0 :             imports: false,
      70            0 :             exports: false,
      71            0 :             resources: true,
      72            0 :             relocations: true,
      73            0 :             load_configuration: true,
      74            0 :             tls: true,
      75            0 :             overlay: true,
      76            0 :             debug: true,
      77            0 :             dos_stub: true,
      78            0 :             rsrc_section: ".rsrc".to_string(),
      79            0 :             idata_section: ".idata".to_string(),
      80            0 :             tls_section: ".tls".to_string(),
      81            0 :             reloc_section: ".reloc".to_string(),
      82            0 :             export_section: ".edata".to_string(),
      83            0 :             debug_section: ".debug".to_string(),
      84            0 :         }
      85            0 :     }
      86              : }
      87              : 
      88              : impl Config {
      89              :     #[doc(hidden)]
      90            0 :     pub fn to_ffi(&self) -> cxx::UniquePtr<ffi::PE_Binary_write_config_t> {
      91            0 :         let mut ptr = ffi::PE_Binary_write_config_t::create();
      92            0 :         ptr.pin_mut().set_import(self.imports);
      93            0 :         ptr.pin_mut().set_exports(self.exports);
      94            0 :         ptr.pin_mut().set_resources(self.resources);
      95            0 :         ptr.pin_mut().set_relocations(self.relocations);
      96            0 :         ptr.pin_mut().set_load_config(self.load_configuration);
      97            0 :         ptr.pin_mut().set_tls(self.tls);
      98            0 :         ptr.pin_mut().set_overlay(self.overlay);
      99            0 :         ptr.pin_mut().set_dos_stub(self.dos_stub);
     100            0 :         ptr.pin_mut().set_rsrc_section(&self.rsrc_section);
     101            0 :         ptr.pin_mut().set_idata_section(&self.idata_section);
     102            0 :         ptr.pin_mut().set_tls_section(&self.tls_section);
     103            0 :         ptr.pin_mut().set_reloc_section(&self.reloc_section);
     104            0 :         ptr.pin_mut().set_export_section(&self.export_section);
     105            0 :         ptr.pin_mut().set_debug_section(&self.debug_section);
     106            0 :         ptr
     107            0 :     }
     108              : }
        

Generated by: LCOV version 2.1-1