aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LauncherInjector/main.cpp2
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj2
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters6
-rw-r--r--NorthstarDedicatedTest/concommand.cpp11
-rw-r--r--NorthstarDedicatedTest/dedicated.cpp3
-rw-r--r--NorthstarDedicatedTest/dllmain.cpp3
-rw-r--r--NorthstarDedicatedTest/playlist.cpp49
-rw-r--r--NorthstarDedicatedTest/playlist.h1
-rw-r--r--NorthstarDedicatedTest/serverauthentication.cpp25
-rw-r--r--R2Northstar.sln1
10 files changed, 78 insertions, 25 deletions
diff --git a/LauncherInjector/main.cpp b/LauncherInjector/main.cpp
index 08ae12c3..2d846f6f 100644
--- a/LauncherInjector/main.cpp
+++ b/LauncherInjector/main.cpp
@@ -151,7 +151,7 @@ int main()
// hook launcher
DWORD launcherPID;
if (steamBuild)
- while (!(launcherPID = GetProcessByName(L"steam.exe"))) Sleep(50);
+ while (!(launcherPID = GetProcessByName(L"EASteamProxy.exe"))) Sleep(50);
else
while (!(launcherPID = GetProcessByName(L"Origin.exe"))) Sleep(50);
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index b6ceebf1..0857c2db 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -313,6 +313,7 @@
<ClInclude Include="modlocalisation.h" />
<ClInclude Include="modmanager.h" />
<ClInclude Include="pch.h" />
+ <ClInclude Include="playlist.h" />
<ClInclude Include="scriptmodmenu.h" />
<ClInclude Include="scriptserverbrowser.h" />
<ClInclude Include="scriptsrson.h" />
@@ -345,6 +346,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
+ <ClCompile Include="playlist.cpp" />
<ClCompile Include="scriptmodmenu.cpp" />
<ClCompile Include="scriptserverbrowser.cpp" />
<ClCompile Include="scriptsrson.cpp" />
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index 041c8e84..4ed01144 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -564,6 +564,9 @@
<ClInclude Include="modlocalisation.h">
<Filter>Header Files\Client</Filter>
</ClInclude>
+ <ClInclude Include="playlist.h">
+ <Filter>Header Files\Server</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@@ -641,6 +644,9 @@
<ClCompile Include="modlocalisation.cpp">
<Filter>Source Files\Client</Filter>
</ClCompile>
+ <ClCompile Include="playlist.cpp">
+ <Filter>Source Files\Server</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="include\spdlog\fmt\bundled\LICENSE.rst">
diff --git a/NorthstarDedicatedTest/concommand.cpp b/NorthstarDedicatedTest/concommand.cpp
index 8cf52b9d..5e0fab42 100644
--- a/NorthstarDedicatedTest/concommand.cpp
+++ b/NorthstarDedicatedTest/concommand.cpp
@@ -15,18 +15,7 @@ void RegisterConCommand(const char* name, void(*callback)(const CCommand&), cons
conCommandConstructor(newCommand, name, callback, helpString, flags, nullptr);
}
-void SetPlaylistCommand(const CCommand& args)
-{
- if (args.ArgC() < 2)
- return;
-
- SetCurrentPlaylist(args.Arg(1));
-}
-
void InitialiseConCommands(HMODULE baseAddress)
{
conCommandConstructor = (ConCommandConstructorType)((char*)baseAddress + 0x415F60);
-
- // this shouldn't be here but idk where else to put it rn
- RegisterConCommand("setplaylist", SetPlaylistCommand, "", FCVAR_NONE);
} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp
index 67cb66d2..8d7a6f8c 100644
--- a/NorthstarDedicatedTest/dedicated.cpp
+++ b/NorthstarDedicatedTest/dedicated.cpp
@@ -276,8 +276,7 @@ void RunServer(CDedicatedExports* dedicated)
// set up engine and host states to allow us to enter CHostState::FrameUpdate, with the state HS_NEW_GAME
cEnginePtr->m_nNextDllState = EngineState_t::DLL_ACTIVE;
- cHostStatePtr->m_currentState = HostState_t::HS_NEW_GAME;
- cHostStatePtr->m_nextState = HostState_t::HS_RUN;
+ cHostStatePtr->m_nextState = HostState_t::HS_NEW_GAME;
strcpy(cHostStatePtr->m_levelName, "mp_lobby"); // set map to load into
while (true)
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index e5ea9517..3439c6ce 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -16,6 +16,7 @@
#include "gameutils.h"
#include "chatcommand.h"
#include "modlocalisation.h"
+#include "playlist.h"
bool initialised = false;
@@ -74,6 +75,8 @@ void InitialiseNorthstar()
AddDllLoadCallback("engine.dll", InitialiseServerAuthentication);
AddDllLoadCallback("engine.dll", InitialiseSharedMasterServer);
+ AddDllLoadCallback("engine.dll", InitialisePlaylistHooks);
+
AddDllLoadCallback("filesystem_stdio.dll", InitialiseFilesystem);
AddDllLoadCallback("engine.dll", InitialiseKeyValues);
diff --git a/NorthstarDedicatedTest/playlist.cpp b/NorthstarDedicatedTest/playlist.cpp
new file mode 100644
index 00000000..2a730ee1
--- /dev/null
+++ b/NorthstarDedicatedTest/playlist.cpp
@@ -0,0 +1,49 @@
+#include "pch.h"
+#include "playlist.h"
+#include "concommand.h"
+#include "convar.h"
+#include "gameutils.h"
+#include "hookutils.h"
+
+typedef char(*Onclc_SetPlaylistVarOverrideType)(void* a1, void* a2);
+Onclc_SetPlaylistVarOverrideType Onclc_SetPlaylistVarOverride;
+
+ConVar* Cvar_ns_use_clc_SetPlaylistVarOverride;
+
+void SetPlaylistCommand(const CCommand& args)
+{
+ if (args.ArgC() < 2)
+ return;
+
+ SetCurrentPlaylist(args.Arg(1));
+}
+
+char Onclc_SetPlaylistVarOverrideHook(void* a1, void* a2)
+{
+ // the private_match playlist is the only situation where there should be any legitimate sending of this netmessage
+ // todo: check mp_lobby here too
+ if (!Cvar_ns_use_clc_SetPlaylistVarOverride->m_nValue || strcmp(GetCurrentPlaylistName(), "private_match"))
+ return 1;
+
+ return Onclc_SetPlaylistVarOverride(a1, a2);
+}
+
+void InitialisePlaylistHooks(HMODULE baseAddress)
+{
+ RegisterConCommand("setplaylist", SetPlaylistCommand, "Sets the current playlist", FCVAR_NONE);
+ // note: clc_SetPlaylistVarOverride is pretty insecure, since it allows for entirely arbitrary playlist var overrides to be sent to the server
+ // this is somewhat restricted on custom servers to prevent it being done outside of private matches, but ideally it should be disabled altogether, since the custom menus won't use it anyway
+ // this should only really be accepted if you want vanilla client compatibility
+ Cvar_ns_use_clc_SetPlaylistVarOverride = RegisterConVar("ns_use_clc_SetPlaylistVarOverride", "0", FCVAR_GAMEDLL, "Whether the server should accept clc_SetPlaylistVarOverride messages");
+
+ HookEnabler hook;
+ ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x222180, &Onclc_SetPlaylistVarOverrideHook, reinterpret_cast<LPVOID*>(&Onclc_SetPlaylistVarOverride));
+
+ // patch to prevent clc_SetPlaylistVarOverride from being able to crash servers if we reach max overrides due to a call to Error (why is this possible respawn, wtf)
+ // todo: add a warning for this
+ {
+ void* ptr = (char*)baseAddress + 0x18ED8D;
+ TempReadWrite rw(ptr);
+ *((char*)ptr) = 0xC3; // jmp => ret
+ }
+} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/playlist.h b/NorthstarDedicatedTest/playlist.h
new file mode 100644
index 00000000..d96a77ee
--- /dev/null
+++ b/NorthstarDedicatedTest/playlist.h
@@ -0,0 +1 @@
+void InitialisePlaylistHooks(HMODULE baseAddress); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp
index 6dd44284..77990d24 100644
--- a/NorthstarDedicatedTest/serverauthentication.cpp
+++ b/NorthstarDedicatedTest/serverauthentication.cpp
@@ -98,23 +98,28 @@ bool ServerAuthenticationManager::AuthenticatePlayer(void* player, int64_t uid,
std::string strUid = std::to_string(uid);
std::lock_guard<std::mutex> guard(m_authDataMutex);
+
+ bool authFail = true;
if (!m_authData.empty() && m_authData.count(std::string(authToken)))
{
// use stored auth data
AuthData authData = m_authData[authToken];
- if (strcmp(strUid.c_str(), authData.uid)) // connecting client's uid is different from auth's uid
- return false;
-
- // uuid
- strcpy((char*)player + 0xF500, strUid.c_str());
+ if (!strcmp(strUid.c_str(), authData.uid)) // connecting client's uid is different from auth's uid
+ {
+ authFail = false;
+ // uuid
+ strcpy((char*)player + 0xF500, strUid.c_str());
- // copy pdata into buffer
- memcpy((char*)player + 0x4FA, authData.pdata, authData.pdataSize);
+ // copy pdata into buffer
+ memcpy((char*)player + 0x4FA, authData.pdata, authData.pdataSize);
- // set persistent data as ready, we use 0x4 internally to mark the client as using remote persistence
- *((char*)player + 0x4a0) = (char)0x4;
+ // set persistent data as ready, we use 0x4 internally to mark the client as using remote persistence
+ *((char*)player + 0x4a0) = (char)0x4;
+ }
}
- else
+
+
+ if (authFail)
{
if (!CVar_ns_auth_allow_insecure->m_nValue) // no auth data and insecure connections aren't allowed, so dc the client
return false;
diff --git a/R2Northstar.sln b/R2Northstar.sln
index 09004f71..b613b518 100644
--- a/R2Northstar.sln
+++ b/R2Northstar.sln
@@ -35,7 +35,6 @@ Global
{3C3FC37C-D4B9-4413-AADF-C52FD2F428E6}.Debug|x86.ActiveCfg = Debug|Win32
{3C3FC37C-D4B9-4413-AADF-C52FD2F428E6}.Debug|x86.Build.0 = Debug|Win32
{3C3FC37C-D4B9-4413-AADF-C52FD2F428E6}.Release|x64.ActiveCfg = Release|x64
- {3C3FC37C-D4B9-4413-AADF-C52FD2F428E6}.Release|x64.Build.0 = Release|x64
{3C3FC37C-D4B9-4413-AADF-C52FD2F428E6}.Release|x86.ActiveCfg = Release|Win32
{3C3FC37C-D4B9-4413-AADF-C52FD2F428E6}.Release|x86.Build.0 = Release|Win32
{0EA82CB0-53FE-4D4C-96DF-47FA970513D0}.Debug|x64.ActiveCfg = Debug|Win32