aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
diff options
context:
space:
mode:
authorBarnaby <22575741+barnabwhy@users.noreply.github.com>2022-05-13 00:49:43 +0100
committerGitHub <noreply@github.com>2022-05-13 01:49:43 +0200
commit0bd42559b53e1a0d210b0542803d76d5f8803070 (patch)
tree493d1073a02c264993d9d7ad1e3be51776edc63c /NorthstarDedicatedTest
parent6c8112a6c368dd36d21fd94689e9682bc3b012a5 (diff)
downloadNorthstarLauncher-0bd42559b53e1a0d210b0542803d76d5f8803070.tar.gz
NorthstarLauncher-0bd42559b53e1a0d210b0542803d76d5f8803070.zip
Compare uid from connect on activate (#175)
* Compare UID from connect on activate * only set uid on first time i think
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/serverauthentication.cpp17
-rw-r--r--NorthstarDedicatedTest/serverauthentication.h4
2 files changed, 20 insertions, 1 deletions
diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp
index 19253fdb..b116c6e3 100644
--- a/NorthstarDedicatedTest/serverauthentication.cpp
+++ b/NorthstarDedicatedTest/serverauthentication.cpp
@@ -387,6 +387,8 @@ bool CBaseClient__ConnectHook(void* self, char* name, __int64 netchan_ptr_arg, c
additionalData.usingLocalPdata = *((char*)self + 0x4a0) == (char)0x3;
g_ServerAuthenticationManager->m_additionalPlayerData.insert(std::make_pair(self, additionalData));
+
+ g_ServerAuthenticationManager->m_additionalPlayerData[self].uid = nextPlayerUid;
}
return ret;
@@ -394,6 +396,21 @@ bool CBaseClient__ConnectHook(void* self, char* name, __int64 netchan_ptr_arg, c
void CBaseClient__ActivatePlayerHook(void* self)
{
+ bool uidMatches = false;
+ if (g_ServerAuthenticationManager->m_additionalPlayerData.count(self))
+ {
+ std::string strUid = std::to_string(g_ServerAuthenticationManager->m_additionalPlayerData[self].uid);
+ if (!strcmp(strUid.c_str(), (char*)self + 0xF500)) // connecting client's uid is the same as auth's uid
+ {
+ uidMatches = true;
+ }
+ }
+ if (!uidMatches)
+ {
+ CBaseClient__Disconnect(self, 1, "Authentication Failed");
+ return;
+ }
+
// if we're authed, write our persistent data
// RemovePlayerAuthData returns true if it removed successfully, i.e. on first call only, and we only want to write on >= second call
// (since this func is called on map loads)
diff --git a/NorthstarDedicatedTest/serverauthentication.h b/NorthstarDedicatedTest/serverauthentication.h
index 41e771b8..e79577e6 100644
--- a/NorthstarDedicatedTest/serverauthentication.h
+++ b/NorthstarDedicatedTest/serverauthentication.h
@@ -28,6 +28,8 @@ struct AdditionalPlayerData
double lastSayTextLimitStart = -1.0;
int sayTextLimitCount = 0;
+
+ uint64_t uid;
};
#pragma once
@@ -107,4 +109,4 @@ extern CBaseClient__DisconnectType CBaseClient__Disconnect;
void InitialiseServerAuthentication(HMODULE baseAddress);
extern ServerAuthenticationManager* g_ServerAuthenticationManager;
-extern ConVar* Cvar_ns_player_auth_port; \ No newline at end of file
+extern ConVar* Cvar_ns_player_auth_port;