diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-11-07 22:06:19 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-11-07 22:06:19 +0000 |
commit | ae09e612ea33cb105a47996c4ae3bf8651119042 (patch) | |
tree | 91c46140555d3a85c0e6bceb1da3d1c031ae40be /NorthstarDedicatedTest/clientauthhooks.cpp | |
parent | 916f4f53ad839d6f8e565e50bb310429a3e115f3 (diff) | |
download | NorthstarLauncher-ae09e612ea33cb105a47996c4ae3bf8651119042.tar.gz NorthstarLauncher-ae09e612ea33cb105a47996c4ae3bf8651119042.zip |
beginning work on new auth
Diffstat (limited to 'NorthstarDedicatedTest/clientauthhooks.cpp')
-rw-r--r-- | NorthstarDedicatedTest/clientauthhooks.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/clientauthhooks.cpp b/NorthstarDedicatedTest/clientauthhooks.cpp new file mode 100644 index 00000000..ff7e42f6 --- /dev/null +++ b/NorthstarDedicatedTest/clientauthhooks.cpp @@ -0,0 +1,42 @@ +#include "pch.h" +#include "clientauthhooks.h" +#include "hookutils.h" +#include "dedicated.h" +#include "gameutils.h" +#include "masterserver.h" +#include "convar.h" + +typedef void(*AuthWithStryderType)(void* a1); +AuthWithStryderType AuthWithStryder; + +ConVar* Cvar_ns_has_agreed_to_send_token; + +void AuthWithStryderHook(void* a1) +{ + // 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_MasterServerManager->m_bOriginAuthWithMasterServerDone) + { + // if player has agreed to send token and we aren't already authing, try to auth + if (Cvar_ns_has_agreed_to_send_token->m_nValue && !g_MasterServerManager->m_bOriginAuthWithMasterServerInProgress) + g_MasterServerManager->AuthenticateOriginWithMasterServer(g_LocalPlayerUserID, g_LocalPlayerOriginToken); + + // invalidate key so auth will fail + *g_LocalPlayerOriginToken = 0; + } + + AuthWithStryder(a1); +} + +void InitialiseClientAuthHooks(HMODULE baseAddress) +{ + if (IsDedicated()) + return; + + // this cvar will save to cfg once initially agreed with + Cvar_ns_has_agreed_to_send_token = RegisterConVar("ns_has_agreed_to_send_token", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "whether the user has agreed to send their origin token to the northstar masterserver"); + + HookEnabler hook; + ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x1843A0, &AuthWithStryderHook, reinterpret_cast<LPVOID*>(&AuthWithStryder)); +}
\ No newline at end of file |