File: xbestruct.h

package info (click to toggle)
ht 2.1.0%2Brepack1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,852 kB
  • sloc: cpp: 88,922; ansic: 12,693; sh: 4,083; lex: 226; makefile: 185; yacc: 128
file content (162 lines) | stat: -rw-r--r-- 4,728 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/* 
 *	HT Editor
 *	xbestruct.h
 *
 *	Copyright (C) 2003 Stefan Esser
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __XBESTRUCT_H_
#define __XBESTRUCT_H_

#include "io/types.h"
#include "tools.h"

typedef unsigned int RVA;

#define XBE_MAGIC_LENGTH 4
#define XBE_MAGIC0	'X'
#define XBE_MAGIC1	'B'
#define XBE_MAGIC2	'E'
#define XBE_MAGIC3	'H'

#define XBE_SIZE_OF_SIGNATURE	256

struct XBE_IMAGE_HEADER {
    byte	magic_id[XBE_MAGIC_LENGTH];
    byte	signature[XBE_SIZE_OF_SIGNATURE];
    uint32	base_address;
    uint32	size_of_headers;
    uint32	size_of_image;
    uint32	size_of_imageheader;
    uint32	timedate;
    uint32	certificate_address;
    uint32	number_of_sections;
    uint32	section_header_address;
    uint32	initialisation_flags;
    uint32	entry_point;
    uint32	tls_address;
    uint32	pe_stack_commit;
    uint32	pe_heap_reserve;
    uint32	pe_heap_commit;
    uint32	pe_base_address;
    uint32	pe_size_of_image;
    uint32	pe_checksum;
    uint32	pe_timedate;
    uint32	debug_pathname_address;
    uint32	debug_filename_address;
    uint32	debug_unicode_filename_address;
    uint32	kernel_image_thunk_address;
    uint32	non_kernel_import_directory_address;
    uint32	number_of_library_versions;
    uint32	library_versions_address;
    uint32	kernel_library_version_address;
    uint32	xapi_library_version_address;
    uint32	logo_bitmap_address;
    uint32	logo_bitmap_size;
} PACKED;


#define XBE_TITLE_NAME_LENGTH	40
#define XBE_NUM_ALTERNATE	16
#define XBE_LAN_KEY_LENGTH	16
#define XBE_SIGNATURE_KEY_LENGTH	16

#define XBE_MEDIA_TYPE_HARD_DISK		0x00000001
#define XBE_MEDIA_TYPE_DVD_X2			0x00000002
#define XBE_MEDIA_TYPE_DVD_CD			0x00000004
#define XBE_MEDIA_TYPE_CD			0x00000008
#define XBE_MEDIA_TYPE_DVD_5_RO			0x00000010
#define XBE_MEDIA_TYPE_DVD_9_RO			0x00000020
#define XBE_MEDIA_TYPE_DVD_5_RW			0x00000040
#define XBE_MEDIA_TYPE_DVD_9_RW			0x00000080
#define XBE_MEDIA_TYPE_DONGLE			0x00000100
#define XBE_MEDIA_TYPE_MEDIA_BOARD		0x00000200
#define XBE_MEDIA_TYPE_NONSECURE_HARD_DISK	0x40000000
#define XBE_MEDIA_TYPE_NONSECURE_MODE		0x80000000
#define XBE_MEDIA_TYPE_MEDIA_MASK		0x00FFFFFF

#define XBE_GAME_REGION_NA			0x00000001
#define XBE_GAME_REGION_JAPAN			0x00000002
#define XBE_GAME_REGION_RESTOFWORLD		0x00000004
#define XBE_GAME_REGION_MANUFACTURING		0x80000000

struct XBE_CERTIFICATE {
    uint32	size_of_certificate;
    uint32	timedate;
    uint32	title_id;
    uint16	title_name[XBE_TITLE_NAME_LENGTH];
    uint32	alternate_title_ids[XBE_NUM_ALTERNATE];
    uint32	allowed_media;
    uint32	game_region;
    uint32	game_ratings;
    uint32	disk_number;
    uint32	version;
    byte	lan_key[XBE_LAN_KEY_LENGTH];
    byte	signature_key[XBE_SIGNATURE_KEY_LENGTH];
    byte	alternate_signature_keys[XBE_NUM_ALTERNATE][XBE_SIGNATURE_KEY_LENGTH];    
} PACKED;


#define XBE_SECTION_FLAGS_WRITABLE	1
#define XBE_SECTION_FLAGS_PRELOAD	2
#define XBE_SECTION_FLAGS_EXECUTABLE	4
#define XBE_SECTION_FLAGS_INSERTEDFILE	8
#define XBE_SECTION_FLAGS_HEADPAGE_RO	16
#define XBE_SECTION_FLAGS_TAILPAGE_RO	32

#define XBE_SECTION_DIGEST_LENGTH	20

struct XBE_SECTION_HEADER {
    uint32	section_flags;
    uint32	virtual_address;
    uint32	virtual_size;
    uint32	raw_address;
    uint32	raw_size;
    uint32	section_name_address;
    uint32	section_name_ref_count;
    uint32	head_shared_page_ref_count_address;
    uint32	tail_shared_page_ref_count_address;
    byte	section_digest[XBE_SECTION_DIGEST_LENGTH];
} PACKED;

#define XBE_LIBRARY_NAME_LENGTH		8

struct XBE_LIBRARY_VERSION {
    byte	library_name[XBE_LIBRARY_NAME_LENGTH];
    uint16	major_version;
    uint16	minor_version;
    uint16	build_version;
    uint16	library_flags;
} PACKED;


struct XBE_TLS_DIRECTORY {
    uint32	data_start_address;
    uint32	data_end_address;
    uint32	tls_index_address;
    uint32	tls_callback_address;
    uint32	size_of_zero_fill;
    uint32	characteristics;
} PACKED;

extern byte XBE_IMAGE_HEADER_struct[];
extern byte XBE_CERTIFICATE_struct[];
extern byte XBE_SECTION_HEADER_struct[];
extern byte XBE_LIBRARY_VERSION_struct[];
extern byte XBE_TLS_DIRECTORY_struct[];


#endif