aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/sourceinterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/sourceinterface.cpp')
-rw-r--r--NorthstarDLL/sourceinterface.cpp83
1 files changed, 25 insertions, 58 deletions
diff --git a/NorthstarDLL/sourceinterface.cpp b/NorthstarDLL/sourceinterface.cpp
index 56020e5e..d5f7b7cd 100644
--- a/NorthstarDLL/sourceinterface.cpp
+++ b/NorthstarDLL/sourceinterface.cpp
@@ -1,82 +1,49 @@
#include "pch.h"
#include "sourceinterface.h"
-#include "hooks.h"
-#include "hookutils.h"
-
#include "sourceconsole.h"
-#include "context.h"
-#include "convar.h"
-#include <iostream>
+
+AUTOHOOK_INIT()
// really wanted to do a modular callback system here but honestly couldn't be bothered so hardcoding stuff for now: todo later
-CreateInterfaceFn clientCreateInterfaceOriginal;
-void* ClientCreateInterfaceHook(const char* pName, int* pReturnCode)
+// clang-format off
+AUTOHOOK_PROCADDRESS(ClientCreateInterface, client.dll, CreateInterface,
+void*, __fastcall, (const char* pName, const int* pReturnCode))
+// clang-format on
{
- void* ret = clientCreateInterfaceOriginal(pName, pReturnCode);
-
+ void* ret = ClientCreateInterface(pName, pReturnCode);
spdlog::info("CreateInterface CLIENT {}", pName);
+
if (!strcmp(pName, "GameClientExports001"))
InitialiseConsoleOnInterfaceCreation();
return ret;
}
-CreateInterfaceFn serverCreateInterfaceOriginal;
-void* ServerCreateInterfaceHook(const char* pName, int* pReturnCode)
+// clang-format off
+AUTOHOOK_PROCADDRESS(ServerCreateInterface, server.dll, CreateInterface,
+void*, __fastcall, (const char* pName, const int* pReturnCode))
+// clang-format on
{
- void* ret = serverCreateInterfaceOriginal(pName, pReturnCode);
-
- std::cout << "CreateInterface SERVER " << pName << std::endl;
+ void* ret = ServerCreateInterface(pName, pReturnCode);
+ spdlog::info("CreateInterface SERVER {}", pName);
return ret;
}
-CreateInterfaceFn engineCreateInterfaceOriginal;
-void* EngineCreateInterfaceHook(const char* pName, int* pReturnCode)
+// clang-format off
+AUTOHOOK_PROCADDRESS(EngineCreateInterface, engine.dll, CreateInterface,
+void*, __fastcall, (const char* pName, const int* pReturnCode))
+// clang-format on
{
- void* ret = engineCreateInterfaceOriginal(pName, pReturnCode);
-
- std::cout << "CreateInterface ENGINE " << pName << std::endl;
+ void* ret = EngineCreateInterface(pName, pReturnCode);
+ spdlog::info("CreateInterface ENGINE {}", pName);
return ret;
}
-void HookClientCreateInterface(HMODULE baseAddress)
-{
- HookEnabler hook;
- ENABLER_CREATEHOOK(
- hook,
- reinterpret_cast<void*>(GetProcAddress(baseAddress, "CreateInterface")),
- &ClientCreateInterfaceHook,
- reinterpret_cast<LPVOID*>(&clientCreateInterfaceOriginal));
-}
-
-void HookServerCreateInterface(HMODULE baseAddress)
-{
- HookEnabler hook;
- ENABLER_CREATEHOOK(
- hook,
- reinterpret_cast<void*>(GetProcAddress(baseAddress, "CreateInterface")),
- &ServerCreateInterfaceHook,
- reinterpret_cast<LPVOID*>(&serverCreateInterfaceOriginal));
-}
-
-void HookEngineCreateInterface(HMODULE baseAddress)
-{
- HookEnabler hook;
- ENABLER_CREATEHOOK(
- hook,
- reinterpret_cast<void*>(GetProcAddress(baseAddress, "CreateInterface")),
- &EngineCreateInterfaceHook,
- reinterpret_cast<LPVOID*>(&engineCreateInterfaceOriginal));
-}
-
-void InitialiseInterfaceCreationHooks()
-{
- AddDllLoadCallback("client.dll", HookClientCreateInterface);
-
- // not used atm
- // AddDllLoadCallback("server.dll", HookServerCreateInterface);
- // AddDllLoadCallback("engine.dll", HookEngineCreateInterface);
-}
+// 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