2019-09-17 09:24:20 +08:00
|
|
|
#ifndef MAIN_H
|
|
|
|
#define MAIN_H
|
|
|
|
|
|
|
|
#include "DLL.h"
|
|
|
|
#include <vector>
|
2019-10-17 07:35:25 +08:00
|
|
|
|
2019-09-17 09:24:20 +08:00
|
|
|
#define no_optimize __attribute__((optimize("O0")))
|
2019-10-17 07:35:25 +08:00
|
|
|
|
2019-09-17 09:24:20 +08:00
|
|
|
void WriteFarJMP(void* source, void* destination);
|
2019-10-17 07:35:25 +08:00
|
|
|
void Popup(const char* title, const char* msg );
|
|
|
|
void PrintLoadedMods();
|
|
|
|
|
|
|
|
#define MUST_IMPORT(dllname, name)\
|
|
|
|
dllname->name = GetProcAddress(dllname->handle, #name);\
|
|
|
|
if (!dllname->name) {\
|
|
|
|
char ERROR_MESSAGE_POPUP[512] = {0};\
|
|
|
|
sprintf(ERROR_MESSAGE_POPUP, "%s does not export " #name ".\n", dllname->fileName.c_str());\
|
|
|
|
Popup("Error", ERROR_MESSAGE_POPUP);\
|
|
|
|
exit(1);\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define IMPORT(dllname, name)\
|
|
|
|
dllname->name = GetProcAddress(dllname->handle, #name);
|
|
|
|
|
|
|
|
#define PUSH_ALL "push rax\npush rbx\npush rcx\npush rdx\npush rsi\npush rdi\npush rbp\npush r8\npush r9\npush r10\npush r11\npush r12\npush r13\npush r14\npush r15\n"
|
|
|
|
#define POP_ALL "pop r15\npop r14\npop r13\npop r12\npop r11\npop r10\npop r9\npop r8\npop rbp\npop rdi\npop rsi\npop rdx\npop rcx\npop rbx\npop rax\n"
|
|
|
|
|
|
|
|
#define PREPARE_STACK "mov rax, rsp \n and rsp, 0xFFFFFFFFFFFFFFF0 \n push rax \n sub rsp, 0x28 \n"
|
|
|
|
#define RESTORE_STACK "add rsp, 0x28 \n pop rsp \n"
|
|
|
|
|
2019-10-25 06:07:08 +08:00
|
|
|
#define GETTER_VAR(vartype, varname)\
|
|
|
|
static __attribute__((used)) vartype varname;\
|
|
|
|
extern "C" vartype Get_##varname(){return varname;}
|
|
|
|
|
|
|
|
#define DEREF_JMP(varname)\
|
|
|
|
"sub rsp, 8 \n"\
|
|
|
|
"push rax \n"\
|
|
|
|
"call Get_"#varname" \n"\
|
|
|
|
"mov [rsp+8], rax \n"\
|
|
|
|
"pop rax \n"\
|
|
|
|
"ret \n"
|
|
|
|
|
|
|
|
#define global static __attribute__((used))
|
|
|
|
|
|
|
|
void* Offset(void* x1, uint64_t x2);
|
|
|
|
|
2019-10-17 07:35:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-17 09:24:20 +08:00
|
|
|
|
|
|
|
#endif // MAIN_H
|