aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/sourceinterface.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-08-24 00:32:31 +0100
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-25 21:32:55 +0200
commit46bed8d09f32360377350d71816a76abdfbf2c7c (patch)
tree7feedae4910dbfe0e53d26ea1e00c4616d2c1850 /NorthstarDLL/sourceinterface.cpp
parenta97f1f07bb5aa31629cd87023e09669eb4bf1fe9 (diff)
downloadNorthstarLauncher-46bed8d09f32360377350d71816a76abdfbf2c7c.tar.gz
NorthstarLauncher-46bed8d09f32360377350d71816a76abdfbf2c7c.zip
Adjust folder structure (#242)v1.9.5-rc1v1.9.5
* Adjust folder structure * change launcher directory name
Diffstat (limited to 'NorthstarDLL/sourceinterface.cpp')
-rw-r--r--NorthstarDLL/sourceinterface.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/NorthstarDLL/sourceinterface.cpp b/NorthstarDLL/sourceinterface.cpp
new file mode 100644
index 00000000..56020e5e
--- /dev/null
+++ b/NorthstarDLL/sourceinterface.cpp
@@ -0,0 +1,82 @@
+#include "pch.h"
+#include "sourceinterface.h"
+#include "hooks.h"
+#include "hookutils.h"
+
+#include "sourceconsole.h"
+#include "context.h"
+#include "convar.h"
+#include <iostream>
+
+// 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)
+{
+ void* ret = clientCreateInterfaceOriginal(pName, pReturnCode);
+
+ spdlog::info("CreateInterface CLIENT {}", pName);
+ if (!strcmp(pName, "GameClientExports001"))
+ InitialiseConsoleOnInterfaceCreation();
+
+ return ret;
+}
+
+CreateInterfaceFn serverCreateInterfaceOriginal;
+void* ServerCreateInterfaceHook(const char* pName, int* pReturnCode)
+{
+ void* ret = serverCreateInterfaceOriginal(pName, pReturnCode);
+
+ std::cout << "CreateInterface SERVER " << pName << std::endl;
+
+ return ret;
+}
+
+CreateInterfaceFn engineCreateInterfaceOriginal;
+void* EngineCreateInterfaceHook(const char* pName, int* pReturnCode)
+{
+ void* ret = engineCreateInterfaceOriginal(pName, pReturnCode);
+
+ std::cout << "CreateInterface ENGINE " << pName << std::endl;
+
+ 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);
+}