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

htneent.cc

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htneent.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 "htatom.h"
00022 #include "htctrl.h"
00023 #include "htendian.h"
00024 #include "htiobox.h"
00025 #include "htne.h"
00026 #include "htneent.h"
00027 #include "httag.h"
00028 #include "formats.h"
00029 #include "snprintf.h"
00030 
00031 static ht_tag_flags_s ne_entflags[] =
00032 {
00033         {-1, "NE - entrypoint flags"},
00034         {0,  "[00] exported"},
00035         {1,  "[01] single data"},
00036         {2,  "[02] reserved"},
00037         {0, 0}
00038 };
00039 
00040 static ht_view *htneentrypoints_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00041 {
00042         ht_ne_shared_data *ne_shared = (ht_ne_shared_data *)group->get_shared_data();
00043 
00044         FILEOFS h = ne_shared->hdr_ofs;
00045         ht_ne_entrypoint_viewer *v = new ht_ne_entrypoint_viewer();
00046         v->init(b, DESC_NE_ENTRYPOINTS, VC_EDIT | VC_SEARCH, file, group);
00047         ht_mask_sub *m = new ht_mask_sub();
00048         m->init(file, 0);
00049 
00050         register_atom(ATOM_NE_ENTFLAGS, ne_entflags);
00051 
00052         char line[1024], *l;    /* possible buffer overflow */
00053         ht_snprintf(line, sizeof line, "* NE entrypoint table at offset %08x", h+ne_shared->hdr.enttab);
00054         m->add_mask(line);
00055 
00056         FILEOFS o = h + ne_shared->hdr.enttab;
00057         NE_ENTRYPOINT_HEADER e;
00058 
00059         dword index = 1;
00060         while (o + sizeof e < h+ne_shared->hdr.enttab+ne_shared->hdr.cbenttab) {
00061                 file->seek(o);
00062                 file->read(&e, sizeof e);
00063                 create_host_struct(&e, NE_ENTRYPOINT_HEADER_struct, little_endian);
00064                 o += sizeof e;
00065 
00066                 if (e.seg_index==0) {
00067 /*                      sprintf(line, "null entries [%d]", e.entry_count);
00068                         m->add_mask(line);*/
00069                 } else if (e.seg_index==0xff) {
00070                         ht_snprintf(line, sizeof line, "entrypoints for movable segment [%d entries]", e.entry_count);
00071                         m->add_mask(line);
00072                 } else {
00073                         ht_snprintf(line, sizeof line, "entrypoints for fixed segment %d [%d entries]", e.seg_index, e.entry_count);
00074                         m->add_mask(line);
00075                 }
00076                 // FIXME: dont use sprintf
00077                 for (int i=0; i<e.entry_count; i++) {
00078                         if (e.seg_index==0) {
00079                         } else if (e.seg_index==0xff) {
00080                                 l=line;
00081                                 l+=sprintf(l, "%04x: ", index);
00082                                 l=tag_make_edit_byte(l, o+3);
00083                                 *(l++)=':';
00084                                 l=tag_make_edit_word(l, o+4, tag_endian_little);
00085                                 *(l++)=' ';
00086                                 l=tag_make_ref(l, o, 0xff, 0, 0, "goto");
00087                                 l+=sprintf(l, " flags=");
00088                                 l=tag_make_edit_byte(l, o);
00089                                 *(l++)=' ';
00090                                 l=tag_make_flags(l, ATOM_NE_ENTFLAGS, o);
00091                                 *l=0;
00092                                 m->add_mask(line);
00093                                 o+=sizeof (NE_ENTRYPOINT_MOVABLE);
00094                         } else {
00095                                 l=line;
00096                                 l+=sprintf(l, "%04x:    ", index);
00097                                 l=tag_make_edit_word(l, o+1, tag_endian_little);
00098                                 *(l++)=' ';
00099                                 l=tag_make_ref(l, o, e.seg_index, 0, 0, "goto");
00100                                 l+=sprintf(l, " flags=");
00101                                 l=tag_make_edit_byte(l, o);
00102                                 *(l++)=' ';
00103                                 l=tag_make_flags(l, ATOM_NE_ENTFLAGS, o);
00104                                 *l=0;
00105                                 m->add_mask(line);
00106                                 o+=sizeof (NE_ENTRYPOINT_FIXED);
00107                         }
00108                         index++;
00109                 }
00110         }
00111 
00112         v->insertsub(m);
00113 
00114         return v;
00115 }
00116 
00117 format_viewer_if htneentrypoints_if = {
00118         htneentrypoints_init,
00119         NULL
00120 };
00121 
00122 /*
00123  *      CLASS ht_ne_entrypoint_viewer
00124  */
00125 
00126 int ht_ne_entrypoint_viewer::ref_sel(LINE_ID *id)
00127 {
00128 /*   FIXNEW
00129         UINT seg = id_high;
00130         FILEOFS o = id_low;
00131         ADDR a;
00132         if (seg == 0xff) {
00133                 NE_ENTRYPOINT_MOVABLE e;
00134                 file->seek(o);
00135                 file->read(&e, sizeof e);
00136                 create_host_struct(&e, NE_ENTRYPOINT_MOVABLE_struct, little_endian);
00137                 a = NE_MAKE_ADDR(e.seg, e.offset);
00138         } else {
00139                 NE_ENTRYPOINT_FIXED e;
00140                 file->seek(o);
00141                 file->read(&e, sizeof e);
00142                 create_host_struct(&e, NE_ENTRYPOINT_FIXED_struct, little_endian);
00143                 a = NE_MAKE_ADDR(seg, e.offset);
00144         }
00145 
00146         ht_ne_shared_data *ne_shared=(ht_ne_shared_data *)format_group->get_shared_data();
00147 
00148         if (ne_shared->v_image->goto_address2(a, this)) {
00149                 app->focus(ne_shared->v_image);
00150         } else errorbox("can't follow: address %y is not valid !", a);
00151         return 1;*/
00152         return 0;
00153 }

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