-
Notifications
You must be signed in to change notification settings - Fork 1
/
hook.h
28 lines (22 loc) · 1.07 KB
/
hook.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
#pragma once
#ifndef HOOK_H
#define HOOK_H
#include <windows.h>
// 4DModLoader-Core hooking stuff for multihooking yea
inline void __stdcall Hook(LPVOID target, LPVOID detour, LPVOID* original) {
reinterpret_cast<void(__stdcall*)(LPVOID target, LPVOID detour, LPVOID * original)>(GetProcAddress(GetModuleHandleA("4DModLoader-Core.dll"), "Hook"))(target, detour, original);
}
template<typename FuncPtr> inline void Hook( unsigned long long target, FuncPtr detour, FuncPtr* original ) {
static_assert(
std::is_function<typename std::remove_pointer<FuncPtr>::type>::value,
"Hook must be called with a function and a pointer to a function of identical signature"
);
Hook( reinterpret_cast<LPVOID>(target), reinterpret_cast<LPVOID>(detour), reinterpret_cast<LPVOID*>(original) );
}
inline void __stdcall EnableHook(LPVOID target){ // enables specific hook.
reinterpret_cast<void(__stdcall*)(LPVOID target)>(GetProcAddress(GetModuleHandleA("4DModLoader-Core.dll"), "EnableHook"))(target);
}
inline void EnableHook(){ // enables every hook.
EnableHook(nullptr);
}
#endif // !HOOK_H