simple_tests with mhook

This commit is contained in:
2017-12-27 19:07:15 +01:00
parent 72af6439a7
commit 72b73ee462
8 changed files with 64 additions and 14 deletions

View File

@@ -8,21 +8,39 @@
#pragma comment(lib, "..\\x64\\debug\\test_cases.lib")
static TypeSmall trueSmall = &_small;
static TypeBranch trueBranch = &_branch;
static TypeRip_relative trueRip_Relative = &_rip_relative;
AbstractHookEngine* g_mhook = new MHook();
static uint64_t hookSmall(void) {
uint64_t MHook_Hooks::hookSmall(void) {
g_mhook->small_ = true;
return trueSmall();
}
uint64_t MHook_Hooks::hookBranch(uint64_t x) {
g_mhook->branch = true;
return trueBranch(x);
}
uint64_t MHook_Hooks::hookRip_relative(void) {
g_mhook->rip_relative = true;
return trueRip_Relative();
}
bool MHook::hook_all(void) {
return Mhook_SetHook((PVOID*)&trueSmall, hookSmall);
bool ret = Mhook_SetHook((PVOID*)&trueSmall, &MHook_Hooks::hookSmall);
ret |= Mhook_SetHook((PVOID*)&trueBranch, &MHook_Hooks::hookBranch);
ret |= Mhook_SetHook((PVOID*)&trueRip_Relative, &MHook_Hooks::hookRip_relative);
return ret;
}
bool MHook::unhook_all() {
return Mhook_Unhook((PVOID*)&trueSmall);
}
bool MHook::all_hooked() {
return true;
return Mhook_Unhook((PVOID*)&trueSmall) &&
Mhook_Unhook((PVOID*)&trueBranch) &&
Mhook_Unhook((PVOID*)&trueRip_Relative);
}