From 51d3d4a40c8579e29571bc80d35bbb62fa50661b Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Sun, 11 Jul 2021 20:17:11 +0100 Subject: add temp console support --- .../NorthstarDedicatedTest.vcxproj | 2 +- .../NorthstarDedicatedTest.vcxproj.filters | 9 ++++-- NorthstarDedicatedTest/concommand.h | 0 NorthstarDedicatedTest/dedicated.cpp | 7 +++++ NorthstarDedicatedTest/sourceconsole.cpp | 33 ++++++++++++++++++---- NorthstarDedicatedTest/sourceconsole.h | 2 +- NorthstarDedicatedTest/sourceinterface.cpp | 13 --------- NorthstarDedicatedTest/sourceinterface.h | 12 ++++++-- 8 files changed, 53 insertions(+), 25 deletions(-) create mode 100644 NorthstarDedicatedTest/concommand.h delete mode 100644 NorthstarDedicatedTest/sourceinterface.cpp diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj index 8af2d3e0..078b2548 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj @@ -170,6 +170,7 @@ + @@ -199,7 +200,6 @@ - diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters index e9e523e8..1a2de381 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters @@ -40,6 +40,9 @@ {ca657be5-c2d8-4322-a689-1154aaafe57b} + + {9751b551-5886-45d4-a039-cbd10445263d} + @@ -81,6 +84,9 @@ Header Files\Shared + + Header Files\Shared\ConVar + @@ -116,8 +122,5 @@ Source Files\Shared - - Source Files\Shared - \ No newline at end of file diff --git a/NorthstarDedicatedTest/concommand.h b/NorthstarDedicatedTest/concommand.h new file mode 100644 index 00000000..e69de29b diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp index ce4723cb..0999e614 100644 --- a/NorthstarDedicatedTest/dedicated.cpp +++ b/NorthstarDedicatedTest/dedicated.cpp @@ -7,6 +7,7 @@ bool IsDedicated() { // temp: should get this from commandline + //return true; return false; } @@ -69,6 +70,12 @@ void InitialiseDedicated(HMODULE engineAddress) // ptr to ptr *ptr = (intptr_t)doublePtr; + + // extra potential patches: + // nop engine.dll+1c67cd1 and +1c67d8 to skip videomode creategamewindow + // also look into launcher.dll+d381, seems to cause renderthread to get made + // this crashes HARD if no window which makes sense tbh + // also look into materialsystem + 5B344 since it seems to be the base of all the renderthread stuff } void Sys_Printf(CDedicatedExports* dedicated, char* msg) diff --git a/NorthstarDedicatedTest/sourceconsole.cpp b/NorthstarDedicatedTest/sourceconsole.cpp index c862356e..775ec856 100644 --- a/NorthstarDedicatedTest/sourceconsole.cpp +++ b/NorthstarDedicatedTest/sourceconsole.cpp @@ -1,14 +1,37 @@ #include "pch.h" #include "sourceconsole.h" #include "sourceinterface.h" +#include "hookutils.h" +#include -SourceInterface* g_SourceGameConsole; +SourceInterface* g_pSourceGameConsole; + +typedef void(*weaponlisttype)(); +weaponlisttype weaponlist; +void CommandWeaponListHook() +{ + std::cout << "TEMP: toggling console... REPLACE THIS WITH ACTUAL CONCOMMAND SUPPORT SOON" << std::endl; + + (*g_pSourceGameConsole)->Activate(); +} + +CreateInterfaceFn createInterface; +void* __fastcall InitialiseConsoleOnUIInit(const char* pName, int* pReturnCode) +{ + std::cout << pName << std::endl; + void* ret = createInterface(pName, pReturnCode); + + if (!strcmp(pName, "GameClientExports001")) + (*g_pSourceGameConsole)->Initialize(); + + return ret; +} void InitialiseSourceConsole(HMODULE baseAddress) { - SourceInterface console = SourceInterface("client.dll", "CGameConsole"); - console->Initialize(); - console->Activate(); + g_pSourceGameConsole = new SourceInterface("client.dll", "GameConsole004"); - g_SourceGameConsole = &console; + HookEnabler hook; + ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x73BA00, &InitialiseConsoleOnUIInit, reinterpret_cast(&createInterface)); + ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x10C080, &CommandWeaponListHook, reinterpret_cast(&weaponlist)); } \ No newline at end of file diff --git a/NorthstarDedicatedTest/sourceconsole.h b/NorthstarDedicatedTest/sourceconsole.h index 7f494dca..7815cd03 100644 --- a/NorthstarDedicatedTest/sourceconsole.h +++ b/NorthstarDedicatedTest/sourceconsole.h @@ -87,4 +87,4 @@ public: CConsoleDialog* m_pConsole; }; -extern SourceInterface* g_SourceGameConsole; \ No newline at end of file +extern SourceInterface* g_pSourceGameConsole; \ No newline at end of file diff --git a/NorthstarDedicatedTest/sourceinterface.cpp b/NorthstarDedicatedTest/sourceinterface.cpp deleted file mode 100644 index 49a2f164..00000000 --- a/NorthstarDedicatedTest/sourceinterface.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "pch.h" -#include "sourceinterface.h" -#include -#include "tier0.h" - -template SourceInterface::SourceInterface(const std::string& moduleName, const std::string& interfaceName) -{ - HMODULE handle = GetModuleHandleA(moduleName.c_str()); - CreateInterfaceFn createInterface = (CreateInterfaceFn)GetProcAddress(handle, interfaceName.c_str()); - m_interface = (T*)createInterface(interfaceName.c_str(), NULL); - if (m_interface == nullptr) - Error("Failed to call CreateInterface for %s in %s", interfaceName, moduleName); -} \ No newline at end of file diff --git a/NorthstarDedicatedTest/sourceinterface.h b/NorthstarDedicatedTest/sourceinterface.h index bc4767f5..b6e9b92a 100644 --- a/NorthstarDedicatedTest/sourceinterface.h +++ b/NorthstarDedicatedTest/sourceinterface.h @@ -1,5 +1,6 @@ #pragma once #include +#include "tier0.h" // literally just copied from ttf2sdk definition typedef void* (*CreateInterfaceFn)(const char* pName, int* pReturnCode); @@ -10,7 +11,14 @@ private: T* m_interface; public: - SourceInterface(const std::string& moduleName, const std::string& interfaceName); + SourceInterface(const std::string& moduleName, const std::string& interfaceName) + { + HMODULE handle = GetModuleHandleA(moduleName.c_str()); + CreateInterfaceFn createInterface = (CreateInterfaceFn)GetProcAddress(handle, "CreateInterface"); + m_interface = (T*)createInterface(interfaceName.c_str(), NULL); + if (m_interface == nullptr) + Error("Failed to call CreateInterface for %s in %s", interfaceName, moduleName); + } T* operator->() const { @@ -21,4 +29,4 @@ public: { return m_interface; } -}; +}; \ No newline at end of file -- cgit v1.2.3