1
0
Fork 0
mirror of https://gitlab.com/Mr_Goldberg/goldberg_emulator.git synced 2024-11-14 10:50:13 +01:00

Clean Linux hook, not needed

Linux uses LD_PRELOAD to load the overlay
This commit is contained in:
Nemirtingas 2019-10-15 17:32:47 +02:00
parent 55ba49c957
commit dd1a21dae9
2 changed files with 38 additions and 22 deletions

View file

@ -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<void**, void*> 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<void**, void*>& 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 "<no_name>";
}
void Base_Hook::BeginHook()
{
}
void Base_Hook::EndHook()
{
}
void Base_Hook::HookFunc(std::pair<void**, void*> hook)
{
}
void Base_Hook::UnhookAll()
{
}
#endif
#endif//NO_OVERLAY

0
scripts/find_interfaces.sh Normal file → Executable file
View file