Waternoose, the XBOX 360 emulator
A very young XBOX 360 emulator that aims to boot games some day
Loading...
Searching...
No Matches
xex.h
1#pragma once
2
3#include <stdint.h>
4#include <stddef.h>
5#include <vector>
6#include <string>
7#include <kernel/Module.h>
8
10typedef struct
11{
12 char magic[4]; // "XEX2"
13 uint32_t module_flags;
14 uint32_t header_size;
15 uint32_t rsv0;
16 uint32_t sec_info_offset;
17 uint32_t optional_header_count;
19
21typedef struct
22{
23 uint32_t id;
24 union
25 {
26 uint32_t offset;
27 uint32_t value;
28 };
30
31typedef struct
32{
33 uint32_t info_size;
34 uint16_t encryption_type;
35 uint16_t compression_type;
37
38typedef struct
39{
40 uint32_t data_size;
41 uint32_t zero_size;
43
44typedef struct
45{
46 uint32_t blockSize;
47 uint8_t blockHash[20];
49
50typedef struct
51{
52 uint32_t windowSize;
53 normalCompressionBlock_t firstBlock;
55
56typedef struct
57{
58 uint32_t size;
59 struct
60 {
61 uint32_t size;
62 uint32_t count;
63 } stringTable;
65
66typedef struct
67{
68 union
69 {
70 uint32_t value;
71 struct
72 {
73 uint32_t info : 4;
74 uint32_t page_count : 28;
75 };
76 };
77 char data_digest[0x14];
79
80typedef struct
81{
82 uint32_t size;
83 char next_import_digest[0x14];
84 uint32_t id;
85 uint32_t version_value;
86 uint32_t version_min_value;
87 uint16_t name_index;
88 uint16_t count;
90
91typedef struct
92{
93 libraryHeader_t header;
94 std::vector<uint32_t> imports;
95 std::string name;
97
98typedef struct
99{
100 uint32_t magic[3];
101 uint32_t modulenumber[2];
102 uint32_t version[3];
103 uint32_t imagebaseaddr;
104 uint32_t count;
105 uint32_t base;
107
108extern uint32_t mainXexBase, mainXexSize;
109
110class XexLoader : public IModule
111{
112public:
116 XexLoader(uint8_t* buffer, size_t len, std::string path);
117
118 uint32_t GetEntryPoint() const;
119 uint32_t GetStackSize() const;
120
122 const std::vector<xexLibrary_t>& GetLibraries() const {return libraries;}
123 size_t GetLibraryIndexByName(const char* name) const;
124
126 const std::string& GetPath() const {return path;}
127
128 uint32_t LookupOrdinal(uint32_t ordinal);
129 virtual uint32_t GetHandle() const {return xexHandle;}
130private:
131 void ParseFileInfo(uint32_t offset);
132 void ParseLibraryInfo(uint32_t offset, xexLibrary_t& lib, int index, std::string& name);
133
134 int ReadImageBasicCompressed(uint8_t* buffer, size_t xex_len, char** outBuffer);
135 int ReadImageCompressed(uint8_t* buffer, size_t xex_len, char** outBuffer);
136
137 xexHeader_t header;
138 uint32_t xexHandle;
139
140 std::string path;
141
142 uint8_t* buffer;
143 uint8_t session_key[16];
144
145 uint16_t compressionFormat, encryptionFormat;
146 uint32_t fileInfoOffset = 0;
147 fileFormatInfo_t info;
148
149 uint32_t baseAddress;
150 uint32_t entryPoint;
151 uint32_t stackSize = 1024*1024;
152
153 uint32_t importBaseAddr;
154
155 uint32_t exportBaseAddr;
156
157 xexExport_t exportTable;
158
159 std::vector<xexLibrary_t> libraries;
160
161 uint32_t image_size();
162};
163
164extern XexLoader* xam;
XexLoader(uint8_t *buffer, size_t len, std::string path)
Loads a .xex file from a buffer into memory.
Definition xex.cpp:47
const std::string & GetPath() const
Returns the path of .xex file, minus the file name.
Definition xex.h:126
const std::vector< xexLibrary_t > & GetLibraries() const
Get the list of libraries imported by the .xex file.
Definition xex.h:122
Following the XEX header are xexHeader_t::optional_header_count optional headers, which either contai...
Definition xex.h:22
The header of a .xex file.
Definition xex.h:11