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

htlehead.cc

Go to the documentation of this file.
00001 /* 
00002  *      HT Editor
00003  *      htlehead.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 "htnewexe.h"
00023 #include "htle.h"
00024 #include "htlehead.h"
00025 #include "httag.h"
00026 #include "snprintf.h"
00027 #include "formats.h"
00028 
00029 #include "lestruct.h"
00030 
00031 static int_hash le_machines[] =
00032 {
00033         { LE_CPU_286,   "Intel 286" },
00034         { LE_CPU_386,   "Intel 386" },
00035         { LE_CPU_486,   "Intel 486" },
00036         { LE_CPU_586,   "Intel 586" },
00037         { LE_CPU_N10,   "Intel i860(N10)" },
00038         { LE_CPU_N11,   "Intel N11" },
00039         { LE_CPU_R2000, "MIPS R2000"    },
00040         { LE_CPU_R6000, "MIPS R6000"    },
00041         { LE_CPU_R4000, "MIPS R4000"    },
00042         {0, 0}
00043 };
00044 
00045 static int_hash le_os[] =
00046 {
00047         { LE_OS_OS2, "OS/2"},
00048         { LE_OS_WIN, "Windows"},
00049         { LE_OS_DOS4,   "DOS 4.x"},
00050         { LE_OS_WIN386, "Windows 386" },
00051         {0, 0}
00052 };
00053 
00054 static ht_tag_flags_s le_flags[] =
00055 {
00056         {-1, "LE - module flags"},
00057         {0,  "[00] ?"},
00058         {1,  "[01] ?"},
00059         {2,  "[02] per-process library initialization"},
00060         {3,  "[03] ?"},
00061         {4,  "[04] no internal fixups"},
00062         {5,  "[05] no external fixups"},
00063         {6,  "[06] ?"},
00064         {7,  "[07] ?"},
00065         {8,  "[08] w0"},
00066         {9,  "[09] w1"},
00067         {10, "[10] w2"},
00068         {11, "[11] ?"},
00069         {12, "[12] ?"},
00070         {13, "[13] errors in image"},
00071         {14, "[14] ?"},
00072         {15, "[15] is library"},
00073         {0, 0}
00074 };
00075 
00076 static ht_mask_ptable leheader[]=
00077 {
00078         {"magic",                                                       STATICTAG_EDIT_WORD_LE("00000000")},
00079         {"byte order",                                          STATICTAG_EDIT_BYTE("00000002")},
00080         {"word order",                                          STATICTAG_EDIT_BYTE("00000003")},
00081         {"level",                                                       STATICTAG_EDIT_DWORD_LE("00000004")},
00082         {"cpu type",                                            STATICTAG_EDIT_WORD_LE("00000008")" "STATICTAG_DESC_WORD_LE("00000008", ATOM_LE_MACHINE_STR)},
00083         {"os type",                                             STATICTAG_EDIT_WORD_LE("0000000a")" "STATICTAG_DESC_WORD_LE("0000000a", ATOM_LE_OS_STR)},
00084         {"module version",                                      STATICTAG_EDIT_DWORD_LE("0000000c")},
00085         {"module flags",                                        STATICTAG_EDIT_DWORD_LE("00000010")" "STATICTAG_FLAGS("00000010", ATOM_LE_FLAGS_STR)},
00086         {"number of pages",                                     STATICTAG_EDIT_DWORD_LE("00000014")},
00087         {"logical cs",                                          STATICTAG_EDIT_DWORD_LE("00000018")},
00088         {"eip",                                                 STATICTAG_EDIT_DWORD_LE("0000001c")},
00089         {"logical ss",                                          STATICTAG_EDIT_DWORD_LE("00000020")},
00090         {"esp",                                                 STATICTAG_EDIT_DWORD_LE("00000024")},
00091         {"memory page size",                            STATICTAG_EDIT_DWORD_LE("00000028")},
00092         {"last page size",                                      STATICTAG_EDIT_DWORD_LE("0000002c")},
00093         {"fixup section size",                          STATICTAG_EDIT_DWORD_LE("00000030")},
00094         {"fixup section checksum",                      STATICTAG_EDIT_DWORD_LE("00000034")},
00095         {"loader section size",                         STATICTAG_EDIT_DWORD_LE("00000038")},
00096         {"loader section checksum",                     STATICTAG_EDIT_DWORD_LE("0000003c")},
00097         {"offset of object table",                      STATICTAG_EDIT_DWORD_LE("00000040")},
00098         {"number of objects",                           STATICTAG_EDIT_DWORD_LE("00000044")},
00099         {"offset page map",                                     STATICTAG_EDIT_DWORD_LE("00000048")},
00100         {"offset iterated data",                                STATICTAG_EDIT_DWORD_LE("0000004c")},
00101         {"offset of resource table",                    STATICTAG_EDIT_DWORD_LE("00000050")},
00102         {"number of resource entries",          STATICTAG_EDIT_DWORD_LE("00000054")},
00103         {"offset of resident name table",               STATICTAG_EDIT_DWORD_LE("00000058")},
00104         {"offset of entry table",                       STATICTAG_EDIT_DWORD_LE("0000005c")},
00105         {"offset of module directive table",    STATICTAG_EDIT_DWORD_LE("00000060")},
00106         {"number of module directives",         STATICTAG_EDIT_DWORD_LE("00000064")},
00107         {"offset of fixup page table",          STATICTAG_EDIT_DWORD_LE("00000068")},
00108         {"offset of fixup record table",                STATICTAG_EDIT_DWORD_LE("0000006c")},
00109         {"offset of import module name table",  STATICTAG_EDIT_DWORD_LE("00000070")},
00110         {"number of imported modules",          STATICTAG_EDIT_DWORD_LE("00000074")},
00111         {"offset of import procedure name table", STATICTAG_EDIT_DWORD_LE("00000078")},
00112         {"offset of per-page checksum table",   STATICTAG_EDIT_DWORD_LE("0000007c")},
00113         {"offset of enumerated data pages",     STATICTAG_EDIT_DWORD_LE("00000080")},
00114         {"number of preload pages",                     STATICTAG_EDIT_DWORD_LE("00000084")},
00115         {"offset of non-resident names table",  STATICTAG_EDIT_DWORD_LE("00000088")},
00116         {"size of non-resident names table",    STATICTAG_EDIT_DWORD_LE("0000008c")},
00117         {"non-resident name table checksum",    STATICTAG_EDIT_DWORD_LE("00000090")},
00118         {"auto data object number",                     STATICTAG_EDIT_DWORD_LE("00000094")},
00119         {"offset of debug info",                                STATICTAG_EDIT_DWORD_LE("00000098")},
00120         {"size of debug info",                          STATICTAG_EDIT_DWORD_LE("0000009c")},
00121         {"pages in preload section",                    STATICTAG_EDIT_DWORD_LE("000000a0")},
00122         {"pages in demand load section",                STATICTAG_EDIT_DWORD_LE("000000a4")},
00123         {"size of heap (16-bit)",                       STATICTAG_EDIT_DWORD_LE("000000a8")},
00124         {"reserved (12 bytes)",                                 STATICTAG_EDIT_BYTE("000000ac")" "STATICTAG_EDIT_BYTE("000000ad")" "STATICTAG_EDIT_BYTE("000000ae")" "STATICTAG_EDIT_BYTE("000000af")},
00125         {0,                                                             STATICTAG_EDIT_BYTE("000000b0")" "STATICTAG_EDIT_BYTE("000000b1")" "STATICTAG_EDIT_BYTE("000000b2")" "STATICTAG_EDIT_BYTE("000000b3")},
00126         {0,                                                             STATICTAG_EDIT_BYTE("000000b4")" "STATICTAG_EDIT_BYTE("000000b5")" "STATICTAG_EDIT_BYTE("000000b6")" "STATICTAG_EDIT_BYTE("000000b7")},
00127         {"--- VxD only ---", 0},
00128         {"offset of win-resource data",         STATICTAG_EDIT_DWORD_LE("000000b8")},
00129         {"size of win-resource data",                   STATICTAG_EDIT_DWORD_LE("000000bc")},
00130         {"device id",                                           STATICTAG_EDIT_WORD_LE("000000c0")},
00131         {"ddk version",                                 STATICTAG_EDIT_WORD_LE("000000c2")},
00132         {0, 0}
00133 };
00134 
00135 static ht_view *htleheader_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00136 {
00137         ht_le_shared_data *le_shared=(ht_le_shared_data *)group->get_shared_data();
00138 
00139         /* FIXME: */
00140         bool le_bigendian = false;
00141 
00142         FILEOFS h = le_shared->hdr_ofs;
00143         ht_uformat_viewer *v = new ht_uformat_viewer();
00144         v->init(b, DESC_LE_HEADER, VC_EDIT | VC_SEARCH, file, group);
00145         ht_mask_sub *m = new ht_mask_sub();
00146         m->init(file, 0);
00147 
00148         register_atom(ATOM_LE_FLAGS, le_flags);
00149         register_atom(ATOM_LE_MACHINE, le_machines);
00150         register_atom(ATOM_LE_OS, le_os);
00151 
00152         char info[128];
00153         ht_snprintf(info, sizeof info, "* LE header at offset %08x", le_shared->hdr_ofs);
00154         m->add_mask(info);
00155         m->add_staticmask_ptable(leheader, h, le_bigendian);
00156         v->insertsub(m);
00157 
00158         le_shared->v_header = v;
00159         return v;
00160 }
00161 
00162 format_viewer_if htleheader_if = {
00163         htleheader_init,
00164         0
00165 };

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