aboutsummaryrefslogtreecommitdiff
path: root/primedev/client/clientauthhooks.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-12-27 00:32:01 +0000
committerGitHub <noreply@github.com>2023-12-27 01:32:01 +0100
commitf5ab6fb5e8be7b73e6003d4145081d5e0c0ce287 (patch)
tree90f2c6a4885dbd181799e2325cf33588697674e1 /primedev/client/clientauthhooks.cpp
parentbb8ed59f6891b1196c5f5bbe7346cd171c8215fa (diff)
downloadNorthstarLauncher-f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287.tar.gz
NorthstarLauncher-f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287.zip
Folder restructuring from primedev (#624)v1.21.2-rc3v1.21.2
Copies of over the primedev folder structure for easier cherry-picking of further changes Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'primedev/client/clientauthhooks.cpp')
-rw-r--r--primedev/client/clientauthhooks.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/primedev/client/clientauthhooks.cpp b/primedev/client/clientauthhooks.cpp
new file mode 100644
index 00000000..35ae3aa7
--- /dev/null
+++ b/primedev/client/clientauthhooks.cpp
@@ -0,0 +1,72 @@
+#include "masterserver/masterserver.h"
+#include "core/convar/convar.h"
+#include "client/r2client.h"
+#include "core/vanilla.h"
+
+AUTOHOOK_INIT()
+
+ConVar* Cvar_ns_has_agreed_to_send_token;
+
+// mirrored in script
+const int NOT_DECIDED_TO_SEND_TOKEN = 0;
+const int AGREED_TO_SEND_TOKEN = 1;
+const int DISAGREED_TO_SEND_TOKEN = 2;
+
+// clang-format off
+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)
+ {
+ // if player has agreed to send token and we aren't already authing, try to auth
+ if (Cvar_ns_has_agreed_to_send_token->GetInt() == AGREED_TO_SEND_TOKEN &&
+ !g_pMasterServerManager->m_bOriginAuthWithMasterServerInProgress)
+ g_pMasterServerManager->AuthenticateOriginWithMasterServer(g_pLocalPlayerUserID, g_pLocalPlayerOriginToken);
+
+ // invalidate key so auth will fail
+ *g_pLocalPlayerOriginToken = 0;
+ }
+
+ AuthWithStryder(a1);
+}
+
+char* p3PToken;
+
+// clang-format off
+AUTOHOOK(Auth3PToken, engine.dll + 0x183760,
+char*, __fastcall, ())
+// clang-format on
+{
+ if (!g_pVanillaCompatibility->GetVanillaCompatibility() && g_pMasterServerManager->m_sOwnClientAuthToken[0])
+ {
+ memset(p3PToken, 0x0, 1024);
+ strcpy(p3PToken, "Protocol 3: Protect the Pilot");
+ }
+
+ return Auth3PToken();
+}
+
+ON_DLL_LOAD_CLIENT_RELIESON("engine.dll", ClientAuthHooks, ConVar, (CModule module))
+{
+ AUTOHOOK_DISPATCH()
+
+ p3PToken = module.Offset(0x13979D80).RCast<char*>();
+
+ // this cvar will save to cfg once initially agreed with
+ Cvar_ns_has_agreed_to_send_token = new ConVar(
+ "ns_has_agreed_to_send_token",
+ "0",
+ FCVAR_ARCHIVE_PLAYERPROFILE,
+ "whether the user has agreed to send their origin token to the northstar masterserver");
+}