#include "Base_Hook.h" #include #include "Hook_Manager.h" #include "../detours/detours.h" Base_Hook::~Base_Hook() { UnhookAll(); } void Base_Hook::BeginHook() { DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); } void Base_Hook::EndHook() { DetourTransactionCommit(); } void Base_Hook::UnhookAll() { if (_hooked_funcs.size()) { BeginHook(); std::for_each(_hooked_funcs.begin(), _hooked_funcs.end(), [](std::pair& hook) { DetourDetach(hook.first, hook.second); }); EndHook(); _hooked_funcs.clear(); } } void Base_Hook::HookFuncs(std::pair hook) { DetourAttach(hook.first, hook.second); }