diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-07-17 22:33:00 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-07-17 22:33:00 +0100 |
commit | ca5db71e8215a6c5660fe03088a6d7349f55f817 (patch) | |
tree | 534b79d2599475b1da3edb4f232223d9e32d3174 /NorthstarDedicatedTest/sourceinterface.cpp | |
parent | 51d3d4a40c8579e29571bc80d35bbb62fa50661b (diff) | |
download | NorthstarLauncher-ca5db71e8215a6c5660fe03088a6d7349f55f817.tar.gz NorthstarLauncher-ca5db71e8215a6c5660fe03088a6d7349f55f817.zip |
add support for custom convars and concommands
Diffstat (limited to 'NorthstarDedicatedTest/sourceinterface.cpp')
-rw-r--r-- | NorthstarDedicatedTest/sourceinterface.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/sourceinterface.cpp b/NorthstarDedicatedTest/sourceinterface.cpp new file mode 100644 index 00000000..cedfad3c --- /dev/null +++ b/NorthstarDedicatedTest/sourceinterface.cpp @@ -0,0 +1,68 @@ +#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); + + std::cout << "CreateInterface CLIENT " << pName << std::endl; + 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, GetProcAddress(baseAddress, "CreateInterface"), &ClientCreateInterfaceHook, reinterpret_cast<LPVOID*>(&clientCreateInterfaceOriginal)); +} + +void HookServerCreateInterface(HMODULE baseAddress) +{ + HookEnabler hook; + ENABLER_CREATEHOOK(hook, GetProcAddress(baseAddress, "CreateInterface"), &ServerCreateInterfaceHook, reinterpret_cast<LPVOID*>(&serverCreateInterfaceOriginal)); +} + +void HookEngineCreateInterface(HMODULE baseAddress) +{ + HookEnabler hook; + ENABLER_CREATEHOOK(hook, GetProcAddress(baseAddress, "CreateInterface"), &EngineCreateInterfaceHook, reinterpret_cast<LPVOID*>(&engineCreateInterfaceOriginal)); +} + +void InitialiseInterfaceCreationHooks() +{ + AddDllLoadCallback("client.dll", HookClientCreateInterface); + AddDllLoadCallback("server.dll", HookServerCreateInterface); + AddDllLoadCallback("engine.dll", HookEngineCreateInterface); +}
\ No newline at end of file |