aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/hooks.cpp
diff options
context:
space:
mode:
authorBobTheBob9 <for.oliver.kirkham@gmail.com>2022-07-10 22:21:29 +0100
committerBobTheBob9 <for.oliver.kirkham@gmail.com>2022-07-10 22:21:29 +0100
commit0a9a44ce15bb772b3193fbee481768e7327db1a9 (patch)
tree855b235161de35ade7d86ce2d847483aa46b31e4 /NorthstarDLL/hooks.cpp
parent2ae34b67e36b8ba05132d481876eb4ed7a826283 (diff)
downloadNorthstarLauncher-0a9a44ce15bb772b3193fbee481768e7327db1a9.tar.gz
NorthstarLauncher-0a9a44ce15bb772b3193fbee481768e7327db1a9.zip
completely remove old hooking
Diffstat (limited to 'NorthstarDLL/hooks.cpp')
-rw-r--r--NorthstarDLL/hooks.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/NorthstarDLL/hooks.cpp b/NorthstarDLL/hooks.cpp
index d41f0f74..3c5438cd 100644
--- a/NorthstarDLL/hooks.cpp
+++ b/NorthstarDLL/hooks.cpp
@@ -140,6 +140,24 @@ void AddDllLoadCallbackForClient(std::string dll, DllLoadCallbackFuncType callba
AddDllLoadCallback(dll, callback, tag, reliesOn);
}
+void MakeHook(LPVOID pTarget, LPVOID pDetour, void* ppOriginal, const char* pFuncName)
+{
+ char* pStrippedFuncName = (char*)pFuncName;
+ // strip & char from funcname
+ if (*pStrippedFuncName == '&')
+ pStrippedFuncName++;
+
+ if (MH_CreateHook(pTarget, pDetour, (LPVOID*)ppOriginal) == MH_OK)
+ {
+ if (MH_EnableHook(pTarget) == MH_OK)
+ spdlog::info("Enabling hook {}", pStrippedFuncName);
+ else
+ spdlog::error("MH_EnableHook failed for function {}", pStrippedFuncName);
+ }
+ else
+ spdlog::error("MH_CreateHook failed for function {}", pStrippedFuncName);
+}
+
AUTOHOOK_ABSOLUTEADDR(_GetCommandLineA, GetCommandLineA,
LPSTR, WINAPI, ())
{