diff --git a/primedev/core/hooks.cpp b/primedev/core/hooks.cpp index 20f0cbef1..6e8492914 100644 --- a/primedev/core/hooks.cpp +++ b/primedev/core/hooks.cpp @@ -104,7 +104,9 @@ bool ManualHook::Dispatch(LPVOID addr, LPVOID* orig) if (orig) ppOrigFunc = orig; - if (MH_CreateHook(addr, pHookFunc, ppOrigFunc) == MH_OK) + if (!addr) + spdlog::error("Address for hook {} is invalid", pFuncName); + else if (MH_CreateHook(addr, pHookFunc, ppOrigFunc) == MH_OK) { if (MH_EnableHook(addr) == MH_OK) { diff --git a/primedev/core/hooks.h b/primedev/core/hooks.h index f842afbb9..e5a653549 100644 --- a/primedev/core/hooks.h +++ b/primedev/core/hooks.h @@ -201,7 +201,9 @@ class __autohook } } - if (MH_CreateHook(targetAddr, pHookFunc, ppOrigFunc) == MH_OK) + if (!targetAddr) + spdlog::error("Address for hook {} is invalid", pFuncName); + else if (MH_CreateHook(targetAddr, pHookFunc, ppOrigFunc) == MH_OK) { if (MH_EnableHook(targetAddr) == MH_OK) spdlog::info("Enabling hook {}", pFuncName);