-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglobal.h
477 lines (413 loc) · 9.81 KB
/
global.h
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
// Global header file
#define WIN32_LEAN_AND_MEAN
#define CINTERFACE
#include <windows.h>
#include <cstdio>
#include <io.h>
#include <d3d9.h>
#define _USE_MATH_DEFINES
#include <map>
#include <cmath>
#include <cassert>
#include <cstdint>
#include <cfloat>
#include <vector>
#include "vecmat.h"
#define tstringify(x) #x
#define sstringify(x) tstringify(x)
#ifdef PATCHVERSTR
#define INSPECTOR_VERSION "v" sstringify(PATCHVERSTR)
#else
#define INSPECTOR_VERSION "DEV"
#endif
#define naked __declspec(naked)
/*
#define callvf(p, f) \
__asm mov ecx, p \
__asm mov eax, [ecx] \
__asm call [eax+f*4]
*/
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
template<class T> struct KVector {
T *_data;
size_t _capacity;
size_t _size;
T *begin() {return _data;}
T *end() {return _data + _size;}
size_t size() const {return _size;}
size_t capacity() const {return _capacity;}
};
struct SGameStartInfo {
HWND hwnd;
uint width, height;
uint unk1, unk2;
char fullscreen;
};
struct KFile;
struct KClass {
virtual void destructor_placeholder() = 0;
virtual char isSubclass(int cls) = 0;
virtual void reset() = 0;
#if XXLVER >= 2
virtual void unknown2() = 0;
#endif
virtual int getClassGroup() = 0;
virtual int getClassID() = 0;
virtual int sendEvent(int event, void *param) = 0;
virtual char unknown3(void *arg0, void *arg4, void *arg8, void *argC) = 0;
virtual int unknown4(void *arg0) = 0;
//virtual int unknown5(void *arg0, void *arg4) = 0;
virtual int serialize(KFile *file, void *arg4) = 0;
virtual int deserialize(KFile *file, void *arg4) = 0;
char isSubclass(int clgrp, int clid) {
return isSubclass(clgrp | (clid << 6));
}
};
struct KclInfos {
struct Tab {
void *pnt;
uint allocatedSize;
uint numElements;
};
void *vtbl;
Tab cls[15];
};
struct CKLoadingManager;
struct KFile {
void *rwFile; // renderware interface
uint32_t unk2;
void *savingManager;
CKLoadingManager *loadingManager;
virtual void unknown0(void* a, void* b, void* c) {abort();}; // Returns 0
virtual void unknown1(void* a, void* b, void* c) {abort();};
virtual void unknown2(void* a) {abort();};
#if XXLVER == 1
virtual void unknownX(void* a) {abort();};
#endif
virtual void unknown3() {abort();};
virtual void read(void *dst, size_t size) = 0;
virtual void write(void *src, size_t size) = 0;
virtual void seek(int32_t, int where) {abort();};
};
struct CKLoadingManager {
//0x2AC
#if XXLVER == 1
char unknown[0x480];
#elif XXLVER == 2
uint uu0;
uint uu1;
KClass **gameObjects;
uint numGameObjects;
char unknown[0x284];
// char unknown[0x294];
#elif XXLVER == 4
uint uu0;
uint uu1;
KClass **gameObjects;
uint numGameObjects;
char unknown[0x288];
//char unknown[0x298];
#endif
uint currentSector;
uint ss0;
uint ss1;
uint ss2;
uint sectorToLoad;
virtual void unknown00() = 0;
virtual void unknown04() = 0;
virtual void unknown08() = 0;
virtual void unknown0C() = 0;
virtual void unknown10() = 0;
virtual void unknown14() = 0;
virtual void unknown18() = 0;
virtual void unknown1C() = 0;
virtual void readRef(KFile *file, KClass **refPointer) = 0;
};
struct CKYellowPages {
#if XXLVER == 1
void *p_00,*p_04,*p_08,*p_0C;
void *p_10,*p_14,*p_18; KclInfos* kclInfos;
void *p_20,*p_24,*p_28,*p_2C;
void *gameLoop,*p_34,*p_38,*p_3C;
void *p_40; CKLoadingManager* loadingManager; void* savingManager, *p_4C;
void *srvCollision,*p_54,*p_58,*p_5C;
void *p_60,*p_64,*p_68,*p_6C;
void *p_70,*p_74,*srvBeacon,*p_7C;
void *p_80,*p_84,*p_88,*gameManager;
#elif XXLVER == 2
void *p_00,*p_04,*p_08,*p_0C;
void *p_10,*p_14,*p_18; KclInfos* kclInfos;
void *p_20,*p_24,*p_28,*p_2C;
void *gameLoop,*p_34,*p_38,*p_3C;
void *p_40,*p_44; CKLoadingManager* loadingManager; void*p_4C;
void *p_50,*p_54,*p_58,*p_5C;
void *p_60,*p_64,*p_68,*p_6C;
void *p_70,*p_74,*p_78,*p_7C;
void *gameManager;
#elif XXLVER == 4
void *a;
void *p_00,*p_04,*p_08,*p_0C;
void *p_10,*p_14,*p_18; KclInfos* kclInfos;
void *p_20,*p_24,*p_28,*p_2C;
void *gameLoop,*p_34,*p_38,*p_3C;
void *b;
void *p_40; CKLoadingManager* loadingManager; void*p_48,*p_4C;
void *p_50,*p_54,*p_58,*p_5C;
void *p_60,*p_64,*p_68,*p_6C;
void *p_70,*p_74;
void *p_80,*p_84,*p_88,*gameManager;
#endif
};
struct CMatrix {
void *u[4];
float c[16];
float d[16];
};
struct CNode : KClass {
//void *vtbl;
CMatrix *matrix;
CNode *nextNode;
CNode *parentNode;
void *p_10, *p_14;
#ifdef REMASTER
void *p_18, *p_1C;
#endif
CNode *childNode;
void *geometry;
#ifdef REMASTER
char name[];
#endif
};
struct KHook : KClass {
KHook *nextHook;
int unk_08;
#if XXLVER == 1
KClass *life;
CNode *node;
#endif
};
struct KGroup : KClass {
#if XXLVER < 2
KGroup *next;
int unk_08; // Could be a boolean value?
KGroup *child;
int unk_10;
KGroup *parent;
KClass *life;
KClass *bundle;
KHook *hook;
#else
int unk_04;
int unk_08;
int unk_0C;
int unk_10;
KGroup *next;
KGroup *child;
KGroup *parent;
int unk_20;
KClass *bundle;
KHook *hook;
#endif
};
struct CKService : KClass {
CKService *next;
int cunknown;
};
#if XXLVER >= 2
struct KAction {
void *param;
KClass *object;
uint16_t type, aaa;
};
struct CKTriggerDomain;
struct CKTrigger;
struct CKCondition;
struct CKComparedData;
struct CKSrvTrigger : CKService {
CKTriggerDomain *rootDomain;
};
struct CKTriggerDomain : KClass {
KVector<CKTrigger*> triggers;
KVector<CKTriggerDomain*> subdomains;
};
struct CKTrigger : KClass {
#if XXLVER >= 4 // TODO: unsure if 4 or 3, but not 2
uint32_t unk1, unk2;
#endif
CKCondition *condition;
KAction *actions;
size_t numActions;
};
struct CKCondition : KClass {
CKCondition *next;
};
struct CKCombiner : CKCondition {
int flags; // 0=and, 4=ior
CKCondition *firstCondition;
};
struct CKComparator : CKCondition {
int flags;
// 00: <=
// 01: negation
// 04: >=
// 08: ==
CKComparedData *left, *right;
};
struct CKComparedData : KClass {
void *data;
int unk1, unk2;
int type : 4; // 0: obj bool/byte, 1: obj int, 4: const bool/byte, 5: const int, 8: ?
int : 0;
};
#endif
typedef size_t (__cdecl *pfm_msize)(void *memblock);
//#define ax_msize ((pfm_msize)0x60FB19)
typedef void (__thiscall *pfKfRefToPnt)(void* _this, uint *ref);
#if XXLVER == 1
#ifndef REMASTER
// XXL 1 Original
#define kfRefToPnt ((pfKfRefToPnt)0x40D2C0)
#define yellowPages (*(CKYellowPages**)0x6621F4)
#define axWndProc 0x479C10
#define m_CKGameManager_currentLevel 4
#define m_CKGameManager_nextLevel 8
#define m_CKGameManager_levelObject 0x20
#define m_CKLevel_currentSector 0x24
#define m_CKLevel_nextSector 0x34
#pragma pack(push, 1)
struct ClassContainer {
void *objects;
uint flags;
void *u1;
ushort u2, count;
ushort clSize; char pl, u3;
};
#pragma pack(pop)
#else
// XXL1 Remaster
extern uint32_t exeRebase;
//#define kfRefToPnt ((pfKfRefToPnt)0x40D2C0) // TO REMOVE
#define yellowPages (*(CKYellowPages**)(0x112D064 + exeRebase)) // (*(CKYellowPages**)0x01128FEC)
#define axWndProc DefWindowProcA
#define m_CKGameManager_currentLevel 4
#define m_CKGameManager_nextLevel 8
#define m_CKGameManager_levelObject 0x20
#define m_CKLevel_currentSector 0x24
#define m_CKLevel_nextSector 0x1480
#pragma pack(push, 1)
struct ClassContainer {
void *objects;
uint flags;
void *u1;
ushort u2, count;
ushort clSize; char pl, u3;
};
#pragma pack(pop)
#endif
#elif XXLVER == 2
#ifndef REMASTER
// XXL 2 Original
#define kfRefToPnt ((pfKfRefToPnt)0x40ED30)
#define yellowPages (*(CKYellowPages**)0x663D04)
#define axWndProc 0x49B190
#define m_CKGameManager_currentLevel 0x6C
#define m_CKGameManager_nextLevel 0x70
#define m_CKGameManager_levelObject 0x18
#define m_CKLevel_currentSector 0x1C
#define m_CKLevel_nextSector 0x2C
#pragma pack(push, 1)
struct ClassContainer {
//0x00:
void *objects;
void *u0;
uint flags;
void *u1;
//0x10:
ushort u2, count;
ushort u3, clSize;
char pl, u4; ushort u5;
};
#pragma pack(pop)
#else
// XXL 2 Remaster
extern uint32_t exeRebase;
//#define kfRefToPnt ((pfKfRefToPnt)0x40ED30) // TO REMOVE
#define yellowPages (*(CKYellowPages**)(0xF597FC + exeRebase))
#define axWndProc DefWindowProcA
#define m_CKGameManager_currentLevel 0x54
#define m_CKGameManager_nextLevel 0x58
#define m_CKGameManager_levelObject 0x1C
#define m_CKLevel_currentSector 0x20
#define m_CKLevel_nextSector 0x30
#pragma pack(push, 1)
struct ClassContainer {
//0x00:
void *objects;
void *u0;
uint flags;
void *u1;
//0x10:
ushort u2, count;
ushort u3, clSize;
char pl, u4; ushort u5;
};
#pragma pack(pop)
#endif
#elif XXLVER == 4
#define kfRefToPnt ((pfKfRefToPnt)0x40CE40)
#define yellowPages (*(CKYellowPages**)0x765BF8)
#define axWndProc 0x4DB0C0
#define m_CKGameManager_currentLevel 0x1A0
#define m_CKGameManager_nextLevel 0x1A4
#define m_CKGameManager_levelObject 0x18
#define m_CKLevel_currentSector 0x1C
#define m_CKLevel_nextSector 0x2C
#pragma pack(push, 1)
struct ClassContainer {
//0x00:
void *objects;
void *u0;
uint flags;
void *u1;
//0x10:
ushort u2, count;
ushort u3, clSize;
char pl, u4; ushort u5;
};
#pragma pack(pop)
#else
#error Incorrect XXL version. Be sure that the XXLVER macro is defined and set to 1, 2 or 4.
#endif
typedef struct
{
void **lpVtbl;
IDirect3D9 *original;
} HDirect3D9;
typedef struct
{
void **lpVtbl;
IDirect3DDevice9 *original;
HDirect3D9 *d3d;
} HDirect3DDevice9;
extern char title[];
//extern char setting_higher_time_precision;
extern IDirect3DDevice9 *gamed3ddev;
extern FILE *logfile;
extern void *odmvtbld[], *devvtbld[];
extern SGameStartInfo* gameStartInfo;
//extern CKYellowPages* yellowPages;
extern std::map<KClass*, char*> lvlObjectNames[32], gameObjectNames;
extern uint lvlNumSectors;
extern bool enableCrateRandomizer, g_cheat_bonusRandomizer;
extern HWND oWindow;
void SetImmediateJump(void *p, uint j);
void SetMemProtection(void *mem, int flags);
void IGInit();
void IGNewFrame();
void IGDX9Render();
void IGGL3Render();
void IGDX9Reset();
LRESULT __stdcall IGWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
char *getClassName(int grp, int id);