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 "htendian.h"
00023 #include "htne.h"
00024 #include "htnenms.h"
00025 #include "httag.h"
00026 #include "formats.h"
00027 #include "snprintf.h"
00028
00029 #include <stdlib.h>
00030 #include <string.h>
00031
00032 static void assign_entrypoint_name(ht_ne_shared_data *ne_shared, UINT i, char *name)
00033 {
00034 if (ne_shared->entrypoints) {
00035 ht_ne_entrypoint *e = (ht_ne_entrypoint*)ne_shared->entrypoints->get(i);
00036 if (e) {
00037 e->name = strdup(name);
00038 }
00039 }
00040 }
00041
00042 static ht_view *htnenames_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00043 {
00044 ht_ne_shared_data *ne_shared=(ht_ne_shared_data *)group->get_shared_data();
00045
00046 dword h=ne_shared->hdr_ofs;
00047 ht_uformat_viewer *v=new ht_uformat_viewer();
00048 v->init(b, DESC_NE_NAMES, VC_EDIT | VC_SEARCH, file, group);
00049 ht_mask_sub *m=new ht_mask_sub();
00050 m->init(file, 0);
00051
00052 char line[256];
00053 char *n;
00054 int i;
00055
00056 ht_snprintf(line, sizeof line, "* NE resident names table at offset %08x", h+ne_shared->hdr.restab);
00057 m->add_mask(line);
00058
00059 file->seek(h+ne_shared->hdr.restab);
00060 i=0;
00061 while (*(n=getstrp(file))) {
00062 char buf[2];
00063 file->read(buf, 2);
00064 word ent = create_host_int(buf, 2, little_endian);
00065 if (!i) {
00066 ht_snprintf(line, sizeof line, "description: %s", n);
00067 } else {
00068 ht_snprintf(line, sizeof line, "%04x %s", ent, n);
00069 assign_entrypoint_name(ne_shared, ent, n);
00070 }
00071 free(n);
00072 m->add_mask(line);
00073 i++;
00074 }
00075 free(n);
00076
00077 m->add_mask("----------------------------------------------------------------");
00078 ht_snprintf(line, sizeof line, "* NE non-resident names table at offset %08x", ne_shared->hdr.nrestab);
00079 m->add_mask(line);
00080
00081 file->seek(ne_shared->hdr.nrestab);
00082 i=0;
00083 while (*(n=getstrp(file))) {
00084 char buf[2];
00085 file->read(buf, 2);
00086 word ent = create_host_int(buf, 2, little_endian);
00087 if (!i) {
00088 ht_snprintf(line, sizeof line, "description: %s", n);
00089 } else {
00090 ht_snprintf(line, sizeof line, "%04x %s", ent, n);
00091 assign_entrypoint_name(ne_shared, ent, n);
00092 }
00093 free(n);
00094 m->add_mask(line);
00095 i++;
00096 }
00097 free(n);
00098
00099 v->insertsub(m);
00100
00101 return v;
00102 }
00103
00104 format_viewer_if htnenames_if = {
00105 htnenames_init,
00106 NULL
00107 };