2021-02-08 01:18:57 +01:00
|
|
|
#ifndef TR1MAIN_UTIL_H
|
|
|
|
#define TR1MAIN_UTIL_H
|
|
|
|
|
|
|
|
#define FEATURE_NOCD_DATA
|
|
|
|
|
2021-02-09 20:58:31 +01:00
|
|
|
#include <stdint.h>
|
2021-02-10 16:03:02 +01:00
|
|
|
#include <stdio.h>
|
2021-02-08 01:18:57 +01:00
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
typedef struct {
|
2021-02-10 16:03:02 +01:00
|
|
|
uint8_t opcode; // must be 0xE9
|
2021-02-09 20:58:31 +01:00
|
|
|
uint32_t offset;
|
2021-02-08 01:18:57 +01:00
|
|
|
} JMP;
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
#define TRACE(...) \
|
|
|
|
{ \
|
|
|
|
printf("%s:%d %s ", __FILE__, __LINE__, __func__); \
|
|
|
|
printf(__VA_ARGS__); \
|
|
|
|
printf("\n"); \
|
|
|
|
fflush(stdout); \
|
|
|
|
}
|
2021-02-08 01:18:57 +01:00
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
#define VAR_U_(address, type) (*(type*)(address))
|
|
|
|
#define VAR_I_(address, type, value) (*(type*)(address))
|
|
|
|
#define ARRAY_(address, type, length) (*(type(*) length)(address))
|
2021-02-08 01:18:57 +01:00
|
|
|
|
2021-02-13 14:58:42 +01:00
|
|
|
void TR1MInjectFunc(void* from, void* to);
|
|
|
|
void TR1MPrintStackTrace();
|
2021-02-08 01:18:57 +01:00
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
#define INJECT(from, to) \
|
|
|
|
{ \
|
2021-02-13 14:58:42 +01:00
|
|
|
TR1MInjectFunc((void*)from, (void*)to); \
|
2021-02-10 16:03:02 +01:00
|
|
|
}
|
2021-02-08 01:18:57 +01:00
|
|
|
|
|
|
|
#endif
|