diff options
Diffstat (limited to 'primedev/core/hooks.h')
-rw-r--r-- | primedev/core/hooks.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/primedev/core/hooks.h b/primedev/core/hooks.h index e5a65354..facf51bf 100644 --- a/primedev/core/hooks.h +++ b/primedev/core/hooks.h @@ -3,7 +3,33 @@ #include <string> #include <iostream> -void InstallInitialHooks(); +//----------------------------------------------------------------------------- +// Purpose: Init minhook +//----------------------------------------------------------------------------- +void HookSys_Init(); + +//----------------------------------------------------------------------------- +// Purpose: MH_MakeHook wrapper +// Input : *ppOriginal - Original function being detoured +// pDetour - Detour function +//----------------------------------------------------------------------------- +inline void HookAttach(PVOID* ppOriginal, PVOID pDetour) +{ + PVOID pAddr = *ppOriginal; + if (MH_CreateHook(pAddr, pDetour, ppOriginal) == MH_OK) + { + if (MH_EnableHook(pAddr) != MH_OK) + { + spdlog::error("Failed enabling a function hook!"); + } + } + else + { + spdlog::error("Failed creating a function hook!"); + } +} + +void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress); typedef void (*DllLoadCallbackFuncType)(CModule moduleAddress); void AddDllLoadCallback(std::string dll, DllLoadCallbackFuncType callback, std::string tag = "", std::vector<std::string> reliesOn = {}); |