aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2024-06-16 13:11:51 +0200
committerGitHub <noreply@github.com>2024-06-16 13:11:51 +0200
commit4a716e54f7a33ed5c2cf8bc2eb508fa1b2f4991a (patch)
tree91903eecd38f254a589ee5bfed3b41dce0e13e41
parent742c4a133a7313940da82bda4f3a51e3b84be594 (diff)
downloadNorthstarLauncher-4a716e54f7a33ed5c2cf8bc2eb508fa1b2f4991a.tar.gz
NorthstarLauncher-4a716e54f7a33ed5c2cf8bc2eb508fa1b2f4991a.zip
Check if hook target is non `null` before calling MinHook (#711)
-rw-r--r--primedev/core/hooks.cpp4
-rw-r--r--primedev/core/hooks.h4
2 files changed, 6 insertions, 2 deletions
diff --git a/primedev/core/hooks.cpp b/primedev/core/hooks.cpp
index 20f0cbef..6e849291 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 f842afbb..e5a65354 100644
--- a/primedev/core/hooks.h
+++ b/primedev/core/hooks.h
@@ -201,7 +201,9 @@ public:
}
}
- 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);