diff options
Diffstat (limited to 'NorthstarDedicatedTest/serverauthentication.cpp')
-rw-r--r-- | NorthstarDedicatedTest/serverauthentication.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp index 4af18612..730c601d 100644 --- a/NorthstarDedicatedTest/serverauthentication.cpp +++ b/NorthstarDedicatedTest/serverauthentication.cpp @@ -127,6 +127,12 @@ void ServerAuthenticationManager::StartPlayerAuthServer() return; } + // Log playername and UID from request + spdlog::info( + "Player \"{}\" with UID \"{}\" requested to join", + request.get_param_value("username").c_str(), + request.get_param_value("id").c_str()); + AuthData newAuthData {}; strncpy(newAuthData.uid, request.get_param_value("id").c_str(), sizeof(newAuthData.uid)); newAuthData.uid[sizeof(newAuthData.uid) - 1] = 0; @@ -194,6 +200,9 @@ bool ServerAuthenticationManager::AuthenticatePlayer(void* player, int64_t uid, // use stored auth data AuthData authData = m_authData[authToken]; + // Log playnername and UID from request + spdlog::info("Comparing connecting UID \"{}\" against stored UID from ms auth request \"{}\"", strUid.c_str(), authData.uid); + if (!strcmp(strUid.c_str(), authData.uid)) // connecting client's uid is the same as auth's uid { authFail = false; @@ -278,6 +287,8 @@ bool ServerAuthenticationManager::RemovePlayerAuthData(void* player) { if (!strcmp((char*)player + 0xF500, auth.second.uid)) { + // Log UID + spdlog::info("Erasing auth data from UID \"{}\"", auth.second.uid); // pretty sure this is fine, since we don't iterate after the erase // i think if we iterated after it'd be undefined behaviour tho std::lock_guard<std::mutex> guard(m_authDataMutex); @@ -350,6 +361,9 @@ void* CBaseServer__ConnectClientHook( nextPlayerToken = serverFilter; nextPlayerUid = uid; + // Random UID log + spdlog::info("CBaseServer__ConnectClientHook says UID \"{}\"", uid); + return CBaseServer__ConnectClient(server, a2, a3, a4, a5, a6, a7, a8, serverFilter, a10, a11, a12, a13, a14, uid, a16, a17); } @@ -362,6 +376,9 @@ bool CBaseClient__ConnectHook(void* self, char* name, __int64 netchan_ptr_arg, c // we connect irregardless of auth, because returning bad from this function can fuck client state p bad bool ret = CBaseClient__Connect(self, name, netchan_ptr_arg, b_fake_player_arg, a5, Buffer, a7); + // Another UID log + spdlog::info("CBaseClient__ConnectHook says UID \"{}\"", nextPlayerUid); + if (!ret) return ret; @@ -385,6 +402,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; @@ -392,6 +411,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) @@ -401,6 +435,8 @@ void CBaseClient__ActivatePlayerHook(void* self) g_ServerAuthenticationManager->WritePersistentData(self); g_MasterServerManager->UpdateServerPlayerCount(g_ServerAuthenticationManager->m_additionalPlayerData.size()); } + // Log UID + spdlog::info("In CBaseClient__ActivatePlayerHook, activating UID \"{}\"", (char*)self + 0xF500); CBaseClient__ActivatePlayer(self); } @@ -682,6 +718,7 @@ void InitialiseServerAuthentication(HMODULE baseAddress) } // patch to allow same of multiple account + if (CommandLine()->CheckParm("-allowdupeaccounts")) { NSMem::BytePatch( ba + 0x114510, |