LCOV - code coverage report
Current view: top level - src - pe.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 26.0 % 50 13
Test Date: 2025-03-30:00:00:00 Functions: 42.9 % 7 3

            Line data    Source code
       1              : //! Module for the PE file format support in LIEF.
       2              : //!
       3              : //! The [`Binary`] structure exposes the main API to inspect a PE file. It can be instantiated,
       4              : //! using either: [`crate::pe::parse`], [`crate::pe::Binary::parse`] or [`crate::Binary::parse`]
       5              : //!
       6              : //! ```
       7              : //! let pe = lief::elf::parse("demo.exe").unwrap();
       8              : //! for section in elf.sections() {
       9              : //!     println!("section: {}", section.name());
      10              : //! }
      11              : //! ```
      12              : 
      13              : pub mod binary;
      14              : pub mod data_directory;
      15              : pub mod debug;
      16              : pub mod delay_import;
      17              : pub mod export;
      18              : pub mod headers;
      19              : pub mod import;
      20              : pub mod load_configuration;
      21              : pub mod relocation;
      22              : pub mod resources;
      23              : pub mod rich_header;
      24              : pub mod section;
      25              : pub mod signature;
      26              : pub mod tls;
      27              : pub mod code_integrity;
      28              : pub mod builder;
      29              : pub mod coff;
      30              : pub mod symbol;
      31              : pub mod exception;
      32              : pub mod exception_x64;
      33              : pub mod exception_aarch64;
      34              : pub mod chpe_metadata_arm64;
      35              : pub mod chpe_metadata_x86;
      36              : pub mod dynamic_relocation;
      37              : pub mod dynamic_fixups;
      38              : pub mod enclave_configuration;
      39              : pub mod volatile_metadata;
      40              : pub mod parser_config;
      41              : 
      42              : #[doc(inline)]
      43              : pub use binary::Binary;
      44              : #[doc(inline)]
      45              : pub use data_directory::DataDirectory;
      46              : #[doc(inline)]
      47              : pub use delay_import::DelayImport;
      48              : #[doc(inline)]
      49              : pub use export::Export;
      50              : #[doc(inline)]
      51              : pub use headers::{DosHeader, Header, OptionalHeader};
      52              : #[doc(inline)]
      53              : pub use relocation::Relocation;
      54              : #[doc(inline)]
      55              : pub use resources::Manager as ResourcesManager;
      56              : #[doc(inline)]
      57              : pub use resources::Node as ResourceNode;
      58              : #[doc(inline)]
      59              : pub use rich_header::{RichEntry, RichHeader};
      60              : #[doc(inline)]
      61              : pub use section::Section;
      62              : #[doc(inline)]
      63              : pub use tls::TLS;
      64              : #[doc(inline)]
      65              : pub use import::Import;
      66              : #[doc(inline)]
      67              : pub use signature::Signature;
      68              : #[doc(inline)]
      69              : pub use coff::String as COFFString;
      70              : #[doc(inline)]
      71              : pub use symbol::Symbol;
      72              : #[doc(inline)]
      73              : pub use exception::{RuntimeExceptionFunction, ExceptionInfo};
      74              : #[doc(inline)]
      75              : pub use load_configuration::{LoadConfiguration, CHPEMetadata};
      76              : #[doc(inline)]
      77              : pub use dynamic_relocation::DynamicRelocation;
      78              : #[doc(inline)]
      79              : pub use dynamic_fixups::DynamicFixup;
      80              : #[doc(inline)]
      81              : pub use enclave_configuration::{EnclaveConfiguration, EnclaveImport};
      82              : #[doc(inline)]
      83              : pub use volatile_metadata::VolatileMetadata;
      84              : #[doc(inline)]
      85              : pub use parser_config::Config as ParserConfig;
      86              : 
      87              : #[allow(non_camel_case_types)]
      88          820 : #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
      89              : pub enum Algorithms {
      90              :     SHA_512,
      91              :     SHA_384,
      92              :     SHA_256,
      93              :     SHA_1,
      94              :     MD5,
      95              :     MD4,
      96              :     MD2,
      97              :     RSA,
      98              :     EC,
      99              :     MD5_RSA,
     100              :     SHA1_DSA,
     101              :     SHA1_RSA,
     102              :     SHA_256_RSA,
     103              :     SHA_384_RSA,
     104              :     SHA_512_RSA,
     105              :     SHA1_ECDSA,
     106              :     SHA_256_ECDSA,
     107              :     SHA_384_ECDSA,
     108              :     SHA_512_ECDSA,
     109              :     UNKNOWN(u32),
     110              : }
     111              : 
     112              : 
     113              : impl From<u32> for Algorithms {
     114          820 :     fn from(value: u32) -> Self {
     115          820 :         match value {
     116            0 :             0x00000001 => Algorithms::SHA_512,
     117            0 :             0x00000002 => Algorithms::SHA_384,
     118          380 :             0x00000003 => Algorithms::SHA_256,
     119          160 :             0x00000004 => Algorithms::SHA_1,
     120           30 :             0x00000005 => Algorithms::MD5,
     121            0 :             0x00000006 => Algorithms::MD4,
     122            0 :             0x00000007 => Algorithms::MD2,
     123          200 :             0x00000008 => Algorithms::RSA,
     124            0 :             0x00000009 => Algorithms::EC,
     125            0 :             0x0000000a => Algorithms::MD5_RSA,
     126            0 :             0x0000000b => Algorithms::SHA1_DSA,
     127            0 :             0x0000000c => Algorithms::SHA1_RSA,
     128           50 :             0x0000000d => Algorithms::SHA_256_RSA,
     129            0 :             0x0000000e => Algorithms::SHA_384_RSA,
     130            0 :             0x0000000f => Algorithms::SHA_512_RSA,
     131            0 :             0x00000010 => Algorithms::SHA1_ECDSA,
     132            0 :             0x00000011 => Algorithms::SHA_256_ECDSA,
     133            0 :             0x00000012 => Algorithms::SHA_384_ECDSA,
     134            0 :             0x00000013 => Algorithms::SHA_512_ECDSA,
     135            0 :             _ => Algorithms::UNKNOWN(value),
     136              : 
     137              :         }
     138          820 :     }
     139              : }
     140              : 
     141              : impl From<Algorithms> for u32 {
     142          130 :     fn from(value: Algorithms) -> u32 {
     143          130 :         match value {
     144            0 :             Algorithms::SHA_512 => 0x00000001,
     145            0 :             Algorithms::SHA_384 => 0x00000002,
     146          130 :             Algorithms::SHA_256 => 0x00000003,
     147            0 :             Algorithms::SHA_1 => 0x00000004,
     148            0 :             Algorithms::MD5 => 0x00000005,
     149            0 :             Algorithms::MD4 => 0x00000006,
     150            0 :             Algorithms::MD2 => 0x00000007,
     151            0 :             Algorithms::RSA => 0x00000008,
     152            0 :             Algorithms::EC => 0x00000009,
     153            0 :             Algorithms::MD5_RSA => 0x0000000a,
     154            0 :             Algorithms::SHA1_DSA => 0x0000000b,
     155            0 :             Algorithms::SHA1_RSA => 0x0000000c,
     156            0 :             Algorithms::SHA_256_RSA => 0x0000000d,
     157            0 :             Algorithms::SHA_384_RSA => 0x0000000e,
     158            0 :             Algorithms::SHA_512_RSA => 0x0000000f,
     159            0 :             Algorithms::SHA1_ECDSA => 0x00000010,
     160            0 :             Algorithms::SHA_256_ECDSA => 0x00000011,
     161            0 :             Algorithms::SHA_384_ECDSA => 0x00000012,
     162            0 :             Algorithms::SHA_512_ECDSA => 0x00000013,
     163            0 :             Algorithms::UNKNOWN(_) => 0,
     164              : 
     165              :         }
     166          130 :     }
     167              : }
     168              : 
     169              : /// Parse a PE file from the given file path
     170            0 : pub fn parse(path: &str) -> Option<Binary> {
     171            0 :     Binary::parse(path)
     172            0 : }
        

Generated by: LCOV version 2.1-1