00001 /* 00002 * HT Editor 00003 * xbestruct.h 00004 * 00005 * Copyright (C) 2003 Stefan Esser 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 #ifndef __XBESTRUCT_H_ 00022 #define __XBESTRUCT_H_ 00023 00024 #include "global.h" 00025 #include "tools.h" 00026 00027 typedef unsigned int RVA; 00028 00029 #define XBE_MAGIC_LENGTH 4 00030 #define XBE_MAGIC0 'X' 00031 #define XBE_MAGIC1 'B' 00032 #define XBE_MAGIC2 'E' 00033 #define XBE_MAGIC3 'H' 00034 00035 #define XBE_SIZE_OF_SIGNATURE 256 00036 00037 typedef struct XBE_IMAGE_HEADER { 00038 byte magic_id[XBE_MAGIC_LENGTH] HTPACKED; 00039 byte signature[XBE_SIZE_OF_SIGNATURE] HTPACKED; 00040 dword base_address HTPACKED; 00041 dword size_of_headers HTPACKED; 00042 dword size_of_image HTPACKED; 00043 dword size_of_imageheader HTPACKED; 00044 dword timedate HTPACKED; 00045 dword certificate_address HTPACKED; 00046 dword number_of_sections HTPACKED; 00047 dword section_header_address HTPACKED; 00048 dword initialisation_flags HTPACKED; 00049 dword entry_point HTPACKED; 00050 dword tls_address HTPACKED; 00051 dword pe_stack_commit HTPACKED; 00052 dword pe_heap_reserve HTPACKED; 00053 dword pe_heap_commit HTPACKED; 00054 dword pe_base_address HTPACKED; 00055 dword pe_size_of_image HTPACKED; 00056 dword pe_checksum HTPACKED; 00057 dword pe_timedate HTPACKED; 00058 dword debug_pathname_address HTPACKED; 00059 dword debug_filename_address HTPACKED; 00060 dword debug_unicode_filename_address HTPACKED; 00061 dword kernel_image_thunk_address HTPACKED; 00062 dword non_kernel_import_directory_address HTPACKED; 00063 dword number_of_library_versions HTPACKED; 00064 dword library_versions_address HTPACKED; 00065 dword kernel_library_version_address HTPACKED; 00066 dword xapi_library_version_address HTPACKED; 00067 dword logo_bitmap_address HTPACKED; 00068 dword logo_bitmap_size HTPACKED; 00069 }; 00070 00071 00072 #define XBE_TITLE_NAME_LENGTH 40 00073 #define XBE_NUM_ALTERNATE 16 00074 #define XBE_LAN_KEY_LENGTH 16 00075 #define XBE_SIGNATURE_KEY_LENGTH 16 00076 00077 #define XBE_MEDIA_TYPE_HARD_DISK 0x00000001 00078 #define XBE_MEDIA_TYPE_DVD_X2 0x00000002 00079 #define XBE_MEDIA_TYPE_DVD_CD 0x00000004 00080 #define XBE_MEDIA_TYPE_CD 0x00000008 00081 #define XBE_MEDIA_TYPE_DVD_5_RO 0x00000010 00082 #define XBE_MEDIA_TYPE_DVD_9_RO 0x00000020 00083 #define XBE_MEDIA_TYPE_DVD_5_RW 0x00000040 00084 #define XBE_MEDIA_TYPE_DVD_9_RW 0x00000080 00085 #define XBE_MEDIA_TYPE_DONGLE 0x00000100 00086 #define XBE_MEDIA_TYPE_MEDIA_BOARD 0x00000200 00087 #define XBE_MEDIA_TYPE_NONSECURE_HARD_DISK 0x40000000 00088 #define XBE_MEDIA_TYPE_NONSECURE_MODE 0x80000000 00089 #define XBE_MEDIA_TYPE_MEDIA_MASK 0x00FFFFFF 00090 00091 #define XBE_GAME_REGION_NA 0x00000001 00092 #define XBE_GAME_REGION_JAPAN 0x00000002 00093 #define XBE_GAME_REGION_RESTOFWORLD 0x00000004 00094 #define XBE_GAME_REGION_MANUFACTURING 0x80000000 00095 00096 typedef struct XBE_CERTIFICATE { 00097 dword size_of_certificate HTPACKED; 00098 dword timedate HTPACKED; 00099 dword title_id HTPACKED; 00100 word title_name[XBE_TITLE_NAME_LENGTH] HTPACKED; 00101 dword alternate_title_ids[XBE_NUM_ALTERNATE] HTPACKED; 00102 dword allowed_media HTPACKED; 00103 dword game_region HTPACKED; 00104 dword game_ratings HTPACKED; 00105 dword disk_number HTPACKED; 00106 dword version HTPACKED; 00107 byte lan_key[XBE_LAN_KEY_LENGTH] HTPACKED; 00108 byte signature_key[XBE_SIGNATURE_KEY_LENGTH] HTPACKED; 00109 byte alternate_signature_keys[XBE_NUM_ALTERNATE][XBE_SIGNATURE_KEY_LENGTH] HTPACKED; 00110 }; 00111 00112 00113 #define XBE_SECTION_FLAGS_WRITABLE 1 00114 #define XBE_SECTION_FLAGS_PRELOAD 2 00115 #define XBE_SECTION_FLAGS_EXECUTABLE 4 00116 #define XBE_SECTION_FLAGS_INSERTEDFILE 8 00117 #define XBE_SECTION_FLAGS_HEADPAGE_RO 16 00118 #define XBE_SECTION_FLAGS_TAILPAGE_RO 32 00119 00120 #define XBE_SECTION_DIGEST_LENGTH 20 00121 00122 typedef struct XBE_SECTION_HEADER { 00123 dword section_flags HTPACKED; 00124 dword virtual_address HTPACKED; 00125 dword virtual_size HTPACKED; 00126 dword raw_address HTPACKED; 00127 dword raw_size HTPACKED; 00128 dword section_name_address HTPACKED; 00129 dword section_name_ref_count HTPACKED; 00130 dword head_shared_page_ref_count_address HTPACKED; 00131 dword tail_shared_page_ref_count_address HTPACKED; 00132 byte section_digest[XBE_SECTION_DIGEST_LENGTH] HTPACKED; 00133 }; 00134 00135 #define XBE_LIBRARY_NAME_LENGTH 8 00136 00137 typedef struct XBE_LIBRARY_VERSION { 00138 byte library_name[XBE_LIBRARY_NAME_LENGTH] HTPACKED; 00139 word major_version HTPACKED; 00140 word minor_version HTPACKED; 00141 word build_version HTPACKED; 00142 word library_flags HTPACKED; 00143 }; 00144 00145 00146 typedef struct XBE_TLS_DIRECTORY { 00147 dword data_start_address HTPACKED; 00148 dword data_end_address HTPACKED; 00149 dword tls_index_address HTPACKED; 00150 dword tls_callback_address HTPACKED; 00151 dword size_of_zero_fill HTPACKED; 00152 dword characteristics HTPACKED; 00153 }; 00154 00155 extern byte XBE_IMAGE_HEADER_struct[]; 00156 extern byte XBE_CERTIFICATE_struct[]; 00157 extern byte XBE_SECTION_HEADER_struct[]; 00158 extern byte XBE_LIBRARY_VERSION_struct[]; 00159 extern byte XBE_TLS_DIRECTORY_struct[]; 00160 00161 00162 #endif