diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-08-24 00:32:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 00:32:31 +0100 |
commit | f9bc3c9d1834cb8bd5f872b749b057c33e8b0102 (patch) | |
tree | e96e2da0d95798dd42eddf644a82a74555db858f /NorthstarDLL/clientauthhooks.cpp | |
parent | 812893d8219daa60f5b5b7fd22cbd6b175603399 (diff) | |
download | NorthstarLauncher-f9bc3c9d1834cb8bd5f872b749b057c33e8b0102.tar.gz NorthstarLauncher-f9bc3c9d1834cb8bd5f872b749b057c33e8b0102.zip |
Adjust folder structure (#242)
* Adjust folder structure
* change launcher directory name
Diffstat (limited to 'NorthstarDLL/clientauthhooks.cpp')
-rw-r--r-- | NorthstarDLL/clientauthhooks.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/NorthstarDLL/clientauthhooks.cpp b/NorthstarDLL/clientauthhooks.cpp new file mode 100644 index 00000000..5c1c4510 --- /dev/null +++ b/NorthstarDLL/clientauthhooks.cpp @@ -0,0 +1,47 @@ +#include "pch.h" +#include "clientauthhooks.h" +#include "hookutils.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; + +// 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; + +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 && 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_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) +{ + // 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"); + + HookEnabler hook; + ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x1843A0, &AuthWithStryderHook, reinterpret_cast<LPVOID*>(&AuthWithStryder)); +}
\ No newline at end of file |