aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL')
-rw-r--r--NorthstarDLL/client/clientauthhooks.cpp11
-rw-r--r--NorthstarDLL/core/vanilla.h29
-rw-r--r--NorthstarDLL/dllmain.cpp5
-rw-r--r--NorthstarDLL/masterserver/masterserver.cpp7
-rw-r--r--NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp8
-rw-r--r--NorthstarDLL/squirrel/squirrel.cpp4
6 files changed, 60 insertions, 4 deletions
diff --git a/NorthstarDLL/client/clientauthhooks.cpp b/NorthstarDLL/client/clientauthhooks.cpp
index e66da6c8..adb2ab22 100644
--- a/NorthstarDLL/client/clientauthhooks.cpp
+++ b/NorthstarDLL/client/clientauthhooks.cpp
@@ -1,6 +1,7 @@
#include "masterserver/masterserver.h"
#include "core/convar/convar.h"
#include "client/r2client.h"
+#include "core/vanilla.h"
AUTOHOOK_INIT()
@@ -16,6 +17,14 @@ AUTOHOOK(AuthWithStryder, engine.dll + 0x1843A0,
void, __fastcall, (void* a1))
// clang-format on
{
+ // don't attempt to do Atlas auth if we are in vanilla compatibility mode
+ // this prevents users from joining untrustworthy servers (unless they use a concommand or something)
+ if (g_pVanillaCompatibility->GetVanillaCompatibility())
+ {
+ AuthWithStryder(a1);
+ return;
+ }
+
// game will call this forever, until it gets a valid auth key
// so, we need to manually invalidate our key until we're authed with northstar, then we'll allow game to auth with stryder
if (!g_pMasterServerManager->m_bOriginAuthWithMasterServerDone && Cvar_ns_has_agreed_to_send_token->GetInt() != DISAGREED_TO_SEND_TOKEN)
@@ -39,7 +48,7 @@ AUTOHOOK(Auth3PToken, engine.dll + 0x183760,
char*, __fastcall, ())
// clang-format on
{
- if (g_pMasterServerManager->m_sOwnClientAuthToken[0])
+ if (!g_pVanillaCompatibility->GetVanillaCompatibility() && g_pMasterServerManager->m_sOwnClientAuthToken[0])
{
memset(p3PToken, 0x0, 1024);
strcpy(p3PToken, "Protocol 3: Protect the Pilot");
diff --git a/NorthstarDLL/core/vanilla.h b/NorthstarDLL/core/vanilla.h
new file mode 100644
index 00000000..fb809a1a
--- /dev/null
+++ b/NorthstarDLL/core/vanilla.h
@@ -0,0 +1,29 @@
+#pragma once
+
+/// Determines if we are in vanilla-compatibility mode.
+/// In this mode we shouldn't auth with Atlas, which prevents users from joining a
+/// non-trusted server. This means that we can unrestrict client/server commands
+/// as well as various other small changes for compatibility
+class VanillaCompatibility
+{
+ public:
+ void SetVanillaCompatibility(bool isVanilla)
+ {
+ static bool bInitialised = false;
+ if (bInitialised)
+ return;
+
+ bInitialised = true;
+ m_bIsVanillaCompatible = isVanilla;
+ }
+
+ bool GetVanillaCompatibility()
+ {
+ return m_bIsVanillaCompatible;
+ }
+
+ private:
+ bool m_bIsVanillaCompatible = false;
+};
+
+inline VanillaCompatibility* g_pVanillaCompatibility;
diff --git a/NorthstarDLL/dllmain.cpp b/NorthstarDLL/dllmain.cpp
index d82c9ffb..3d9bdc97 100644
--- a/NorthstarDLL/dllmain.cpp
+++ b/NorthstarDLL/dllmain.cpp
@@ -2,6 +2,7 @@
#include "logging/logging.h"
#include "logging/crashhandler.h"
#include "core/memalloc.h"
+#include "core/vanilla.h"
#include "config/profile.h"
#include "plugins/plugin_abi.h"
#include "plugins/plugins.h"
@@ -53,6 +54,10 @@ bool InitialiseNorthstar()
bool bAllFatal = strstr(GetCommandLineA(), "-crash_handle_all") != NULL;
g_pCrashHandler->SetAllFatal(bAllFatal);
+ // determine if we are in vanilla-compatibility mode
+ g_pVanillaCompatibility = new VanillaCompatibility();
+ g_pVanillaCompatibility->SetVanillaCompatibility(strstr(GetCommandLineA(), "-vanilla") != NULL);
+
// Write launcher version to log
StartupLog();
diff --git a/NorthstarDLL/masterserver/masterserver.cpp b/NorthstarDLL/masterserver/masterserver.cpp
index 21b76f73..53a5fa9a 100644
--- a/NorthstarDLL/masterserver/masterserver.cpp
+++ b/NorthstarDLL/masterserver/masterserver.cpp
@@ -3,6 +3,7 @@
#include "shared/playlist.h"
#include "server/auth/serverauthentication.h"
#include "core/tier0.h"
+#include "core/vanilla.h"
#include "engine/r2engine.h"
#include "mods/modmanager.h"
#include "shared/misccommands.h"
@@ -88,7 +89,7 @@ size_t CurlWriteToStringBufferCallback(char* contents, size_t size, size_t nmemb
void MasterServerManager::AuthenticateOriginWithMasterServer(const char* uid, const char* originToken)
{
- if (m_bOriginAuthWithMasterServerInProgress)
+ if (m_bOriginAuthWithMasterServerInProgress || g_pVanillaCompatibility->GetVanillaCompatibility())
return;
// do this here so it's instantly set
@@ -466,7 +467,7 @@ void MasterServerManager::RequestMainMenuPromos()
void MasterServerManager::AuthenticateWithOwnServer(const char* uid, const char* playerToken)
{
// dont wait, just stop if we're trying to do 2 auth requests at once
- if (m_bAuthenticatingWithGameServer)
+ if (m_bAuthenticatingWithGameServer || g_pVanillaCompatibility->GetVanillaCompatibility())
return;
m_bAuthenticatingWithGameServer = true;
@@ -601,7 +602,7 @@ void MasterServerManager::AuthenticateWithOwnServer(const char* uid, const char*
void MasterServerManager::AuthenticateWithServer(const char* uid, const char* playerToken, RemoteServerInfo server, const char* password)
{
// dont wait, just stop if we're trying to do 2 auth requests at once
- if (m_bAuthenticatingWithGameServer)
+ if (m_bAuthenticatingWithGameServer || g_pVanillaCompatibility->GetVanillaCompatibility())
return;
m_bAuthenticatingWithGameServer = true;
diff --git a/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp b/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp
index 2a0a9c2c..8821a40d 100644
--- a/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp
+++ b/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp
@@ -5,6 +5,7 @@
#include "engine/r2engine.h"
#include "client/r2client.h"
#include "core/math/vector.h"
+#include "core/vanilla.h"
AUTOHOOK_INIT()
@@ -33,6 +34,8 @@ AUTOHOOK(CLC_Screenshot_WriteToBuffer, engine.dll + 0x22AF20,
bool, __fastcall, (void* thisptr, void* buffer)) // 48 89 5C 24 ? 57 48 83 EC 20 8B 42 10
// clang-format on
{
+ if (g_pVanillaCompatibility->GetVanillaCompatibility())
+ return CLC_Screenshot_WriteToBuffer(thisptr, buffer);
return false;
}
@@ -41,6 +44,8 @@ AUTOHOOK(CLC_Screenshot_ReadFromBuffer, engine.dll + 0x221F00,
bool, __fastcall, (void* thisptr, void* buffer)) // 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B DA 48 8B 52 38
// clang-format on
{
+ if (g_pVanillaCompatibility->GetVanillaCompatibility())
+ return CLC_Screenshot_ReadFromBuffer(thisptr, buffer);
return false;
}
@@ -261,6 +266,9 @@ bool, __fastcall, (const char* pModName)) // 48 83 EC 28 48 8B 0D ? ? ? ? 48 8D
R2::g_pModName = new char[iSize + 1];
strcpy(R2::g_pModName, pModName);
+ if (g_pVanillaCompatibility->GetVanillaCompatibility())
+ return false;
+
return (!strcmp("r2", pModName) || !strcmp("r1", pModName)) && !Tier0::CommandLine()->CheckParm("-norestrictservercommands");
}
diff --git a/NorthstarDLL/squirrel/squirrel.cpp b/NorthstarDLL/squirrel/squirrel.cpp
index e43686d7..68fffb9b 100644
--- a/NorthstarDLL/squirrel/squirrel.cpp
+++ b/NorthstarDLL/squirrel/squirrel.cpp
@@ -9,6 +9,7 @@
#include "plugins/plugin_abi.h"
#include "plugins/plugins.h"
#include "ns_version.h"
+#include "core/vanilla.h"
#include <any>
@@ -272,6 +273,9 @@ template <ScriptContext context> void SquirrelManager<context>::VMCreated(CSquir
defconst(m_pSQVM, "NS_VERSION_PATCH", version[2]);
defconst(m_pSQVM, "NS_VERSION_DEV", version[3]);
+ // define squirrel constant for if we are in vanilla-compatibility mode
+ defconst(m_pSQVM, "VANILLA", g_pVanillaCompatibility->GetVanillaCompatibility());
+
g_pSquirrel<context>->messageBuffer = new SquirrelMessageBuffer();
g_pPluginManager->InformSQVMCreated(context, newSqvm);
}