From 653c29d0bd1bcd398a5e2076d37360875caa38dd Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 20 Feb 2012 11:50:47 -0500 Subject: [PATCH 1/2] Restore eap's misunderstanding of endianness. --- Sources/Plasma/Apps/plClient/winmain.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 40b69d88..b4605fb7 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -989,8 +989,15 @@ static void SaveUserPass (LoginDialogParam *pLoginParam, char *password) if (StrLen(domain) == 0 || StrCmpI(domain, L"gametap") == 0) { plSHA1Checksum shasum(StrLen(password) * sizeof(password[0]), (uint8_t*)password); - - memcpy(pLoginParam->namePassHash, shasum.GetValue(), sizeof(ShaDigest)); + uint32_t* dest = reinterpret_cast(pLoginParam->namePassHash); + const uint32_t* from = reinterpret_cast(shasum.GetValue()); + + // I blame eap for this ass shit + dest[0] = hsToBE32(from[0]); + dest[1] = hsToBE32(from[1]); + dest[2] = hsToBE32(from[2]); + dest[3] = hsToBE32(from[3]); + dest[4] = hsToBE32(from[4]); } else { From 897abb7200995ba0d52ac640b8bb6196a36d8cbb Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 20 Feb 2012 12:06:41 -0500 Subject: [PATCH 2/2] Chip away at uses of pnUtStr --- Sources/Plasma/Apps/plClient/winmain.cpp | 18 +++++++----------- .../plNetClientComm/plNetClientComm.cpp | 2 +- .../plNetClientComm/plNetClientComm.h | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index b4605fb7..e003f674 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -970,22 +970,18 @@ BOOL CALLBACK UruTOSDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l static void SaveUserPass (LoginDialogParam *pLoginParam, char *password) { uint32_t cryptKey[4]; - ZeroMemory(cryptKey, sizeof(cryptKey)); + memset(cryptKey, 0, sizeof(cryptKey)); GetCryptKey(cryptKey, arrsize(cryptKey)); - wchar_t wusername[kMaxAccountNameLength]; - wchar_t wpassword[kMaxPasswordLength]; - - StrToUnicode(wusername, pLoginParam->username, arrsize(wusername)); + plString theUser = _TEMP_CONVERT_FROM_LITERAL(pLoginParam->username); + plString thePass = (_TEMP_CONVERT_FROM_LITERAL(password)).Left(kMaxPasswordLength); // if the password field is the fake string then we've already // loaded the namePassHash from the file - if (StrCmp(password, FAKE_PASS_STRING) != 0) + if (thePass.Compare(FAKE_PASS_STRING) != 0) { - StrToUnicode(wpassword, password, arrsize(wpassword)); - wchar_t domain[15]; - PathSplitEmail(wusername, nil, 0, domain, arrsize(domain), nil, 0, nil, 0, 0); + PathSplitEmail(_TEMP_CONVERT_TO_WCHAR_T(theUser), nil, 0, domain, arrsize(domain), nil, 0, nil, 0, 0); if (StrLen(domain) == 0 || StrCmpI(domain, L"gametap") == 0) { plSHA1Checksum shasum(StrLen(password) * sizeof(password[0]), (uint8_t*)password); @@ -1001,11 +997,11 @@ static void SaveUserPass (LoginDialogParam *pLoginParam, char *password) } else { - CryptHashPassword(_TEMP_CONVERT_FROM_WCHAR_T(wusername), _TEMP_CONVERT_FROM_WCHAR_T(wpassword), pLoginParam->namePassHash); + CryptHashPassword(theUser, thePass, pLoginParam->namePassHash); } } - NetCommSetAccountUsernamePassword(wusername, pLoginParam->namePassHash); + NetCommSetAccountUsernamePassword(_TEMP_CONVERT_TO_WCHAR_T(theUser), pLoginParam->namePassHash); if (TGIsCider) NetCommSetAuthTokenAndOS(nil, L"mac"); else diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp index 41be9ca9..b817fbae 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp @@ -1037,7 +1037,7 @@ void NetCommSetMsgPreHandler ( //============================================================================ void NetCommSetAccountUsernamePassword ( - wchar_t username[], + const wchar_t username[], const ShaDigest & namePassHash ) { StrCopy(s_iniAccountUsername, username, arrsize(s_iniAccountUsername)); diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h index d22e422f..8dd0c0e9 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h @@ -102,7 +102,7 @@ const ARRAY(NetCommPlayer) & NetCommGetPlayerList (); unsigned NetCommGetPlayerCount (); bool NetCommIsLoginComplete (); void NetCommSetReadIniAccountInfo (bool readFromIni); -void NetCommSetAccountUsernamePassword (wchar_t username[], const ShaDigest & namePassHash); +void NetCommSetAccountUsernamePassword (const wchar_t username[], const ShaDigest & namePassHash); void NetCommSetAuthTokenAndOS (wchar_t authToken[], wchar_t os[]); ENetError NetCommGetAuthResult ();