1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include "htnewexe.h"
#include "mzstruct.h"
#include "endianess.h"
FileOfs get_newexe_header_ofs(File *file)
{
byte mzmagic[2];
file->seek(0);
file->read(mzmagic, 2);
if ((mzmagic[0] != IMAGE_MZ_MAGIC0) || (mzmagic[1] != IMAGE_MZ_MAGIC1))
return 0;
uint16 reloc_ofs;
file->seek(24);
file->read(&reloc_ofs, 2);
reloc_ofs = createHostInt(&reloc_ofs, 2, little_endian);
if (reloc_ofs && reloc_ofs < 0x40) return 0;
FileOfs newexe_ofs;
file->seek(60);
file->read(&newexe_ofs, 4);
newexe_ofs = createHostInt(&newexe_ofs, 4, little_endian);
return newexe_ofs;
}
|