/// Find the optional header and read the `optional_header.magic`.
Find the optional header and read the `optional_header.magic`.
Find the optional header and read the ` optional_header . magic ` .
pub fn optional_header_magic(data: &'data [u8]) -> Result<u16> {
        let data = Bytes(data);
        let dos_header = pe::ImageDosHeader::parse(data)?;
        // NT headers are at an offset specified in the DOS header.
        let nt_headers = data
            .read_at::<Pe>(dos_header.e_lfanew.get(LE) as usize)
            .read_error("Invalid NT headers offset, size, or alignment")?;
        if nt_headers.signature() != pe::IMAGE_NT_SIGNATURE {
            return Err(Error("Invalid PE magic"));
        }
        Ok(nt_headers.optional_header().magic())
    }
pub fn optional_header_magic ( data : & ' data [ u8 ] ) -> Result < u16 > { let data = Bytes ( data ) ; let dos_header = pe :: ImageDosHeader :: parse ( data ) ? ; // NT headers are at an offset specified in the DOS header. let nt_headers = data . read_at :: < Pe > ( dos_header . e_lfanew . get ( LE ) as usize ) . read_error ( " " ) ? ; if nt_headers . signature ( ) != pe :: IMAGE_NT_SIGNATURE { return Err ( Error ( " " ) ) ; } Ok ( nt_headers . optional_header ( ) . magic ( ) ) }
Find the optional header and read the `optional_header.magic`.
Find the optional header and read the ` optional_header . magic ` .
data
&'data [u8]