blob: ff7e42f68df6d53af487741a4d6e8e7f36b69a98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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));
}
|