mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-09 01:10:34 +00:00
f096a2d8a2
LoadLibrary increase the reference count to the library. So we make sure this library is still loaded when we shut down the hook.
50 lines
955 B
C++
50 lines
955 B
C++
#ifndef __INCLUDED_BASE_HOOK_H__
|
|
#define __INCLUDED_BASE_HOOK_H__
|
|
|
|
#include "../dll/base.h"
|
|
|
|
#ifndef NO_OVERLAY
|
|
|
|
#include <vector>
|
|
#include <utility>
|
|
|
|
class Base_Hook
|
|
{
|
|
protected:
|
|
std::vector<std::pair<void**, void*>> _hooked_funcs;
|
|
|
|
void* _library;
|
|
bool _hooked;
|
|
|
|
Base_Hook(const Base_Hook&) = delete;
|
|
Base_Hook(Base_Hook&&) = delete;
|
|
Base_Hook& operator =(const Base_Hook&) = delete;
|
|
Base_Hook& operator =(Base_Hook&&) = delete;
|
|
|
|
public:
|
|
Base_Hook();
|
|
virtual ~Base_Hook();
|
|
|
|
void BeginHook();
|
|
void EndHook();
|
|
void UnhookAll();
|
|
|
|
void HookFunc(std::pair<void**, void*> hook);
|
|
|
|
template<typename T>
|
|
void HookFuncs(std::pair<T*, T> funcs)
|
|
{
|
|
HookFunc(funcs);
|
|
}
|
|
|
|
template<typename T, typename ...Args>
|
|
void HookFuncs(std::pair<T*, T> funcs, Args... args)
|
|
{
|
|
HookFunc(funcs);
|
|
HookFuncs(args...);
|
|
}
|
|
};
|
|
|
|
#endif//NO_OVERLAY
|
|
|
|
#endif//__INCLUDED_BASE_HOOK_H__
|