Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

htnewexe.cc

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htnewexe.cc
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #include "htnewexe.h"
00022 
00023 #include "mzstruct.h"
00024 #include "htendian.h"
00025 
00026 FILEOFS get_newexe_header_ofs(ht_streamfile *file)
00027 {
00028         /* look for mz magic */
00029         byte mzmagic[2];
00030         file->seek(0);
00031         file->read(mzmagic, 2);
00032         if ((mzmagic[0] != IMAGE_MZ_MAGIC0) || (mzmagic[1] != IMAGE_MZ_MAGIC1))
00033                 return 0;
00034         /* test if reloc_ofs >= 0x40 */
00035         word reloc_ofs;
00036         file->seek(24);
00037         file->read(&reloc_ofs, 2);
00038         reloc_ofs = create_host_int(&reloc_ofs, 2, little_endian);
00039         if (reloc_ofs && reloc_ofs < 0x40) return 0;
00040         /* ok seems to be a newexe */
00041         FILEOFS newexe_ofs;
00042         file->seek(60);
00043         file->read(&newexe_ofs, 4);
00044         newexe_ofs = create_host_int(&newexe_ofs, 4, little_endian);
00045         return newexe_ofs;
00046 }

Generated on Fri May 7 21:15:35 2004 by doxygen 1.3.5