@@ -7,7 +7,6 @@ use goblin::pe::{
7
7
data_directories:: DataDirectory , options:: ParseOptions ,
8
8
section_table:: SectionTable ,
9
9
} ;
10
- use memmap2:: Mmap ;
11
10
use scroll:: Pread ;
12
11
use serde:: { Deserialize , Serialize } ;
13
12
use std:: fmt;
@@ -327,7 +326,7 @@ pub struct CheckSecResults {
327
326
}
328
327
impl CheckSecResults {
329
328
#[ must_use]
330
- pub fn parse ( pe : & PE , buffer : & Mmap ) -> Self {
329
+ pub fn parse ( pe : & PE , buffer : & [ u8 ] ) -> Self {
331
330
Self {
332
331
aslr : pe. has_aslr ( ) ,
333
332
authenticode : pe. has_authenticode ( buffer) ,
@@ -446,7 +445,7 @@ pub trait Properties {
446
445
/// [`memmap2::Mmap`](https://docs.rs/memmap2/0.5.7/memmap2/struct.Mmap.html)
447
446
/// of the original file to read & parse required information from the
448
447
/// underlying binary file
449
- fn has_authenticode ( & self , mem : & memmap2 :: Mmap ) -> bool ;
448
+ fn has_authenticode ( & self , bytes : & [ u8 ] ) -> bool ;
450
449
/// check for `IMAGE_DLLCHARACTERISTICS_GUARD_CF` *(0x4000)* in
451
450
/// `DllCharacteristics` within the `IMAGE_OPTIONAL_HEADER32/64`
452
451
fn has_cfg ( & self ) -> bool ;
@@ -470,7 +469,7 @@ pub trait Properties {
470
469
/// [`memmap2::Mmap`](https://docs.rs/memmap2/0.5.7/memmap2/struct.Mmap.html)
471
470
/// of the original file to read & parse required information from the
472
471
/// underlying binary file
473
- fn has_gs ( & self , mem : & memmap2 :: Mmap ) -> bool ;
472
+ fn has_gs ( & self , bytes : & [ u8 ] ) -> bool ;
474
473
/// check for `IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA` *(`0x0020`)* in
475
474
/// `DllCharacteristics` within the `IMAGE_OPTIONAL_HEADER32/64`
476
475
fn has_high_entropy_va ( & self ) -> bool ;
@@ -486,15 +485,15 @@ pub trait Properties {
486
485
/// [`memmap2::Mmap`](https://docs.rs/memmap2/0.5.7/memmap2/struct.Mmap.html)
487
486
/// of the original file to read & parse required information from the
488
487
/// underlying binary file
489
- fn has_rfg ( & self , mem : & memmap2 :: Mmap ) -> bool ;
488
+ fn has_rfg ( & self , bytes : & [ u8 ] ) -> bool ;
490
489
/// check `shandler_count` from `LOAD_CONFIG` in `IMAGE_DATA_DIRECTORY`
491
490
/// linked from the the `IMAGE_OPTIONAL_HEADER32/64`
492
491
///
493
492
/// requires a
494
493
/// [`memmap2::Mmap`](https://docs.rs/memmap2/0.5.7/memmap2/struct.Mmap.html)
495
494
/// of the original file to read and parse required information from the
496
495
/// underlying binary file
497
- fn has_safe_seh ( & self , mem : & memmap2 :: Mmap ) -> bool ;
496
+ fn has_safe_seh ( & self , bytes : & [ u8 ] ) -> bool ;
498
497
/// check `IMAGE_DLLCHARACTERISTICS_NO_SEH` from the
499
498
/// `IMAGE_OPTIONAL_HEADER32/64`
500
499
fn has_seh ( & self ) -> bool ;
@@ -508,7 +507,7 @@ impl Properties for PE<'_> {
508
507
}
509
508
ASLR :: None
510
509
}
511
- fn has_authenticode ( & self , mem : & memmap2 :: Mmap ) -> bool {
510
+ fn has_authenticode ( & self , bytes : & [ u8 ] ) -> bool {
512
511
// requires running platform to be Windows for verification
513
512
// just check for existence right now
514
513
if let Some ( optional_header) = self . header . optional_header {
@@ -518,7 +517,7 @@ impl Properties for PE<'_> {
518
517
optional_header. data_directories . get_load_config_table ( )
519
518
{
520
519
if let Ok ( load_config_val) = get_load_config_val (
521
- mem ,
520
+ bytes ,
522
521
* load_config_hdr,
523
522
sections,
524
523
file_alignment,
@@ -591,15 +590,15 @@ impl Properties for PE<'_> {
591
590
}
592
591
false
593
592
}
594
- fn has_gs ( & self , mem : & memmap2 :: Mmap ) -> bool {
593
+ fn has_gs ( & self , bytes : & [ u8 ] ) -> bool {
595
594
if let Some ( optional_header) = self . header . optional_header {
596
595
let file_alignment = optional_header. windows_fields . file_alignment ;
597
596
let sections = & self . sections ;
598
597
if let Some ( load_config_hdr) =
599
598
optional_header. data_directories . get_load_config_table ( )
600
599
{
601
600
if let Ok ( load_config_val) = get_load_config_val (
602
- mem ,
601
+ bytes ,
603
602
* load_config_hdr,
604
603
sections,
605
604
file_alignment,
@@ -632,15 +631,15 @@ impl Properties for PE<'_> {
632
631
}
633
632
false
634
633
}
635
- fn has_rfg ( & self , mem : & memmap2 :: Mmap ) -> bool {
634
+ fn has_rfg ( & self , bytes : & [ u8 ] ) -> bool {
636
635
if let Some ( optional_header) = self . header . optional_header {
637
636
let file_alignment = optional_header. windows_fields . file_alignment ;
638
637
let sections = & self . sections ;
639
638
if let Some ( load_config_hdr) =
640
639
optional_header. data_directories . get_load_config_table ( )
641
640
{
642
641
if let Ok ( load_config_val) = get_load_config_val (
643
- mem ,
642
+ bytes ,
644
643
* load_config_hdr,
645
644
sections,
646
645
file_alignment,
@@ -657,15 +656,15 @@ impl Properties for PE<'_> {
657
656
}
658
657
false
659
658
}
660
- fn has_safe_seh ( & self , mem : & memmap2 :: Mmap ) -> bool {
659
+ fn has_safe_seh ( & self , bytes : & [ u8 ] ) -> bool {
661
660
if let Some ( optional_header) = self . header . optional_header {
662
661
let file_alignment = optional_header. windows_fields . file_alignment ;
663
662
let sections = & self . sections ;
664
663
if let Some ( load_config_hdr) =
665
664
optional_header. data_directories . get_load_config_table ( )
666
665
{
667
666
if let Ok ( load_config_val) = get_load_config_val (
668
- mem ,
667
+ bytes ,
669
668
* load_config_hdr,
670
669
sections,
671
670
file_alignment,
0 commit comments