aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/dllmain.cpp21
-rw-r--r--NorthstarDedicatedTest/hooks.cpp16
-rw-r--r--NorthstarDedicatedTest/maxplayers.cpp13
-rw-r--r--NorthstarDedicatedTest/maxplayers.h5
-rw-r--r--NorthstarDedicatedTest/plugins.cpp5
-rw-r--r--NorthstarDedicatedTest/plugins.h4
-rw-r--r--NorthstarDedicatedTest/sourceinterface.cpp29
-rw-r--r--NorthstarDedicatedTest/sourceinterface.h5
8 files changed, 26 insertions, 72 deletions
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index d73fa9d5..394370c2 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -24,8 +24,6 @@ namespace fs = std::filesystem;
typedef void (*initPluginFuncPtr)(void* getPluginObject);
-bool initialised = false;
-
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
@@ -158,13 +156,15 @@ bool LoadPlugins()
bool InitialiseNorthstar()
{
- if (initialised)
+ static bool bInitialised = false;
+
+ if (bInitialised)
{
// spdlog::warn("Called InitialiseNorthstar more than once!"); // it's actually 100% fine for that to happen
return false;
}
- initialised = true;
+ bInitialised = true;
parseConfigurables();
InitialiseVersion();
@@ -181,24 +181,11 @@ bool InitialiseNorthstar()
// Write launcher version to log
spdlog::info("NorthstarLauncher version: {}", version);
- InitialiseInterfaceCreationHooks();
-
AddDllLoadCallback("tier0.dll", InitialiseTier0GameUtilFunctions);
AddDllLoadCallback("engine.dll", WaitForDebugger);
AddDllLoadCallback("engine.dll", InitialiseEngineGameUtilFunctions);
AddDllLoadCallback("server.dll", InitialiseServerGameUtilFunctions);
- // client-exclusive patches
- {
-
- AddDllLoadCallbackForClient("client.dll", InitialisePluginCommands);
- }
-
- // maxplayers increase
- AddDllLoadCallback("engine.dll", InitialiseMaxPlayersOverride_Engine);
- AddDllLoadCallback("client.dll", InitialiseMaxPlayersOverride_Client);
- AddDllLoadCallback("server.dll", InitialiseMaxPlayersOverride_Server);
-
// run callbacks for any libraries that are already loaded by now
CallAllPendingDLLLoadCallbacks();
diff --git a/NorthstarDedicatedTest/hooks.cpp b/NorthstarDedicatedTest/hooks.cpp
index 5ced6046..c566ca8d 100644
--- a/NorthstarDedicatedTest/hooks.cpp
+++ b/NorthstarDedicatedTest/hooks.cpp
@@ -53,8 +53,6 @@ void InstallInitialHooks()
__dllLoadCallback::__dllLoadCallback(
eDllLoadCallbackSide side, const std::string dllName, DllLoadCallbackFuncType callback, std::string uniqueStr, std::string reliesOn)
{
- spdlog::info("calling loadcallback {} for dll {}", uniqueStr, dllName);
-
switch (side)
{
case eDllLoadCallbackSide::UNSIDED:
@@ -192,21 +190,14 @@ std::vector<std::string> calledTags;
void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress)
{
- spdlog::info((char*)lpLibFileName);
-
while (true)
{
bool doneCalling = true;
for (auto& callbackStruct : dllLoadCallbacks)
{
- spdlog::info("{} {}", callbackStruct.tag, callbackStruct.reliesOn);
-
if (!callbackStruct.called && fs::path(lpLibFileName).filename() == fs::path(callbackStruct.dll).filename())
{
- //spdlog::info(callbackStruct.tag);
- //spdlog::info(callbackStruct.reliesOn);
-
if (callbackStruct.reliesOn != "" &&
std::find(calledTags.begin(), calledTags.end(), callbackStruct.reliesOn) == calledTags.end())
{
@@ -227,21 +218,14 @@ void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress)
void CallLoadLibraryWCallbacks(LPCWSTR lpLibFileName, HMODULE moduleAddress)
{
- spdlog::info((char*)lpLibFileName);
-
while (true)
{
bool doneCalling = true;
for (auto& callbackStruct : dllLoadCallbacks)
{
- spdlog::info("{} {}", callbackStruct.tag, callbackStruct.reliesOn);
-
if (!callbackStruct.called && fs::path(lpLibFileName).filename() == fs::path(callbackStruct.dll).filename())
{
- //spdlog::info(callbackStruct.tag);
- //spdlog::info(callbackStruct.reliesOn);
-
if (callbackStruct.reliesOn != "" &&
std::find(calledTags.begin(), calledTags.end(), callbackStruct.reliesOn) == calledTags.end())
{
diff --git a/NorthstarDedicatedTest/maxplayers.cpp b/NorthstarDedicatedTest/maxplayers.cpp
index 32f3b2ec..b2219faf 100644
--- a/NorthstarDedicatedTest/maxplayers.cpp
+++ b/NorthstarDedicatedTest/maxplayers.cpp
@@ -1,4 +1,5 @@
#include "pch.h"
+#include "hooks.h"
#include "maxplayers.h"
#include "gameutils.h"
@@ -108,7 +109,7 @@ bool MaxPlayersIncreaseEnabled()
return CommandLine() && CommandLine()->CheckParm("-experimentalmaxplayersincrease");
}
-void InitialiseMaxPlayersOverride_Engine(HMODULE baseAddress)
+ON_DLL_LOAD("engine.dll", MaxPlayersOverride_Engine, (HMODULE baseAddress)
{
if (!MaxPlayersIncreaseEnabled())
return;
@@ -158,7 +159,7 @@ void InitialiseMaxPlayersOverride_Engine(HMODULE baseAddress)
(char*)baseAddress + 0x22E220,
&StringTables_CreateStringTable_Hook,
reinterpret_cast<LPVOID*>(&StringTables_CreateStringTable_Original));
-}
+})
typedef void (*RunUserCmds_Type)(bool a1, float a2);
RunUserCmds_Type RunUserCmds_Original;
@@ -320,7 +321,7 @@ __int64 __fastcall SendPropArray2_Hook(__int64 recvProp, int elements, int flags
return SendPropArray2_Original(recvProp, elements, flags, name, proxyFn, unk1);
}
-void InitialiseMaxPlayersOverride_Server(HMODULE baseAddress)
+ON_DLL_LOAD("server.dll", MaxPlayersOverride_Server, (HMODULE baseAddress)
{
if (!MaxPlayersIncreaseEnabled())
return;
@@ -484,7 +485,7 @@ void InitialiseMaxPlayersOverride_Server(HMODULE baseAddress)
*(DWORD*)((char*)baseAddress + 0xC945A0) = 0;
auto DT_Team_Construct = (__int64(__fastcall*)())((char*)baseAddress + 0x238F50);
DT_Team_Construct();
-}
+})
typedef __int64 (*RecvPropArray2_Type)(__int64 recvProp, int elements, int flags, const char* name, __int64 proxyFn);
RecvPropArray2_Type RecvPropArray2_Original;
@@ -498,7 +499,7 @@ __int64 __fastcall RecvPropArray2_Hook(__int64 recvProp, int elements, int flags
return RecvPropArray2_Original(recvProp, elements, flags, name, proxyFn);
}
-void InitialiseMaxPlayersOverride_Client(HMODULE baseAddress)
+ON_DLL_LOAD("client.dll", MaxPlayersOverride_Client, (HMODULE baseAddress)
{
if (!MaxPlayersIncreaseEnabled())
return;
@@ -679,4 +680,4 @@ void InitialiseMaxPlayersOverride_Client(HMODULE baseAddress)
*(DWORD*)((char*)baseAddress + 0xC3AFF8) = 0;
auto DT_Team_Construct = (__int64(__fastcall*)())((char*)baseAddress + 0x17F950);
DT_Team_Construct();
-} \ No newline at end of file
+}) \ No newline at end of file
diff --git a/NorthstarDedicatedTest/maxplayers.h b/NorthstarDedicatedTest/maxplayers.h
index cd191fc8..7b9637ef 100644
--- a/NorthstarDedicatedTest/maxplayers.h
+++ b/NorthstarDedicatedTest/maxplayers.h
@@ -1,4 +1 @@
-#pragma once
-void InitialiseMaxPlayersOverride_Engine(HMODULE baseAddress);
-void InitialiseMaxPlayersOverride_Server(HMODULE baseAddress);
-void InitialiseMaxPlayersOverride_Client(HMODULE baseAddress); \ No newline at end of file
+#pragma once \ No newline at end of file
diff --git a/NorthstarDedicatedTest/plugins.cpp b/NorthstarDedicatedTest/plugins.cpp
index 70535a32..54067772 100644
--- a/NorthstarDedicatedTest/plugins.cpp
+++ b/NorthstarDedicatedTest/plugins.cpp
@@ -1,4 +1,5 @@
#include "pch.h"
+#include "hooks.h"
#include "squirrel.h"
#include "plugins.h"
#include <chrono>
@@ -384,7 +385,7 @@ int getPlayerInfoBool(bool* out_ptr, PlayerInfoType var)
return n;
}
-void InitialisePluginCommands(HMODULE baseAddress)
+ON_DLL_LOAD_CLIENT_RELIESON("client.dll", PluginCommands, ClientSquirrel, (HMODULE baseAddress)
{
// i swear there's a way to make this not have be run in 2 contexts but i can't figure it out
// some funcs i need are just not available in UI or CLIENT
@@ -417,4 +418,4 @@ void InitialisePluginCommands(HMODULE baseAddress)
g_UISquirrelManager->AddFuncRegistration("void", "NSSetLoading", "bool loading", "", SQ_SetConnected);
g_UISquirrelManager->AddFuncRegistration("void", "NSUpdateListenServer", "", "", SQ_UpdateListenServer);
}
-}
+})
diff --git a/NorthstarDedicatedTest/plugins.h b/NorthstarDedicatedTest/plugins.h
index 27312da9..3a0f9f79 100644
--- a/NorthstarDedicatedTest/plugins.h
+++ b/NorthstarDedicatedTest/plugins.h
@@ -14,6 +14,4 @@ int getPlayerInfoInt(int* out_ptr, PlayerInfoType var);
int getPlayerInfoBool(bool* out_ptr, PlayerInfoType var);
void initGameState();
-void* getPluginObject(PluginObject var);
-
-void InitialisePluginCommands(HMODULE baseAddress); \ No newline at end of file
+void* getPluginObject(PluginObject var); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/sourceinterface.cpp b/NorthstarDedicatedTest/sourceinterface.cpp
index 2cc4733d..24657739 100644
--- a/NorthstarDedicatedTest/sourceinterface.cpp
+++ b/NorthstarDedicatedTest/sourceinterface.cpp
@@ -14,8 +14,8 @@ CreateInterfaceFn clientCreateInterfaceOriginal;
void* ClientCreateInterfaceHook(const char* pName, int* pReturnCode)
{
void* ret = clientCreateInterfaceOriginal(pName, pReturnCode);
-
spdlog::info("CreateInterface CLIENT {}", pName);
+
if (!strcmp(pName, "GameClientExports001"))
InitialiseConsoleOnInterfaceCreation();
@@ -26,8 +26,7 @@ CreateInterfaceFn serverCreateInterfaceOriginal;
void* ServerCreateInterfaceHook(const char* pName, int* pReturnCode)
{
void* ret = serverCreateInterfaceOriginal(pName, pReturnCode);
-
- std::cout << "CreateInterface SERVER " << pName << std::endl;
+ spdlog::info("CreateInterface SERVER {}", pName);
return ret;
}
@@ -36,13 +35,12 @@ CreateInterfaceFn engineCreateInterfaceOriginal;
void* EngineCreateInterfaceHook(const char* pName, int* pReturnCode)
{
void* ret = engineCreateInterfaceOriginal(pName, pReturnCode);
-
- std::cout << "CreateInterface ENGINE " << pName << std::endl;
+ spdlog::info("CreateInterface ENGINE {}", pName);
return ret;
}
-void HookClientCreateInterface(HMODULE baseAddress)
+ON_DLL_LOAD("client.dll", ClientInterface, (HMODULE baseAddress)
{
HookEnabler hook;
ENABLER_CREATEHOOK(
@@ -50,9 +48,9 @@ void HookClientCreateInterface(HMODULE baseAddress)
GetProcAddress(baseAddress, "CreateInterface"),
&ClientCreateInterfaceHook,
reinterpret_cast<LPVOID*>(&clientCreateInterfaceOriginal));
-}
+})
-void HookServerCreateInterface(HMODULE baseAddress)
+ON_DLL_LOAD("server.dll", ServerInterface, (HMODULE baseAddress)
{
HookEnabler hook;
ENABLER_CREATEHOOK(
@@ -60,9 +58,9 @@ void HookServerCreateInterface(HMODULE baseAddress)
GetProcAddress(baseAddress, "CreateInterface"),
&ServerCreateInterfaceHook,
reinterpret_cast<LPVOID*>(&serverCreateInterfaceOriginal));
-}
+})
-void HookEngineCreateInterface(HMODULE baseAddress)
+ON_DLL_LOAD("engine.dll", EngineInterface, (HMODULE baseAddress)
{
HookEnabler hook;
ENABLER_CREATEHOOK(
@@ -70,13 +68,4 @@ void HookEngineCreateInterface(HMODULE baseAddress)
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);
-} \ No newline at end of file
+}) \ No newline at end of file
diff --git a/NorthstarDedicatedTest/sourceinterface.h b/NorthstarDedicatedTest/sourceinterface.h
index 05318963..c4f41920 100644
--- a/NorthstarDedicatedTest/sourceinterface.h
+++ b/NorthstarDedicatedTest/sourceinterface.h
@@ -28,7 +28,4 @@ template <typename T> class SourceInterface
{
return m_interface;
}
-};
-
-// functions for interface creation callbacks
-void InitialiseInterfaceCreationHooks(); \ No newline at end of file
+}; \ No newline at end of file