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

htmzrel.cc

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htmzrel.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 "htmz.h"
00022 #include "htmzrel.h"
00023 #include "htpal.h"
00024 #include "httag.h"
00025 #include "formats.h"
00026 #include "snprintf.h"
00027 
00028 static int htmzrel_detect(ht_streamfile *file)
00029 {
00030         word rcount;
00031         file->seek(6);
00032         file->read(&rcount, 2);
00033         return rcount;
00034 }
00035 
00036 static ht_view *htmzrel_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00037 {
00038         ht_uformat_viewer *v=new ht_uformat_viewer();
00039         v->init(b, DESC_MZ_REL, VC_EDIT | VC_SEARCH, file, group);
00040         dword r=0;
00041         dword rc=0;
00042         file->seek(6);
00043         file->read(&rc, 2);
00044         file->seek(24);
00045         file->read(&r, 2);
00046         char buf[256];
00047 
00048         ht_mask_sub *m=new ht_mask_sub();
00049         m->init(file, 0);
00050         char info[128];
00051         ht_snprintf(info, sizeof info, "* MZ relocations at offset %08x", r);
00052         m->add_mask(info);
00053         for (int i=rc; i>0; i--) {
00054                 int so;
00055                 file->seek(r);
00056                 file->read(&so, 4);
00057                 char *b=tag_make_edit_word(buf, r+2, tag_endian_little);
00058                 *(b++)=':';
00059                 b=tag_make_edit_word(b, r, tag_endian_little);
00060                 *b=0;
00061                 m->add_mask(buf);
00062                 r+=4;
00063         }
00064         v->insertsub(m);
00065         return v;
00066 }

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