00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }