00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "formats.h"
00022 #include "htapp.h"
00023 #include "htatom.h"
00024 #include "htcoff.h"
00025 #include "htctrl.h"
00026 #include "htendian.h"
00027 #include "hthex.h"
00028 #include "htiobox.h"
00029 #include "htnewexe.h"
00030 #include "htxbe.h"
00031 #include "htxbehead.h"
00032 #include "httag.h"
00033 #include "htstring.h"
00034 #include "snprintf.h"
00035
00036 #include "xbestruct.h"
00037
00038 #include <string.h>
00039
00040 static ht_mask_ptable xbemagic[] = {
00041 {"magic", STATICTAG_EDIT_CHAR("00000000")STATICTAG_EDIT_CHAR("00000001")STATICTAG_EDIT_CHAR("00000002")STATICTAG_EDIT_CHAR("00000003")},
00042 {0, 0}
00043 };
00044
00045 static ht_tag_flags_s xbe_init_flags[] =
00046 {
00047 {-1, "XBE - initialisation flags"},
00048 {0, "[00] Mount Utility Drive"},
00049 {1, "[01] Format Utility Drive"},
00050 {2, "[02] Limit to 64MB"},
00051 {3, "[03] Dont setup harddisk"},
00052 {0, 0}
00053 };
00054
00055 static ht_mask_ptable xbeimageheader[] = {
00056 {"base address", STATICTAG_EDIT_DWORD_LE("00000104")},
00057 {"size of headers", STATICTAG_EDIT_DWORD_LE("00000108")},
00058 {"size of image", STATICTAG_EDIT_DWORD_LE("0000010c")},
00059 {"size of imageheader", STATICTAG_EDIT_DWORD_LE("00000110")},
00060 {"timestamp", STATICTAG_EDIT_DWORD_LE("00000114")},
00061 {"certificate address", STATICTAG_EDIT_DWORD_LE("00000118")},
00062 {"number of sections", STATICTAG_EDIT_DWORD_LE("0000011c")},
00063 {"section header address", STATICTAG_EDIT_DWORD_LE("00000120")},
00064 {"initialisation flags", STATICTAG_EDIT_DWORD_LE("00000124")" "STATICTAG_FLAGS("00000124", ATOM_XBE_INIT_FLAGS_STR)},
00065 {"entry point", STATICTAG_EDIT_DWORD_LE("00000128")},
00066 {"TLS address", STATICTAG_EDIT_DWORD_LE("0000012c")},
00067 {"PE stack commit", STATICTAG_EDIT_DWORD_LE("00000130")},
00068 {"PE heap reserve", STATICTAG_EDIT_DWORD_LE("00000134")},
00069 {"PE heap commit", STATICTAG_EDIT_DWORD_LE("00000138")},
00070 {"PE base address", STATICTAG_EDIT_DWORD_LE("0000013c")},
00071 {"PE size of image", STATICTAG_EDIT_DWORD_LE("00000140")},
00072 {"PE checksum", STATICTAG_EDIT_DWORD_LE("00000144")},
00073 {"PE timestamp", STATICTAG_EDIT_DWORD_LE("00000148")},
00074 {"debug pathname address", STATICTAG_EDIT_DWORD_LE("0000014c")},
00075 {"debug filename address", STATICTAG_EDIT_DWORD_LE("00000150")},
00076 {"debug unicode filename address", STATICTAG_EDIT_DWORD_LE("00000154")},
00077 {"kernel image thunk address", STATICTAG_EDIT_DWORD_LE("00000158")},
00078 {"non-kernel import directoy address", STATICTAG_EDIT_DWORD_LE("0000015c")},
00079 {"number of library versions", STATICTAG_EDIT_DWORD_LE("00000160")},
00080 {"library versions address", STATICTAG_EDIT_DWORD_LE("00000164")},
00081 {"kernel library version", STATICTAG_EDIT_DWORD_LE("00000168")},
00082 {"xapi library version", STATICTAG_EDIT_DWORD_LE("0000016c")},
00083 {"logo bitmap address", STATICTAG_EDIT_DWORD_LE("00000170")},
00084 {"logo bitmap size", STATICTAG_EDIT_DWORD_LE("00000174")},
00085 {0, 0}
00086 };
00087
00088 static ht_tag_flags_s xbe_media_flags[] =
00089 {
00090 {-1, "XBE - allowed media flags"},
00091 {0, "[00] Harddisk"},
00092 {1, "[01] DVD X2"},
00093 {2, "[02] DVD CD"},
00094 {3, "[03] CD"},
00095 {4, "[04] DVD-5 RO"},
00096 {5, "[05] DVD-9 RO"},
00097 {6, "[06] DVD-5 RW"},
00098 {7, "[07] DVD-9 RW"},
00099 {8, "[08] Dongle"},
00100 {9, "[09] Mediaboard"},
00101 {30, "[30] Nonsecure Harddisk"},
00102 {31, "[31] Nonsecure Mode"},
00103 {0, 0}
00104 };
00105
00106 static ht_tag_flags_s xbe_region_codes[] =
00107 {
00108 { -1, "XBE - game region codes"},
00109 { 0, "[00] USA"},
00110 { 1, "[01] Japan"},
00111 { 2, "[02] Rest of World"},
00112 { 31, "[31] Manufacturing" },
00113 {0, 0}
00114 };
00115
00116
00117 static ht_mask_ptable xbecertificate[] = {
00118 {"certificate size", STATICTAG_EDIT_DWORD_LE("00000000")},
00119 {"timestamp", STATICTAG_EDIT_DWORD_LE("00000004")},
00120 {"title id", STATICTAG_EDIT_DWORD_LE("00000008")},
00121 {"alternate title ids", STATICTAG_EDIT_DWORD_LE("0000005c") " " STATICTAG_EDIT_DWORD_LE("00000060") " " STATICTAG_EDIT_DWORD_LE("00000064")},
00122 {"", STATICTAG_EDIT_DWORD_LE("00000068") " " STATICTAG_EDIT_DWORD_LE("0000006c") " " STATICTAG_EDIT_DWORD_LE("00000070")},
00123 {"", STATICTAG_EDIT_DWORD_LE("00000074") " " STATICTAG_EDIT_DWORD_LE("00000078") " " STATICTAG_EDIT_DWORD_LE("0000007c")},
00124 {"", STATICTAG_EDIT_DWORD_LE("00000080") " " STATICTAG_EDIT_DWORD_LE("00000084") " " STATICTAG_EDIT_DWORD_LE("00000088")},
00125 {"", STATICTAG_EDIT_DWORD_LE("0000008c") " " STATICTAG_EDIT_DWORD_LE("00000090") " " STATICTAG_EDIT_DWORD_LE("00000094")},
00126 {"", STATICTAG_EDIT_DWORD_LE("00000098")},
00127 {"allowed media", STATICTAG_EDIT_DWORD_LE("0000009c")" ("STATICTAG_FLAGS("0000009c", ATOM_XBE_MEDIA_FLAGS_STR)")"},
00128 {"game region", STATICTAG_EDIT_DWORD_LE("000000a0")" ("STATICTAG_FLAGS("000000a0", ATOM_XBE_REGION_STR)")"},
00129 {"game ratings", STATICTAG_EDIT_DWORD_LE("000000a4")},
00130 {"disk number", STATICTAG_EDIT_DWORD_LE("000000a8")},
00131 {"version", STATICTAG_EDIT_DWORD_LE("000000ac")},
00132 {"lan key", STATICTAG_EDIT_BYTE("000000b0") STATICTAG_EDIT_BYTE("000000b1") STATICTAG_EDIT_BYTE("000000b2") STATICTAG_EDIT_BYTE("000000b3") STATICTAG_EDIT_BYTE("000000b4") STATICTAG_EDIT_BYTE("000000b5") STATICTAG_EDIT_BYTE("000000b6") STATICTAG_EDIT_BYTE("000000b7") STATICTAG_EDIT_BYTE("000000b8") STATICTAG_EDIT_BYTE("000000b9") STATICTAG_EDIT_BYTE("000000ba") STATICTAG_EDIT_BYTE("000000bb") STATICTAG_EDIT_BYTE("000000bc") STATICTAG_EDIT_BYTE("000000bd") STATICTAG_EDIT_BYTE("000000be") STATICTAG_EDIT_BYTE("000000bf")},
00133 {"signature key", STATICTAG_EDIT_BYTE("000000c0") STATICTAG_EDIT_BYTE("000000c1") STATICTAG_EDIT_BYTE("000000c2") STATICTAG_EDIT_BYTE("000000c3") STATICTAG_EDIT_BYTE("000000c4") STATICTAG_EDIT_BYTE("000000c5") STATICTAG_EDIT_BYTE("000000c6") STATICTAG_EDIT_BYTE("000000c7") STATICTAG_EDIT_BYTE("000000c8") STATICTAG_EDIT_BYTE("000000c9") STATICTAG_EDIT_BYTE("000000ca") STATICTAG_EDIT_BYTE("000000cb") STATICTAG_EDIT_BYTE("000000cc") STATICTAG_EDIT_BYTE("000000cd") STATICTAG_EDIT_BYTE("000000ce") STATICTAG_EDIT_BYTE("000000cf")},
00134 {"alternate signature keys", STATICTAG_EDIT_BYTE("000000d0") STATICTAG_EDIT_BYTE("000000d1") STATICTAG_EDIT_BYTE("000000d2") STATICTAG_EDIT_BYTE("000000d3") STATICTAG_EDIT_BYTE("000000d4") STATICTAG_EDIT_BYTE("000000d5") STATICTAG_EDIT_BYTE("000000d6") STATICTAG_EDIT_BYTE("000000d7") STATICTAG_EDIT_BYTE("000000d8") STATICTAG_EDIT_BYTE("000000d9") STATICTAG_EDIT_BYTE("000000da") STATICTAG_EDIT_BYTE("000000db") STATICTAG_EDIT_BYTE("000000dc") STATICTAG_EDIT_BYTE("000000dd") STATICTAG_EDIT_BYTE("000000de") STATICTAG_EDIT_BYTE("000000df")},
00135 {"", STATICTAG_EDIT_BYTE("000000e0") STATICTAG_EDIT_BYTE("000000e1") STATICTAG_EDIT_BYTE("000000e2") STATICTAG_EDIT_BYTE("000000e3") STATICTAG_EDIT_BYTE("000000e4") STATICTAG_EDIT_BYTE("000000e5") STATICTAG_EDIT_BYTE("000000e6") STATICTAG_EDIT_BYTE("000000e7") STATICTAG_EDIT_BYTE("000000e8") STATICTAG_EDIT_BYTE("000000e9") STATICTAG_EDIT_BYTE("000000ea") STATICTAG_EDIT_BYTE("000000eb") STATICTAG_EDIT_BYTE("000000ec") STATICTAG_EDIT_BYTE("000000ed") STATICTAG_EDIT_BYTE("000000ee") STATICTAG_EDIT_BYTE("000000ef")},
00136 {"", STATICTAG_EDIT_BYTE("000000f0") STATICTAG_EDIT_BYTE("000000f1") STATICTAG_EDIT_BYTE("000000f2") STATICTAG_EDIT_BYTE("000000f3") STATICTAG_EDIT_BYTE("000000f4") STATICTAG_EDIT_BYTE("000000f5") STATICTAG_EDIT_BYTE("000000f6") STATICTAG_EDIT_BYTE("000000f7") STATICTAG_EDIT_BYTE("000000f8") STATICTAG_EDIT_BYTE("000000f9") STATICTAG_EDIT_BYTE("000000fa") STATICTAG_EDIT_BYTE("000000fb") STATICTAG_EDIT_BYTE("000000fc") STATICTAG_EDIT_BYTE("000000fd") STATICTAG_EDIT_BYTE("000000fe") STATICTAG_EDIT_BYTE("000000ff")},
00137 {"", STATICTAG_EDIT_BYTE("00000100") STATICTAG_EDIT_BYTE("00000101") STATICTAG_EDIT_BYTE("00000102") STATICTAG_EDIT_BYTE("00000103") STATICTAG_EDIT_BYTE("00000104") STATICTAG_EDIT_BYTE("00000105") STATICTAG_EDIT_BYTE("00000106") STATICTAG_EDIT_BYTE("00000107") STATICTAG_EDIT_BYTE("00000108") STATICTAG_EDIT_BYTE("00000109") STATICTAG_EDIT_BYTE("0000010a") STATICTAG_EDIT_BYTE("0000010b") STATICTAG_EDIT_BYTE("0000010c") STATICTAG_EDIT_BYTE("0000010d") STATICTAG_EDIT_BYTE("0000010e") STATICTAG_EDIT_BYTE("0000010f")},
00138 {"", STATICTAG_EDIT_BYTE("00000110") STATICTAG_EDIT_BYTE("00000111") STATICTAG_EDIT_BYTE("00000112") STATICTAG_EDIT_BYTE("00000113") STATICTAG_EDIT_BYTE("00000114") STATICTAG_EDIT_BYTE("00000115") STATICTAG_EDIT_BYTE("00000116") STATICTAG_EDIT_BYTE("00000117") STATICTAG_EDIT_BYTE("00000118") STATICTAG_EDIT_BYTE("00000119") STATICTAG_EDIT_BYTE("0000011a") STATICTAG_EDIT_BYTE("0000011b") STATICTAG_EDIT_BYTE("0000011c") STATICTAG_EDIT_BYTE("0000011d") STATICTAG_EDIT_BYTE("0000011e") STATICTAG_EDIT_BYTE("0000011f")},
00139 {"", STATICTAG_EDIT_BYTE("00000120") STATICTAG_EDIT_BYTE("00000121") STATICTAG_EDIT_BYTE("00000122") STATICTAG_EDIT_BYTE("00000123") STATICTAG_EDIT_BYTE("00000124") STATICTAG_EDIT_BYTE("00000125") STATICTAG_EDIT_BYTE("00000126") STATICTAG_EDIT_BYTE("00000127") STATICTAG_EDIT_BYTE("00000128") STATICTAG_EDIT_BYTE("00000129") STATICTAG_EDIT_BYTE("0000012a") STATICTAG_EDIT_BYTE("0000012b") STATICTAG_EDIT_BYTE("0000012c") STATICTAG_EDIT_BYTE("0000012d") STATICTAG_EDIT_BYTE("0000012e") STATICTAG_EDIT_BYTE("0000012f")},
00140 {"", STATICTAG_EDIT_BYTE("00000130") STATICTAG_EDIT_BYTE("00000131") STATICTAG_EDIT_BYTE("00000132") STATICTAG_EDIT_BYTE("00000133") STATICTAG_EDIT_BYTE("00000134") STATICTAG_EDIT_BYTE("00000135") STATICTAG_EDIT_BYTE("00000136") STATICTAG_EDIT_BYTE("00000137") STATICTAG_EDIT_BYTE("00000138") STATICTAG_EDIT_BYTE("00000139") STATICTAG_EDIT_BYTE("0000013a") STATICTAG_EDIT_BYTE("0000013b") STATICTAG_EDIT_BYTE("0000013c") STATICTAG_EDIT_BYTE("0000013d") STATICTAG_EDIT_BYTE("0000013e") STATICTAG_EDIT_BYTE("0000013f")},
00141 {"", STATICTAG_EDIT_BYTE("00000140") STATICTAG_EDIT_BYTE("00000141") STATICTAG_EDIT_BYTE("00000142") STATICTAG_EDIT_BYTE("00000143") STATICTAG_EDIT_BYTE("00000144") STATICTAG_EDIT_BYTE("00000145") STATICTAG_EDIT_BYTE("00000146") STATICTAG_EDIT_BYTE("00000147") STATICTAG_EDIT_BYTE("00000148") STATICTAG_EDIT_BYTE("00000149") STATICTAG_EDIT_BYTE("0000014a") STATICTAG_EDIT_BYTE("0000014b") STATICTAG_EDIT_BYTE("0000014c") STATICTAG_EDIT_BYTE("0000014d") STATICTAG_EDIT_BYTE("0000014e") STATICTAG_EDIT_BYTE("0000014f")},
00142 {"", STATICTAG_EDIT_BYTE("00000150") STATICTAG_EDIT_BYTE("00000151") STATICTAG_EDIT_BYTE("00000152") STATICTAG_EDIT_BYTE("00000153") STATICTAG_EDIT_BYTE("00000154") STATICTAG_EDIT_BYTE("00000155") STATICTAG_EDIT_BYTE("00000156") STATICTAG_EDIT_BYTE("00000157") STATICTAG_EDIT_BYTE("00000158") STATICTAG_EDIT_BYTE("00000159") STATICTAG_EDIT_BYTE("0000015a") STATICTAG_EDIT_BYTE("0000015b") STATICTAG_EDIT_BYTE("0000015c") STATICTAG_EDIT_BYTE("0000015d") STATICTAG_EDIT_BYTE("0000015e") STATICTAG_EDIT_BYTE("0000015f")},
00143 {"", STATICTAG_EDIT_BYTE("00000160") STATICTAG_EDIT_BYTE("00000161") STATICTAG_EDIT_BYTE("00000162") STATICTAG_EDIT_BYTE("00000163") STATICTAG_EDIT_BYTE("00000164") STATICTAG_EDIT_BYTE("00000165") STATICTAG_EDIT_BYTE("00000166") STATICTAG_EDIT_BYTE("00000167") STATICTAG_EDIT_BYTE("00000168") STATICTAG_EDIT_BYTE("00000169") STATICTAG_EDIT_BYTE("0000016a") STATICTAG_EDIT_BYTE("0000016b") STATICTAG_EDIT_BYTE("0000016c") STATICTAG_EDIT_BYTE("0000016d") STATICTAG_EDIT_BYTE("0000016e") STATICTAG_EDIT_BYTE("0000016f")},
00144 {"", STATICTAG_EDIT_BYTE("00000170") STATICTAG_EDIT_BYTE("00000171") STATICTAG_EDIT_BYTE("00000172") STATICTAG_EDIT_BYTE("00000173") STATICTAG_EDIT_BYTE("00000174") STATICTAG_EDIT_BYTE("00000175") STATICTAG_EDIT_BYTE("00000176") STATICTAG_EDIT_BYTE("00000177") STATICTAG_EDIT_BYTE("00000178") STATICTAG_EDIT_BYTE("00000179") STATICTAG_EDIT_BYTE("0000017a") STATICTAG_EDIT_BYTE("0000017b") STATICTAG_EDIT_BYTE("0000017c") STATICTAG_EDIT_BYTE("0000017d") STATICTAG_EDIT_BYTE("0000017e") STATICTAG_EDIT_BYTE("0000017f")},
00145 {"", STATICTAG_EDIT_BYTE("00000180") STATICTAG_EDIT_BYTE("00000181") STATICTAG_EDIT_BYTE("00000182") STATICTAG_EDIT_BYTE("00000183") STATICTAG_EDIT_BYTE("00000184") STATICTAG_EDIT_BYTE("00000185") STATICTAG_EDIT_BYTE("00000186") STATICTAG_EDIT_BYTE("00000187") STATICTAG_EDIT_BYTE("00000188") STATICTAG_EDIT_BYTE("00000189") STATICTAG_EDIT_BYTE("0000018a") STATICTAG_EDIT_BYTE("0000018b") STATICTAG_EDIT_BYTE("0000018c") STATICTAG_EDIT_BYTE("0000018d") STATICTAG_EDIT_BYTE("0000018e") STATICTAG_EDIT_BYTE("0000018f")},
00146 {"", STATICTAG_EDIT_BYTE("00000190") STATICTAG_EDIT_BYTE("00000191") STATICTAG_EDIT_BYTE("00000192") STATICTAG_EDIT_BYTE("00000193") STATICTAG_EDIT_BYTE("00000194") STATICTAG_EDIT_BYTE("00000195") STATICTAG_EDIT_BYTE("00000196") STATICTAG_EDIT_BYTE("00000197") STATICTAG_EDIT_BYTE("00000198") STATICTAG_EDIT_BYTE("00000199") STATICTAG_EDIT_BYTE("0000019a") STATICTAG_EDIT_BYTE("0000019b") STATICTAG_EDIT_BYTE("0000019c") STATICTAG_EDIT_BYTE("0000019d") STATICTAG_EDIT_BYTE("0000019e") STATICTAG_EDIT_BYTE("0000019")},
00147 {"", STATICTAG_EDIT_BYTE("000001a0") STATICTAG_EDIT_BYTE("000001a1") STATICTAG_EDIT_BYTE("000001a2") STATICTAG_EDIT_BYTE("000001a3") STATICTAG_EDIT_BYTE("000001a4") STATICTAG_EDIT_BYTE("000001a5") STATICTAG_EDIT_BYTE("000001a6") STATICTAG_EDIT_BYTE("000001a7") STATICTAG_EDIT_BYTE("000001a8") STATICTAG_EDIT_BYTE("000001a9") STATICTAG_EDIT_BYTE("000001aa") STATICTAG_EDIT_BYTE("000001ab") STATICTAG_EDIT_BYTE("000001ac") STATICTAG_EDIT_BYTE("000001ad") STATICTAG_EDIT_BYTE("000001ae") STATICTAG_EDIT_BYTE("000001af")},
00148 {"", STATICTAG_EDIT_BYTE("000001b0") STATICTAG_EDIT_BYTE("000001b1") STATICTAG_EDIT_BYTE("000001b2") STATICTAG_EDIT_BYTE("000001b3") STATICTAG_EDIT_BYTE("000001b4") STATICTAG_EDIT_BYTE("000001b5") STATICTAG_EDIT_BYTE("000001b6") STATICTAG_EDIT_BYTE("000001b7") STATICTAG_EDIT_BYTE("000001b8") STATICTAG_EDIT_BYTE("000001b9") STATICTAG_EDIT_BYTE("000001ba") STATICTAG_EDIT_BYTE("000001bb") STATICTAG_EDIT_BYTE("000001bc") STATICTAG_EDIT_BYTE("000001bd") STATICTAG_EDIT_BYTE("000001be") STATICTAG_EDIT_BYTE("000001bf")},
00149 {"", STATICTAG_EDIT_BYTE("000001c0") STATICTAG_EDIT_BYTE("000001c1") STATICTAG_EDIT_BYTE("000001c2") STATICTAG_EDIT_BYTE("000001c3") STATICTAG_EDIT_BYTE("000001c4") STATICTAG_EDIT_BYTE("000001c5") STATICTAG_EDIT_BYTE("000001c6") STATICTAG_EDIT_BYTE("000001c7") STATICTAG_EDIT_BYTE("000001c8") STATICTAG_EDIT_BYTE("000001c9") STATICTAG_EDIT_BYTE("000001ca") STATICTAG_EDIT_BYTE("000001cb") STATICTAG_EDIT_BYTE("000001cc") STATICTAG_EDIT_BYTE("000001cd") STATICTAG_EDIT_BYTE("000001ce") STATICTAG_EDIT_BYTE("000001cf")},
00150
00151 {0, 0}
00152 };
00153
00154 static ht_tag_flags_s xbe_section_flags[] =
00155 {
00156 {-1, "XBE - section flags"},
00157 {0, "[00] Writeable"},
00158 {1, "[01] Preload"},
00159 {2, "[02] Executable"},
00160 {3, "[03] Inserted File"},
00161 {4, "[04] Head Page Read Only"},
00162 {5, "[05] Tail Page Read Only"},
00163 {0, 0}
00164 };
00165
00166 static ht_mask_ptable xbesectionheader[] = {
00167 {"section flags", STATICTAG_EDIT_DWORD_LE("00000000")" "STATICTAG_FLAGS("00000000", ATOM_XBE_SECTION_FLAGS_STR)},
00168 {"virtual address", STATICTAG_EDIT_DWORD_LE("00000004")},
00169 {"virtual size", STATICTAG_EDIT_DWORD_LE("00000008")},
00170 {"raw address", STATICTAG_EDIT_DWORD_LE("0000000c")},
00171 {"raw size", STATICTAG_EDIT_DWORD_LE("00000010")},
00172 {"section name address", STATICTAG_EDIT_DWORD_LE("00000014")},
00173 {"section name reference counter", STATICTAG_EDIT_DWORD_LE("00000018")},
00174 {"head shared page reference counter address", STATICTAG_EDIT_DWORD_LE("0000001c")},
00175 {"tail shared page reference counter address", STATICTAG_EDIT_DWORD_LE("00000020")},
00176 {0, 0}
00177 };
00178
00179 static ht_tag_flags_s xbe_library_flags[] =
00180 {
00181 {-1, "XBE - library flags"},
00182 {15, "[15] Debug Build"},
00183 {0, 0}
00184 };
00185
00186
00187 static ht_mask_ptable xbelibraryversion[] = {
00188 {"library name", STATICTAG_EDIT_CHAR("00000000")STATICTAG_EDIT_CHAR("00000001")STATICTAG_EDIT_CHAR("00000002")STATICTAG_EDIT_CHAR("00000003")STATICTAG_EDIT_CHAR("00000004")STATICTAG_EDIT_CHAR("00000005")STATICTAG_EDIT_CHAR("00000006")STATICTAG_EDIT_CHAR("00000007")},
00189 {"major version", STATICTAG_EDIT_WORD_LE("00000008")},
00190 {"minor version", STATICTAG_EDIT_WORD_LE("0000000a")},
00191 {"build version", STATICTAG_EDIT_WORD_LE("0000000c")},
00192 {"library flags", STATICTAG_EDIT_WORD_LE("0000000e")" "STATICTAG_FLAGS("0000000a", ATOM_XBE_LIBRARY_FLAGS_STR)},
00193 {0, 0}
00194 };
00195
00196 static ht_view *htxbeheader_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00197 {
00198 ht_xbe_shared_data *xbe_shared=(ht_xbe_shared_data *)group->get_shared_data();
00199
00200 ht_xbe_header_viewer *v=new ht_xbe_header_viewer();
00201 v->init(b, DESC_XBE_HEADER, VC_EDIT | VC_SEARCH, file, group);
00202
00203 register_atom(ATOM_XBE_INIT_FLAGS, xbe_init_flags);
00204 register_atom(ATOM_XBE_SECTION_FLAGS, xbe_section_flags);
00205 register_atom(ATOM_XBE_MEDIA_FLAGS, xbe_media_flags);
00206 register_atom(ATOM_XBE_REGION, xbe_region_codes);
00207 register_atom(ATOM_XBE_LIBRARY_FLAGS, xbe_library_flags);
00208
00209 ht_mask_sub *s;
00210 ht_collapsable_sub *cs;
00211
00212 s=new ht_mask_sub();
00213 s->init(file, 0);
00214 char info[128];
00215 ht_snprintf(info, sizeof info, "* XBE header");
00216 s->add_mask(info);
00217 v->insertsub(s);
00218
00219
00220 bool xbe_bigendian = false;
00221
00222 s=new ht_mask_sub();
00223 s->init(file, 1);
00224 s->add_staticmask_ptable(xbemagic, 0x0, xbe_bigendian);
00225
00226
00227 s->add_staticmask_ptable(xbeimageheader, 0x0, xbe_bigendian);
00228 cs=new ht_collapsable_sub();
00229 cs->init(file, s, 1, "image header", 1);
00230 v->insertsub(cs);
00231
00232
00233 s=new ht_mask_sub();
00234 s->init(file, 2);
00235 s->add_staticmask_ptable(xbecertificate, xbe_shared->header.certificate_address-xbe_shared->header.base_address, xbe_bigendian);
00236 cs=new ht_collapsable_sub();
00237 cs->init(file, s, 1, "certificate", 1);
00238 v->insertsub(cs);
00239
00240
00241
00242 for (UINT i=0; i<xbe_shared->header.number_of_library_versions; i++) {
00243 s=new ht_mask_sub();
00244 s->init(file, 50+i);
00245
00246 s->add_staticmask_ptable(xbelibraryversion, xbe_shared->header.library_versions_address-xbe_shared->header.base_address+i*sizeof *xbe_shared->libraries, xbe_bigendian);
00247
00248 char t[256];
00249 ht_snprintf(t, sizeof t, "library %d: %-9s %d.%d.%d", i, &xbe_shared->libraries[i].library_name, xbe_shared->libraries[i].major_version, xbe_shared->libraries[i].minor_version, xbe_shared->libraries[i].build_version);
00250
00251 cs=new ht_collapsable_sub();
00252 cs->init(file, s, 1, t, 1);
00253
00254 v->insertsub(cs);
00255 }
00256
00257
00258
00259 for (UINT i=0; i<xbe_shared->sections.number_of_sections; i++) {
00260 char *name;
00261
00262
00263 s=new ht_mask_sub();
00264 s->init(file, 100+i);
00265
00266 s->add_staticmask_ptable(xbesectionheader, xbe_shared->header.section_header_address-xbe_shared->header.base_address+i*sizeof *xbe_shared->sections.sections, xbe_bigendian);
00267
00268 if (xbe_shared->sections.sections[i].section_name_address) {
00269
00270 name = (char *)xbe_shared->sections.sections[i].section_name_address;
00271
00272 } else {
00273 name = "<empty>";
00274 }
00275
00276 char t[256];
00277 ht_snprintf(t, sizeof t, "section header %d: %s - rva %08x vsize %08x", i, name, xbe_shared->sections.sections[i].virtual_address, xbe_shared->sections.sections[i].virtual_size);
00278
00279 cs=new ht_collapsable_sub();
00280 cs->init(file, s, 1, t, 1);
00281
00282 v->insertsub(cs);
00283 }
00284 return v;
00285 }
00286
00287 format_viewer_if htxbeheader_if = {
00288 htxbeheader_init,
00289 0
00290 };
00291
00292
00293
00294
00295
00296 void ht_xbe_header_viewer::init(bounds *b, char *desc, int caps, ht_streamfile *file, ht_format_group *group)
00297 {
00298 ht_uformat_viewer::init(b, desc, caps, file, group);
00299 VIEW_DEBUG_NAME("ht_xbe_header_viewer");
00300 }
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319 int ht_xbe_header_viewer::ref_sel(LINE_ID *id)
00320 {
00321 return 1;
00322 }