diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2024-08-25 22:51:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-25 22:51:51 +0200 |
commit | af040dfaaefe1155c6ed6a0615ea2c44b2de30b9 (patch) | |
tree | c7b1aedd9c3cedfb72ef80f8b1ea620c4354f598 | |
parent | 2625fff85ff1dcdb7b51c06d9651fc364c24bcb8 (diff) | |
parent | 3e2d4035ada7a91e0ecffd0fde050cf47fce0427 (diff) | |
download | NorthstarLauncher-af040dfaaefe1155c6ed6a0615ea2c44b2de30b9.tar.gz NorthstarLauncher-af040dfaaefe1155c6ed6a0615ea2c44b2de30b9.zip |
Merge branch 'main' into formatting/initializers
-rw-r--r-- | primedev/core/hooks.cpp | 22 | ||||
-rw-r--r-- | primedev/core/hooks.h | 2 |
2 files changed, 7 insertions, 17 deletions
diff --git a/primedev/core/hooks.cpp b/primedev/core/hooks.cpp index 5026f837..d8fad409 100644 --- a/primedev/core/hooks.cpp +++ b/primedev/core/hooks.cpp @@ -85,19 +85,9 @@ void __fileAutohook::DispatchForModule(const char* pModuleName) hook->Dispatch(); } -ManualHook::ManualHook(const char* funcName, LPVOID func) : pHookFunc(func), ppOrigFunc(nullptr) -{ - const size_t iFuncNameStrlen = strlen(funcName); - pFuncName = new char[iFuncNameStrlen]; - memcpy(pFuncName, funcName, iFuncNameStrlen); -} +ManualHook::ManualHook(const char* funcName, LPVOID func) : svFuncName(funcName), pHookFunc(func), ppOrigFunc(nullptr) {} -ManualHook::ManualHook(const char* funcName, LPVOID* orig, LPVOID func) : pHookFunc(func), ppOrigFunc(orig) -{ - const size_t iFuncNameStrlen = strlen(funcName); - pFuncName = new char[iFuncNameStrlen]; - memcpy(pFuncName, funcName, iFuncNameStrlen); -} +ManualHook::ManualHook(const char* funcName, LPVOID* orig, LPVOID func) : svFuncName(funcName), pHookFunc(func), ppOrigFunc(orig) {} bool ManualHook::Dispatch(LPVOID addr, LPVOID* orig) { @@ -105,19 +95,19 @@ bool ManualHook::Dispatch(LPVOID addr, LPVOID* orig) ppOrigFunc = orig; if (!addr) - spdlog::error("Address for hook {} is invalid", pFuncName); + spdlog::error("Address for hook {} is invalid", svFuncName); else if (MH_CreateHook(addr, pHookFunc, ppOrigFunc) == MH_OK) { if (MH_EnableHook(addr) == MH_OK) { - spdlog::info("Enabling hook {}", pFuncName); + spdlog::info("Enabling hook {}", svFuncName); return true; } else - spdlog::error("MH_EnableHook failed for function {}", pFuncName); + spdlog::error("MH_EnableHook failed for function {}", svFuncName); } else - spdlog::error("MH_CreateHook failed for function {}", pFuncName); + spdlog::error("MH_CreateHook failed for function {}", svFuncName); return false; } diff --git a/primedev/core/hooks.h b/primedev/core/hooks.h index 2a2180da..023b7411 100644 --- a/primedev/core/hooks.h +++ b/primedev/core/hooks.h @@ -278,7 +278,7 @@ public: class ManualHook { public: - char* pFuncName; + std::string svFuncName; LPVOID pHookFunc; LPVOID* ppOrigFunc; |