private OptionalHeader loadOptionalHeader ( PESignature pesig , COFFFileHeader coff , RandomAccessFile raf ) throws IOException { // offset right after the eCOFF File Header long offset = pesig . getOffset ( ) + PESignature . PE_SIG . length + COFFFileHeader . HEADER_SIZE ; logger . info ( "Optional Header offset: " + offset ) ; // set the maximum size for the bytes to read int size = getOptHeaderSize ( offset ) ; // read bytes and construct header byte [ ] headerbytes = loadBytesSafely ( offset , size , raf ) ; return OptionalHeader . newInstance ( headerbytes , offset ) ; }
Loads the optional header . Presumes a valid PE file .