-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRuntime.h
39 lines (31 loc) · 960 Bytes
/
Runtime.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
#pragma once
#include "MinHook.h"
#include "ProxyTypes.h"
#include "asmjit/x86.h"
#include <iostream>
namespace Runtime {
extern HMODULE GameCore;
extern uintptr_t GameCoreAddress;
extern asmjit::JitRuntime Jit;
// Should only be called once
extern void Create();
// Call on dll exit
extern void Destroy();
void InitMinHook();
template <typename T>
T GetGameCoreGlobalAt(uintptr_t address) {
return reinterpret_cast<T>(GameCoreAddress + address);
}
template <typename T>
void CreateHook(LPVOID pTarget, LPVOID pDetour, T** ppOriginal) {
MH_STATUS status;
if ((status = MH_CreateHook(pTarget, pDetour, reinterpret_cast<LPVOID*>(ppOriginal))) != MH_OK) {
std::cout << "Failed to load hook! " << MH_StatusToString(status) << "\n";
}
if ((status = MH_EnableHook(pTarget)) != MH_OK) {
std::cout << "Failed to enable hook! " << MH_StatusToString(status) << "\n";
}
}
extern void InitConsole();
extern void CloseConsole();
};