aboutsummaryrefslogtreecommitdiff
path: root/primedev/core
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2024-08-31 16:25:59 +0100
committerGitHub <noreply@github.com>2024-08-31 17:25:59 +0200
commitf2d07f5d19d824194a6595455e577810b9d71762 (patch)
tree67bc13cccd56e404902a0f548ec59c39105511e2 /primedev/core
parentcb62662816c1e1f38de3567f83140d2adf21eebb (diff)
downloadNorthstarLauncher-f2d07f5d19d824194a6595455e577810b9d71762.tar.gz
NorthstarLauncher-f2d07f5d19d824194a6595455e577810b9d71762.zip
core: Remove uses of Autohook from `sourceinterface.cpp` (#798)
Replaces the AUTOHOOK macro in `sourceinterface.cpp` with HookAttach.
Diffstat (limited to 'primedev/core')
-rw-r--r--primedev/core/sourceinterface.cpp48
1 files changed, 26 insertions, 22 deletions
diff --git a/primedev/core/sourceinterface.cpp b/primedev/core/sourceinterface.cpp
index 5a72beb0..74e4a996 100644
--- a/primedev/core/sourceinterface.cpp
+++ b/primedev/core/sourceinterface.cpp
@@ -1,16 +1,12 @@
#include "sourceinterface.h"
#include "logging/sourceconsole.h"
-AUTOHOOK_INIT()
-
// really wanted to do a modular callback system here but honestly couldn't be bothered so hardcoding stuff for now: todo later
-// clang-format off
-AUTOHOOK_PROCADDRESS(ClientCreateInterface, client.dll, CreateInterface,
-void*, __fastcall, (const char* pName, const int* pReturnCode))
-// clang-format on
+static void*(__fastcall* o_pClientCreateInterface)(const char* pName, const int* pReturnCode) = nullptr;
+static void* __fastcall h_ClientCreateInterface(const char* pName, const int* pReturnCode)
{
- void* ret = ClientCreateInterface(pName, pReturnCode);
+ void* ret = o_pClientCreateInterface(pName, pReturnCode);
spdlog::info("CreateInterface CLIENT {}", pName);
if (!strcmp(pName, "GameClientExports001"))
@@ -19,30 +15,38 @@ void*, __fastcall, (const char* pName, const int* pReturnCode))
return ret;
}
-// clang-format off
-AUTOHOOK_PROCADDRESS(ServerCreateInterface, server.dll, CreateInterface,
-void*, __fastcall, (const char* pName, const int* pReturnCode))
-// clang-format on
+static void*(__fastcall* o_pServerCreateInterface)(const char* pName, const int* pReturnCode) = nullptr;
+static void* __fastcall h_ServerCreateInterface(const char* pName, const int* pReturnCode)
{
- void* ret = ServerCreateInterface(pName, pReturnCode);
+ void* ret = o_pServerCreateInterface(pName, pReturnCode);
spdlog::info("CreateInterface SERVER {}", pName);
return ret;
}
-// clang-format off
-AUTOHOOK_PROCADDRESS(EngineCreateInterface, engine.dll, CreateInterface,
-void*, __fastcall, (const char* pName, const int* pReturnCode))
-// clang-format on
+static void*(__fastcall* o_pEngineCreateInterface)(const char* pName, const int* pReturnCode) = nullptr;
+static void* __fastcall h_EngineCreateInterface(const char* pName, const int* pReturnCode)
{
- void* ret = EngineCreateInterface(pName, pReturnCode);
+ void* ret = o_pEngineCreateInterface(pName, pReturnCode);
spdlog::info("CreateInterface ENGINE {}", pName);
return ret;
}
-// clang-format off
-ON_DLL_LOAD("client.dll", ClientInterface, (CModule module)) {AUTOHOOK_DISPATCH_MODULE(client.dll)}
-ON_DLL_LOAD("server.dll", ServerInterface, (CModule module)) {AUTOHOOK_DISPATCH_MODULE(server.dll)}
-ON_DLL_LOAD("engine.dll", EngineInterface, (CModule module)) {AUTOHOOK_DISPATCH_MODULE(engine.dll)}
-// clang-format on
+ON_DLL_LOAD("client.dll", ClientInterface, (CModule module))
+{
+ o_pClientCreateInterface = module.GetExportedFunction("CreateInterface").RCast<decltype(o_pClientCreateInterface)>();
+ HookAttach(&(PVOID&)o_pClientCreateInterface, (PVOID)h_ClientCreateInterface);
+}
+
+ON_DLL_LOAD("server.dll", ServerInterface, (CModule module))
+{
+ o_pServerCreateInterface = module.GetExportedFunction("CreateInterface").RCast<decltype(o_pServerCreateInterface)>();
+ HookAttach(&(PVOID&)o_pServerCreateInterface, (PVOID)h_ServerCreateInterface);
+}
+
+ON_DLL_LOAD("engine.dll", EngineInterface, (CModule module))
+{
+ o_pEngineCreateInterface = module.GetExportedFunction("CreateInterface").RCast<decltype(o_pEngineCreateInterface)>();
+ HookAttach(&(PVOID&)o_pEngineCreateInterface, (PVOID)h_EngineCreateInterface);
+}