00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "htdisasm.h"
00022 #include "htmz.h"
00023 #include "htmzimg.h"
00024 #include "htpal.h"
00025 #include "htstring.h"
00026 #include "htformat.h"
00027 #include "formats.h"
00028 #include "snprintf.h"
00029 #include "x86asm.h"
00030 #include "x86dis.h"
00031
00032 static ht_view *htmzimage_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00033 {
00034 ht_mz_shared_data *mz_shared=(ht_mz_shared_data *)group->get_shared_data();
00035
00036 x86asm *assembler=new x86asm(X86_OPSIZE16, X86_ADDRSIZE16);
00037 x86dis *disassembler=new x86dis(X86_OPSIZE16, X86_ADDRSIZE16);
00038
00039 dword o=mz_shared->header.header_size*16;
00040 ht_disasm_viewer *v=new ht_disasm_viewer();
00041 v->init(b, DESC_MZ_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, assembler, disassembler, 1);
00042 ht_mask_sub *m=new ht_mask_sub();
00043 m->init(file, 0);
00044 char info[128];
00045 ht_snprintf(info, sizeof info, "* MZ image at offset %08x", o);
00046 m->add_mask(info);
00047 v->insertsub(m);
00048
00049 ht_disasm_sub *d=new ht_disasm_sub();
00050 d->init(file, o, (mz_shared->header.sizep-1)*512+
00051 mz_shared->header.sizelp,
00052 disassembler, false, X86DIS_STYLE_OPTIMIZE_ADDR);
00053
00054 v->insertsub(d);
00055
00056 v->sendmsg(msg_complete_init, 0);
00057
00058 viewer_pos p;
00059 v->clear_viewer_pos(&p);
00060 p.u.sub = d;
00061 p.u.tag_idx = 0;
00062
00063 if (d->convert_ofs_to_id(o+mz_shared->header.cs*16+
00064 mz_shared->header.ip, &p.u.line_id)) {
00065 v->goto_pos(p, false);
00066 }
00067
00068 return v;
00069 }
00070
00071 format_viewer_if htmzimage_if = {
00072 htmzimage_init,
00073 0
00074 };
00075