2021-02-22 21:44:20 +01:00
|
|
|
#ifndef T1M_UTIL_H
|
|
|
|
#define T1M_UTIL_H
|
2021-02-08 01:18:57 +01:00
|
|
|
|
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-22 21:41:45 +01:00
|
|
|
#define TRACE(...) T1MTraceFunc(__FILE__, __LINE__, __func__, __VA_ARGS__)
|
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-22 21:41:45 +01:00
|
|
|
void T1MTraceFunc(
|
2021-02-22 00:59:38 +01:00
|
|
|
const char* file, int line, const char* func, const char* fmt, ...);
|
2021-02-22 21:39:37 +01:00
|
|
|
void T1MInjectFunc(void* from, void* to);
|
2021-02-22 21:41:45 +01:00
|
|
|
void T1MPrintStackTrace();
|
2021-02-08 01:18:57 +01:00
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
#define INJECT(from, to) \
|
|
|
|
{ \
|
2021-02-22 21:39:37 +01:00
|
|
|
T1MInjectFunc((void*)from, (void*)to); \
|
2021-02-10 16:03:02 +01:00
|
|
|
}
|
2021-02-08 01:18:57 +01:00
|
|
|
|
|
|
|
#endif
|