mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2025-12-06 12:14:54 +01:00
Fix build
This commit is contained in:
parent
1785ae6eaf
commit
b9cd9ae6c2
26 changed files with 1544 additions and 109 deletions
|
|
@ -8,68 +8,20 @@
|
|||
|
||||
#include "../detours/detours.h"
|
||||
|
||||
void Base_Hook::BeginHook()
|
||||
{
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
}
|
||||
#define DETOUR_HOOKBEGIN DetourTransactionBegin
|
||||
#define DETOUR_UPDATETHREAD() DetourUpdateThread(GetCurrentThread())
|
||||
#define DETOUR_ENDHOOK DetourTransactionCommit
|
||||
#define DETOUR_HOOK DetourAttach
|
||||
#define DETOUR_UNHOOK DetourDetach
|
||||
|
||||
void Base_Hook::EndHook()
|
||||
{
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
|
||||
void Base_Hook::HookFunc(std::pair<void**, void*> hook)
|
||||
{
|
||||
if( DetourAttach(hook.first, hook.second) == 0 )
|
||||
_hooked_funcs.emplace_back(hook);
|
||||
}
|
||||
|
||||
void Base_Hook::UnhookAll()
|
||||
{
|
||||
if (_hooked_funcs.size())
|
||||
{
|
||||
BeginHook();
|
||||
std::for_each(_hooked_funcs.begin(), _hooked_funcs.end(), [](std::pair<void**, void*>& hook) {
|
||||
DetourDetach(hook.first, hook.second);
|
||||
});
|
||||
EndHook();
|
||||
_hooked_funcs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#elif defined(__LINUX__)
|
||||
#include "linux/Linux_Detour.h"
|
||||
|
||||
void Base_Hook::BeginHook()
|
||||
{
|
||||
Linux_Detour::transaction_begin();
|
||||
Linux_Detour::update_thread(pthread_self());
|
||||
}
|
||||
|
||||
void Base_Hook::EndHook()
|
||||
{
|
||||
Linux_Detour::transaction_commit();
|
||||
}
|
||||
|
||||
void Base_Hook::HookFunc(std::pair<void**, void*> hook)
|
||||
{
|
||||
if( Linux_Detour::hook_func(hook.first, hook.second) == 0 )
|
||||
_hooked_funcs.emplace_back(hook);
|
||||
}
|
||||
|
||||
void Base_Hook::UnhookAll()
|
||||
{
|
||||
if (_hooked_funcs.size())
|
||||
{
|
||||
BeginHook();
|
||||
std::for_each(_hooked_funcs.begin(), _hooked_funcs.end(), [](std::pair<void**, void*>& hook) {
|
||||
Linux_Detour::unhook_func(hook.first, hook.second);
|
||||
});
|
||||
EndHook();
|
||||
_hooked_funcs.clear();
|
||||
}
|
||||
}
|
||||
#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
|
||||
|
||||
|
|
@ -87,4 +39,34 @@ const char* Base_Hook::get_lib_name() const
|
|||
return "<no_name>";
|
||||
}
|
||||
|
||||
void Base_Hook::BeginHook()
|
||||
{
|
||||
DETOUR_HOOKBEGIN();
|
||||
DETOUR_UPDATETHREAD();
|
||||
}
|
||||
|
||||
void Base_Hook::EndHook()
|
||||
{
|
||||
DETOUR_ENDHOOK();
|
||||
}
|
||||
|
||||
void Base_Hook::HookFunc(std::pair<void**, void*> hook)
|
||||
{
|
||||
if( DETOUR_HOOK(hook.first, hook.second) == 0 )
|
||||
_hooked_funcs.emplace_back(hook);
|
||||
}
|
||||
|
||||
void Base_Hook::UnhookAll()
|
||||
{
|
||||
if (_hooked_funcs.size())
|
||||
{
|
||||
BeginHook();
|
||||
std::for_each(_hooked_funcs.begin(), _hooked_funcs.end(), [](std::pair<void**, void*>& hook) {
|
||||
DETOUR_UNHOOK(hook.first, hook.second);
|
||||
});
|
||||
EndHook();
|
||||
_hooked_funcs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#endif//NO_OVERLAY
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue