Skip to content

Commit

Permalink
pe.header: added ability to parse part of pe header without dos
Browse files Browse the repository at this point in the history
  • Loading branch information
ideeockus committed Jul 7, 2024
1 parent 06cf965 commit 43278d5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pe/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,15 @@ pub struct Header {
}

impl Header {
/// Parses PE header from the given bytes, use default DosHeader if missed
pub fn parse(bytes: &[u8]) -> error::Result<Self> {
let dos_header = DosHeader::parse(&bytes)?;
let dos_header = DosHeader::parse(&bytes).unwrap_or_default();
let dos_stub = bytes.pread(DOS_STUB_OFFSET as usize).map_err(|_| {
error::Error::Malformed(format!(
"cannot parse DOS stub (offset {:#x})",
DOS_STUB_OFFSET
))
})?;
}).unwrap_or_default();
let mut offset = dos_header.pe_pointer as usize;
let signature = bytes.gread_with(&mut offset, scroll::LE).map_err(|_| {
error::Error::Malformed(format!("cannot parse PE signature (offset {:#x})", offset))
Expand Down

0 comments on commit 43278d5

Please sign in to comment.