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: 2024-11-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              : 
      29              : #[doc(inline)]
      30              : pub use binary::Binary;
      31              : #[doc(inline)]
      32              : pub use data_directory::DataDirectory;
      33              : #[doc(inline)]
      34              : pub use delay_import::DelayImport;
      35              : #[doc(inline)]
      36              : pub use export::Export;
      37              : #[doc(inline)]
      38              : pub use headers::{DosHeader, Header, OptionalHeader};
      39              : #[doc(inline)]
      40              : pub use relocation::Relocation;
      41              : #[doc(inline)]
      42              : pub use resources::Manager as ResourcesManager;
      43              : #[doc(inline)]
      44              : pub use resources::Node as ResourceNode;
      45              : #[doc(inline)]
      46              : pub use rich_header::{RichEntry, RichHeader};
      47              : #[doc(inline)]
      48              : pub use section::Section;
      49              : #[doc(inline)]
      50              : pub use tls::TLS;
      51              : #[doc(inline)]
      52              : pub use import::Import;
      53              : #[doc(inline)]
      54              : pub use signature::Signature;
      55              : 
      56              : #[allow(non_camel_case_types)]
      57          640 : #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
      58              : pub enum Algorithms {
      59              :     SHA_512,
      60              :     SHA_384,
      61              :     SHA_256,
      62              :     SHA_1,
      63              :     MD5,
      64              :     MD4,
      65              :     MD2,
      66              :     RSA,
      67              :     EC,
      68              :     MD5_RSA,
      69              :     SHA1_DSA,
      70              :     SHA1_RSA,
      71              :     SHA_256_RSA,
      72              :     SHA_384_RSA,
      73              :     SHA_512_RSA,
      74              :     SHA1_ECDSA,
      75              :     SHA_256_ECDSA,
      76              :     SHA_384_ECDSA,
      77              :     SHA_512_ECDSA,
      78              :     UNKNOWN(u32),
      79              : }
      80              : 
      81              : 
      82              : impl From<u32> for Algorithms {
      83          640 :     fn from(value: u32) -> Self {
      84          640 :         match value {
      85            0 :             0x00000001 => Algorithms::SHA_512,
      86            0 :             0x00000002 => Algorithms::SHA_384,
      87          260 :             0x00000003 => Algorithms::SHA_256,
      88          160 :             0x00000004 => Algorithms::SHA_1,
      89           30 :             0x00000005 => Algorithms::MD5,
      90            0 :             0x00000006 => Algorithms::MD4,
      91            0 :             0x00000007 => Algorithms::MD2,
      92          170 :             0x00000008 => Algorithms::RSA,
      93            0 :             0x00000009 => Algorithms::EC,
      94            0 :             0x0000000a => Algorithms::MD5_RSA,
      95            0 :             0x0000000b => Algorithms::SHA1_DSA,
      96            0 :             0x0000000c => Algorithms::SHA1_RSA,
      97           20 :             0x0000000d => Algorithms::SHA_256_RSA,
      98            0 :             0x0000000e => Algorithms::SHA_384_RSA,
      99            0 :             0x0000000f => Algorithms::SHA_512_RSA,
     100            0 :             0x00000010 => Algorithms::SHA1_ECDSA,
     101            0 :             0x00000011 => Algorithms::SHA_256_ECDSA,
     102            0 :             0x00000012 => Algorithms::SHA_384_ECDSA,
     103            0 :             0x00000013 => Algorithms::SHA_512_ECDSA,
     104            0 :             _ => Algorithms::UNKNOWN(value),
     105              : 
     106              :         }
     107          640 :     }
     108              : }
     109              : 
     110              : impl From<Algorithms> for u32 {
     111           80 :     fn from(value: Algorithms) -> u32 {
     112           80 :         match value {
     113            0 :             Algorithms::SHA_512 => 0x00000001,
     114            0 :             Algorithms::SHA_384 => 0x00000002,
     115           80 :             Algorithms::SHA_256 => 0x00000003,
     116            0 :             Algorithms::SHA_1 => 0x00000004,
     117            0 :             Algorithms::MD5 => 0x00000005,
     118            0 :             Algorithms::MD4 => 0x00000006,
     119            0 :             Algorithms::MD2 => 0x00000007,
     120            0 :             Algorithms::RSA => 0x00000008,
     121            0 :             Algorithms::EC => 0x00000009,
     122            0 :             Algorithms::MD5_RSA => 0x0000000a,
     123            0 :             Algorithms::SHA1_DSA => 0x0000000b,
     124            0 :             Algorithms::SHA1_RSA => 0x0000000c,
     125            0 :             Algorithms::SHA_256_RSA => 0x0000000d,
     126            0 :             Algorithms::SHA_384_RSA => 0x0000000e,
     127            0 :             Algorithms::SHA_512_RSA => 0x0000000f,
     128            0 :             Algorithms::SHA1_ECDSA => 0x00000010,
     129            0 :             Algorithms::SHA_256_ECDSA => 0x00000011,
     130            0 :             Algorithms::SHA_384_ECDSA => 0x00000012,
     131            0 :             Algorithms::SHA_512_ECDSA => 0x00000013,
     132            0 :             Algorithms::UNKNOWN(_) => 0,
     133              : 
     134              :         }
     135           80 :     }
     136              : }
     137              : 
     138              : /// Parse a PE file from the given file path
     139            0 : pub fn parse(path: &str) -> Option<Binary> {
     140            0 :     Binary::parse(path)
     141            0 : }
        

Generated by: LCOV version 2.1-1