From a73006df20d65802b23c38c310f018c92e4fc661 Mon Sep 17 00:00:00 2001 From: F1F7Y <64418963+F1F7Y@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:31:39 +0200 Subject: core: Remove unused `CModule` variable (#785) Removes unused `CModule` var. CModule crashes when you give it a dll tha's been loaded as one of these: `LOAD_LIBRARY_AS_DATAFILE`, `LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE`, `LOAD_LIBRARY_AS_IMAGE_RESOURCE`. We have guards for this in libsys but not here. --- primedev/core/hooks.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'primedev/core/hooks.cpp') diff --git a/primedev/core/hooks.cpp b/primedev/core/hooks.cpp index 7ce98331..a57340cf 100644 --- a/primedev/core/hooks.cpp +++ b/primedev/core/hooks.cpp @@ -328,8 +328,6 @@ void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress) void CallLoadLibraryWCallbacks(LPCWSTR lpLibFileName, HMODULE moduleAddress) { - CModule cModule(moduleAddress); - while (true) { bool bDoneCalling = true; -- cgit v1.2.3 From a60c2738a2a0247ef46db8bae55f5dfd0c0f14c3 Mon Sep 17 00:00:00 2001 From: Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Sat, 31 Aug 2024 10:31:08 +0100 Subject: core: Remove uses of Autohook from `hooks.cpp` (#796) Removes AUTOHOOK macro from `hooks.cpp`. --- primedev/core/hooks.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'primedev/core/hooks.cpp') diff --git a/primedev/core/hooks.cpp b/primedev/core/hooks.cpp index a57340cf..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"); @@ -394,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); } -- cgit v1.2.3