aboutsummaryrefslogtreecommitdiff
path: root/primedev/core/hooks.cpp
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2024-09-20 14:24:56 +0200
committerGitHub <noreply@github.com>2024-09-20 14:24:56 +0200
commita4b09bc42d5f79ef86697c893efc9e3b7d966502 (patch)
treed4c7b2b8cc04361ddf7b9c942e5f9462bb55e0b9 /primedev/core/hooks.cpp
parenta9d2ce8a692f7890f4e4bfc21458332890605a5f (diff)
parent6737a344c012c0f7fd19cd593949dd3dbe5a0cb7 (diff)
downloadNorthstarLauncher-a4b09bc42d5f79ef86697c893efc9e3b7d966502.tar.gz
NorthstarLauncher-a4b09bc42d5f79ef86697c893efc9e3b7d966502.zip
Merge branch 'main' into feat/overhaul-mod-loading-locations
Diffstat (limited to 'primedev/core/hooks.cpp')
-rw-r--r--primedev/core/hooks.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/primedev/core/hooks.cpp b/primedev/core/hooks.cpp
index 7ce98331..6146c93c 100644
--- a/primedev/core/hooks.cpp
+++ b/primedev/core/hooks.cpp
@@ -12,8 +12,6 @@
namespace fs = std::filesystem;
-AUTOHOOK_INIT()
-
// called from the ON_DLL_LOAD macros
__dllLoadCallback::__dllLoadCallback(
eDllLoadCallbackSide side, const std::string dllName, DllLoadCallbackFuncType callback, std::string uniqueStr, std::string reliesOn)
@@ -223,14 +221,15 @@ void MakeHook(LPVOID pTarget, LPVOID pDetour, void* ppOriginal, const char* pFun
spdlog::error("MH_CreateHook failed for function {}", pStrippedFuncName);
}
-AUTOHOOK_ABSOLUTEADDR(_GetCommandLineA, (LPVOID)GetCommandLineA, LPSTR, WINAPI, ())
+static LPSTR(WINAPI* o_pGetCommandLineA)() = nullptr;
+static LPSTR WINAPI h_GetCommandLineA()
{
static char* cmdlineModified;
static char* cmdlineOrg;
if (cmdlineOrg == nullptr || cmdlineModified == nullptr)
{
- cmdlineOrg = _GetCommandLineA();
+ cmdlineOrg = o_pGetCommandLineA();
bool isDedi = strstr(cmdlineOrg, "-dedicated"); // well, this one has to be a real argument
bool ignoreStartupArgs = strstr(cmdlineOrg, "-nostartupargs");
@@ -328,8 +327,6 @@ void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress)
void CallLoadLibraryWCallbacks(LPCWSTR lpLibFileName, HMODULE moduleAddress)
{
- CModule cModule(moduleAddress);
-
while (true)
{
bool bDoneCalling = true;
@@ -396,6 +393,7 @@ void HookSys_Init()
{
spdlog::error("MH_Initialize (minhook initialization) failed");
}
- // todo: remove remaining instances of autohook in this file
- AUTOHOOK_DISPATCH()
+
+ o_pGetCommandLineA = GetCommandLineA;
+ HookAttach(&(PVOID&)o_pGetCommandLineA, (PVOID)h_GetCommandLineA);
}