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

htmzimg.cc

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htmzimg.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 "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 

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