I tried to hook a member varialbe. well shit I mean it kinda has to have a similar name, doesn't it
88 lines
2.3 KiB
C++
88 lines
2.3 KiB
C++
#include <iostream>
|
|
#include <iomanip>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include "..\third_party\poly\PolyHook\PolyHook.hpp"
|
|
#include "typedefs.h"
|
|
#include "abstracthook.h"
|
|
#include "PolyHook.h"
|
|
|
|
#pragma comment(lib, "..\\x64\\debug\\test_cases.lib")
|
|
|
|
static TypeSmall trueSmall = nullptr;
|
|
static TypeBranch trueBranch = nullptr;
|
|
static TypeRip_relative trueRip_Relative = nullptr;
|
|
static TypeAVX trueAVX = nullptr;
|
|
static TypeRDRAND trueRDRAND = nullptr;
|
|
static TypeLoop trueLoop = nullptr;
|
|
static TypeTailRecursion trueTailRecursion = nullptr;
|
|
|
|
AbstractHookEngine* g_PolyHook = new PolyHook();
|
|
|
|
uint64_t PolyHook_Hooks::hookSmall(void) {
|
|
g_PolyHook->small_ = true;
|
|
|
|
return trueSmall();
|
|
}
|
|
|
|
uint64_t PolyHook_Hooks::hookBranch(uint64_t x) {
|
|
g_PolyHook->branch = true;
|
|
|
|
return trueBranch(x);
|
|
}
|
|
|
|
uint64_t PolyHook_Hooks::hookRip_relative(void) {
|
|
g_PolyHook->rip_relative = true;
|
|
|
|
return trueRip_Relative();
|
|
}
|
|
|
|
void PolyHook_Hooks::hookAVX(float num, void* res) {
|
|
g_PolyHook->avx = true;
|
|
|
|
trueAVX(num, res);
|
|
}
|
|
|
|
uint32_t PolyHook_Hooks::hookRDRAND(void) {
|
|
g_PolyHook->rdrand = true;
|
|
|
|
return trueRDRAND();
|
|
}
|
|
|
|
uint32_t PolyHook_Hooks::hookLoop(uint32_t num, uint32_t cnt) {
|
|
g_PolyHook->loop = true;
|
|
|
|
return trueLoop(num, cnt);
|
|
}
|
|
|
|
uint32_t PolyHook_Hooks::hookTail_recursion(uint32_t x) {
|
|
g_PolyHook->tail_recursion = true;
|
|
|
|
return trueTailRecursion(x);
|
|
}
|
|
|
|
bool PolyHook::hook_all(void) {
|
|
bool ret = hook<decltype(&_small)>(detSmall, &_small, trueSmall, &PolyHook_Hooks::hookSmall);
|
|
ret |= hook<decltype(&_branch)>(detBranch, &_branch, trueBranch, &PolyHook_Hooks::hookBranch);
|
|
ret |= hook<decltype(&_rip_relative)>(detRIPRelative, &_rip_relative, trueRip_Relative, &PolyHook_Hooks::hookRip_relative);
|
|
|
|
ret |= hook<decltype(&_AVX)>(detAVX, &_AVX, trueAVX, &PolyHook_Hooks::hookAVX);
|
|
ret |= hook<decltype(&_RDRAND)>(detRDRAND, &_RDRAND, trueRDRAND, &PolyHook_Hooks::hookRDRAND);
|
|
|
|
ret |= hook<decltype(&_loop)>(detLoop, &_loop, trueLoop, &PolyHook_Hooks::hookLoop);
|
|
ret |= hook<decltype(&_tail_recursion)>(detTailRecursion, &_tail_recursion, trueTailRecursion, &PolyHook_Hooks::hookTail_recursion);
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool PolyHook::unhook_all() {
|
|
detSmall->UnHook();
|
|
detBranch->UnHook();
|
|
detRIPRelative->UnHook();
|
|
detAVX->UnHook();
|
|
detRDRAND->UnHook();
|
|
detLoop->UnHook();
|
|
detTailRecursion->UnHook();
|
|
|
|
return true;
|
|
} |