Cube-World-Mod-Launcher/CubeModLoader/main.h

37 lines
1.2 KiB
C++

#ifndef MAIN_H
#define MAIN_H
#include "DLL.h"
#include <vector>
#define no_optimize __attribute__((optimize("O0")))
void WriteFarJMP(void* source, void* destination);
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"
#endif // MAIN_H