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 "htnewexe.h"
00023 #include "htle.h"
00024 #include "htleobj.h"
00025 #include "httag.h"
00026 #include "htstring.h"
00027 #include "formats.h"
00028 #include "snprintf.h"
00029
00030 #include "lestruct.h"
00031
00032 #include <stdlib.h>
00033 #include <string.h>
00034
00035 static ht_mask_ptable leobj[]=
00036 {
00037 {"virtual size", STATICTAG_EDIT_DWORD_LE("00000000")},
00038 {"relocation base address", STATICTAG_EDIT_DWORD_LE("00000004")},
00039 {"flags", STATICTAG_EDIT_DWORD_LE("00000008")" "STATICTAG_FLAGS("00000008", ATOM_LE_OBJFLAGS_STR)},
00040 {"page map index", STATICTAG_EDIT_DWORD_LE("0000000c")},
00041 {"page map count", STATICTAG_EDIT_DWORD_LE("00000010")},
00042 {"name", STATICTAG_EDIT_CHAR("00000014")""STATICTAG_EDIT_CHAR("00000015")""STATICTAG_EDIT_CHAR("00000016")""STATICTAG_EDIT_CHAR("00000017")},
00043 {0, 0}
00044 };
00045
00046 static ht_tag_flags_s le_objflags[] =
00047 {
00048 {0, "[00] readable"},
00049 {1, "[01] writable"},
00050 {2, "[02] executable"},
00051 {3, "[03] resource"},
00052 {4, "[04] discardable"},
00053 {5, "[05] shared"},
00054 {6, "[06] preloaded"},
00055 {7, "[07] * reserved"},
00056 {8, "[08] * reserved"},
00057 {9, "[09] * reserved"},
00058 {10, "[10] resident"},
00059 {11, "[11] * reserved"},
00060 {12, "[12] 16:16 alias"},
00061 {13, "[13] use32"},
00062 {14, "[14] conforming"},
00063 {15, "[15] object i/o privilege level"},
00064 {0, 0}
00065 };
00066
00067 static ht_view *htleobjects_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00068 {
00069 ht_le_shared_data *le_shared=(ht_le_shared_data *)group->get_shared_data();
00070
00071 dword h=le_shared->hdr_ofs;
00072 ht_uformat_viewer *v=new ht_uformat_viewer();
00073 v->init(b, DESC_LE_OBJECTS, VC_EDIT, file, group);
00074 ht_mask_sub *m=new ht_mask_sub();
00075 m->init(file, 0);
00076
00077 register_atom(ATOM_LE_OBJFLAGS, le_objflags);
00078
00079
00080 bool le_bigendian = false;
00081
00082 char t[64];
00083 ht_snprintf(t, sizeof t, "* LE object headers at offset %08x", h+le_shared->hdr.objtab);
00084 m->add_mask(t);
00085
00086 v->insertsub(m);
00087
00088 for (dword i=0; i<le_shared->hdr.objcnt; i++) {
00089 m=new ht_mask_sub();
00090 m->init(file, i);
00091
00092 char n[5];
00093 m->add_staticmask_ptable(leobj, h+le_shared->hdr.objtab+i*24, le_bigendian);
00094
00095 memmove(&n, le_shared->objmap.header[i].name, 4);
00096 n[4]=0;
00097
00098 bool use32=le_shared->objmap.header[i].flags & LE_OBJECT_FLAG_USE32;
00099
00100 ht_snprintf(t, sizeof t, "--- object %d USE%d: %s ---", i+1, use32 ? 32 : 16, (char*)&n);
00101
00102 ht_collapsable_sub *cs=new ht_collapsable_sub();
00103 cs->init(file, m, 1, t, 1);
00104 v->insertsub(cs);
00105 }
00106
00107 le_shared->v_objects = v;
00108 return v;
00109 }
00110
00111 format_viewer_if htleobjects_if = {
00112 htleobjects_init,
00113 0
00114 };