00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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;
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
00068
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
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
00124
00125
00126 int ht_ne_entrypoint_viewer::ref_sel(LINE_ID *id)
00127 {
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 return 0;
00153 }