From 0187778dcefb66bf306478266ac19e0651a6b2f2 Mon Sep 17 00:00:00 2001 From: AconiteX <63141077+AconiteX@users.noreply.github.com> Date: Fri, 3 Sep 2021 12:26:03 -0400 Subject: [PATCH] Add Login Session GUID Tracking Support --- .../src/shared/network/GameNetwork.cpp | 16 ++++++++++++++++ .../clientGame/src/shared/network/GameNetwork.h | 3 +++ .../src/shared/network/LoginConnection.cpp | 13 +++++++++++-- .../clientLoginServer/ClientLoginMessages.cpp | 15 +++++++++++++++ .../clientLoginServer/ClientLoginMessages.h | 10 ++++++++++ .../src/shared/page/SwgCuiLoginScreen.cpp | 16 ++++++++++++++++ 6 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/engine/client/library/clientGame/src/shared/network/GameNetwork.cpp b/src/engine/client/library/clientGame/src/shared/network/GameNetwork.cpp index 77a96beda..4543a6da2 100644 --- a/src/engine/client/library/clientGame/src/shared/network/GameNetwork.cpp +++ b/src/engine/client/library/clientGame/src/shared/network/GameNetwork.cpp @@ -261,6 +261,7 @@ m_userPassword (ConfigClientGame::getLoginClientPassword()), m_userIpAddress (), m_centralServerName (), m_pendingCentralServerName (), +m_guid (), m_loginTokenLength (0), m_userPort (0), m_acceptSceneCommand (false), @@ -466,6 +467,13 @@ void GameNetwork::setUserPassword (const std::string & newUserPassword) s_instance->m_userPassword = newUserPassword; } +//------------------------------------------------------------------- + +void GameNetwork::setUserGuid(const std::string& newUserGuid) +{ + s_instance->m_guid = newUserGuid; +} + //----------------------------------------------------------------------- void GameNetwork::startScene(const std::string & sceneName, const NetworkId & objectId, const std::string & templateName, const Vector & startPosition, const float startYaw, const float timeInSeconds, bool disableSnapshot) @@ -790,6 +798,14 @@ const std::string & GameNetwork::getUserPassword (void) //------------------------------------------------------------------- +const std::string& GameNetwork::getUserGuid(void) +{ + DEBUG_FATAL(s_instance == 0, ("GameNetwork not installed")); + return s_instance->m_guid; +} + +//------------------------------------------------------------------- + const std::string & GameNetwork::getUserIpAddress (void) { DEBUG_FATAL(s_instance == 0, ("GameNetwork not installed")); diff --git a/src/engine/client/library/clientGame/src/shared/network/GameNetwork.h b/src/engine/client/library/clientGame/src/shared/network/GameNetwork.h index 6f4c27f5e..b983eb768 100644 --- a/src/engine/client/library/clientGame/src/shared/network/GameNetwork.h +++ b/src/engine/client/library/clientGame/src/shared/network/GameNetwork.h @@ -70,6 +70,7 @@ public: static const uint16 getLoginTokenLength (); static const std::string & getUserName (); static const std::string & getUserPassword (); + static const std::string & getUserGuid(); static const std::string & getUserIpAddress (); static uint16 getUserPort (); static const ConnectionServerConnection* getConnectionServerConnection(); @@ -95,6 +96,7 @@ public: static void setSceneChannel (); static void setUserName (const std::string & newUserName); static void setUserPassword (const std::string & newUserPassword); + static void setUserGuid (const std::string& newUserGuid); static void startScene (const std::string & sceneName, const NetworkId & characterObjectId, const std::string & characterTemplateName, @@ -144,6 +146,7 @@ private: std::string m_userIpAddress; std::string m_centralServerName; std::string m_pendingCentralServerName; + std::string m_guid; uint16 m_loginTokenLength; uint16 m_userPort; bool m_acceptSceneCommand; diff --git a/src/engine/client/library/clientGame/src/shared/network/LoginConnection.cpp b/src/engine/client/library/clientGame/src/shared/network/LoginConnection.cpp index f3a38ebbf..4f4de5a83 100644 --- a/src/engine/client/library/clientGame/src/shared/network/LoginConnection.cpp +++ b/src/engine/client/library/clientGame/src/shared/network/LoginConnection.cpp @@ -65,8 +65,17 @@ void LoginConnection::onConnectionOpened() if (CuiLoginManager::getSessionIdKey() && !ConfigClientGame::getEnableAdminLogin()) sendUserName = false; - LoginClientId id(sendUserName ? GameNetwork::getUserName() : "", GameNetwork::getUserPassword()); - send(id, true); + if(!GameNetwork::getUserGuid().empty()) + { + LoginClientId id(sendUserName ? GameNetwork::getUserName() : "", GameNetwork::getUserPassword(), GameNetwork::getUserGuid()); + send(id, true); + } + else + { + LoginClientId id(sendUserName ? GameNetwork::getUserName() : "", GameNetwork::getUserPassword()); + send(id, true); + } + #if PRODUCTION != 1 GenericValueTypeMessage< int > msg( "RequestExtendedClusterInfo", 0 ); diff --git a/src/engine/shared/library/sharedNetworkMessages/src/shared/clientLoginServer/ClientLoginMessages.cpp b/src/engine/shared/library/sharedNetworkMessages/src/shared/clientLoginServer/ClientLoginMessages.cpp index 6b4b8d93c..cb11da2ea 100644 --- a/src/engine/shared/library/sharedNetworkMessages/src/shared/clientLoginServer/ClientLoginMessages.cpp +++ b/src/engine/shared/library/sharedNetworkMessages/src/shared/clientLoginServer/ClientLoginMessages.cpp @@ -30,6 +30,21 @@ version(ConfigVersion ? ConfigVersion : NetworkVersionId) //-- todo production //----------------------------------------------------------------------- + +LoginClientId::LoginClientId(const std::string& newId, const std::string& newKey, const std::string& guidVal) : + GameNetworkMessage("LoginClientId"), + id(newId), + key(newKey), + version(NetworkVersionId), + guid(guidVal) +{ + addVariable(id); + addVariable(key); + addVariable(version); + addVariable(guid); +} +//----------------------------------------------------------------------- + LoginClientId::LoginClientId(Archive::ReadIterator & source) : GameNetworkMessage("LoginClientId"), id(), diff --git a/src/engine/shared/library/sharedNetworkMessages/src/shared/clientLoginServer/ClientLoginMessages.h b/src/engine/shared/library/sharedNetworkMessages/src/shared/clientLoginServer/ClientLoginMessages.h index c2ef738e5..7bc6cc243 100644 --- a/src/engine/shared/library/sharedNetworkMessages/src/shared/clientLoginServer/ClientLoginMessages.h +++ b/src/engine/shared/library/sharedNetworkMessages/src/shared/clientLoginServer/ClientLoginMessages.h @@ -22,15 +22,18 @@ class LoginClientId : public GameNetworkMessage { public: LoginClientId(const std::string & newId, const std::string & newKey); + LoginClientId(const std::string & newId, const std::string & newKey, const std::string & guid); LoginClientId(Archive::ReadIterator & source); ~LoginClientId(); const std::string & getId () const; const std::string & getKey () const; const std::string & getVersion () const; + const std::string & getGuid() const; private: Archive::AutoVariable id; Archive::AutoVariable key; Archive::AutoVariable version; + Archive::AutoVariable guid; LoginClientId(); LoginClientId(const LoginClientId&); @@ -60,6 +63,13 @@ inline const std::string & LoginClientId::getVersion() const //----------------------------------------------------------------------- +inline const std::string& LoginClientId::getGuid() const +{ + return guid.get(); +} + +//----------------------------------------------------------------------- + class LoginClientToken : public GameNetworkMessage { public: diff --git a/src/game/client/library/swgClientUserInterface/src/shared/page/SwgCuiLoginScreen.cpp b/src/game/client/library/swgClientUserInterface/src/shared/page/SwgCuiLoginScreen.cpp index cc6cd0bd3..412623e44 100644 --- a/src/game/client/library/swgClientUserInterface/src/shared/page/SwgCuiLoginScreen.cpp +++ b/src/game/client/library/swgClientUserInterface/src/shared/page/SwgCuiLoginScreen.cpp @@ -244,6 +244,22 @@ void SwgCuiLoginScreen::ok () GameNetwork::setUserName (Unicode::wideToNarrow (name)); GameNetwork::setUserPassword (Unicode::wideToNarrow (passwd)); + char szGUID[255]; + memset(szGUID, 0, 255); + DWORD lSize = 255; + HKEY hKey; + ULONG ulResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", 0, + KEY_WOW64_64KEY + KEY_READ, &hKey); + if (ulResult == ERROR_SUCCESS) + { + ulResult = RegGetValue(hKey, "", "MachineGUID", RRF_RT_ANY, nullptr, szGUID, &lSize); + if (ulResult == ERROR_SUCCESS) + { + GameNetwork::setUserGuid(szGUID); + } + } + RegCloseKey(hKey); + std::vector > loginServerList; {