From dd1a21dae9eadea4e657312ab51058786ba54eea Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Tue, 15 Oct 2019 17:32:47 +0200 Subject: [PATCH] Clean Linux hook, not needed Linux uses LD_PRELOAD to load the overlay --- overlay_experimental/Base_Hook.cpp | 60 +++++++++++++++++++----------- scripts/find_interfaces.sh | 0 2 files changed, 38 insertions(+), 22 deletions(-) mode change 100644 => 100755 scripts/find_interfaces.sh diff --git a/overlay_experimental/Base_Hook.cpp b/overlay_experimental/Base_Hook.cpp index a9889c0f..e660729a 100644 --- a/overlay_experimental/Base_Hook.cpp +++ b/overlay_experimental/Base_Hook.cpp @@ -8,23 +8,6 @@ #include "../detours/detours.h" -#define DETOUR_HOOKBEGIN DetourTransactionBegin -#define DETOUR_UPDATETHREAD() DetourUpdateThread(GetCurrentThread()) -#define DETOUR_ENDHOOK DetourTransactionCommit -#define DETOUR_HOOK DetourAttach -#define DETOUR_UNHOOK DetourDetach - -#elif defined(__LINUX__) -#include "linux/Linux_Detour.h" - -#define DETOUR_HOOKBEGIN Linux_Detour::transaction_begin -#define DETOUR_UPDATETHREAD() Linux_Detour::update_thread(pthread_self()) -#define DETOUR_ENDHOOK Linux_Detour::transaction_commit -#define DETOUR_HOOK Linux_Detour::hook_func -#define DETOUR_UNHOOK Linux_Detour::unhook_func - -#endif - Base_Hook::Base_Hook(): _library(nullptr) {} @@ -41,18 +24,18 @@ const char* Base_Hook::get_lib_name() const void Base_Hook::BeginHook() { - DETOUR_HOOKBEGIN(); - DETOUR_UPDATETHREAD(); + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); } void Base_Hook::EndHook() { - DETOUR_ENDHOOK(); + DetourTransactionCommit(); } void Base_Hook::HookFunc(std::pair hook) { - if( DETOUR_HOOK(hook.first, hook.second) == 0 ) + if( DetourAttach(hook.first, hook.second) == 0 ) _hooked_funcs.emplace_back(hook); } @@ -62,11 +45,44 @@ void Base_Hook::UnhookAll() { BeginHook(); std::for_each(_hooked_funcs.begin(), _hooked_funcs.end(), [](std::pair& hook) { - DETOUR_UNHOOK(hook.first, hook.second); + DetourDetach(hook.first, hook.second); }); EndHook(); _hooked_funcs.clear(); } } +#else + +Base_Hook::Base_Hook(): + _library(nullptr) +{} + +Base_Hook::~Base_Hook() +{ +} + +const char* Base_Hook::get_lib_name() const +{ + return ""; +} + +void Base_Hook::BeginHook() +{ +} + +void Base_Hook::EndHook() +{ +} + +void Base_Hook::HookFunc(std::pair hook) +{ +} + +void Base_Hook::UnhookAll() +{ +} + +#endif + #endif//NO_OVERLAY diff --git a/scripts/find_interfaces.sh b/scripts/find_interfaces.sh old mode 100644 new mode 100755