diff --git a/reactos/base/applications/rapps/installed.cpp b/reactos/base/applications/rapps/installed.cpp index 12f729c067f..578087b69c8 100644 --- a/reactos/base/applications/rapps/installed.cpp +++ b/reactos/base/applications/rapps/installed.cpp @@ -32,7 +32,7 @@ GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR szString) return TRUE; } - szString = L"---"; + StringCchCopyW(szString, MAX_PATH, L"---"); return FALSE; } @@ -44,8 +44,8 @@ IsInstalledApplication(const ATL::CStringW &RegName, BOOL IsUserKey, REGSAM keyW ATL::CStringW szPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegName; if (RegOpenKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, - szPath, 0, keyWow | KEY_READ, - &hKey) == ERROR_SUCCESS) + szPath, 0, keyWow | KEY_READ, + &hKey) == ERROR_SUCCESS) { IsInstalled = TRUE; } @@ -62,17 +62,17 @@ InstalledVersion(ATL::CStringW& szVersionResult, const ATL::CStringW& RegName, B ATL::CStringW szPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegName; if (RegOpenKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, - szPath.GetString(), 0, keyWow | KEY_READ, - &hKey) == ERROR_SUCCESS) + szPath.GetString(), 0, keyWow | KEY_READ, + &hKey) == ERROR_SUCCESS) { - DWORD dwSize = MAX_PATH; + DWORD dwSize = MAX_PATH * sizeof(WCHAR); DWORD dwType = REG_SZ; if (RegQueryValueExW(hKey, - L"DisplayVersion", - NULL, - &dwType, - (LPBYTE) szVersion.GetBuffer(dwSize), - &dwSize) == ERROR_SUCCESS) + L"DisplayVersion", + NULL, + &dwType, + (LPBYTE) szVersion.GetBuffer(MAX_PATH), + &dwSize) == ERROR_SUCCESS) { szVersion.ReleaseBuffer(); szVersionResult = szVersion; @@ -126,11 +126,11 @@ UninstallApplication(INT Index, BOOL bModify) if (!ListView_GetItem(hListView, &Item)) return FALSE; - ItemInfo = (PINSTALLED_INFO)Item.lParam; + ItemInfo = (PINSTALLED_INFO) Item.lParam; hKey = ItemInfo->hSubKey; dwType = REG_SZ; - dwSize = sizeof(szPath); + dwSize = MAX_PATH * sizeof(WCHAR); if (RegQueryValueExW(hKey, bModify ? szModify : szUninstall, NULL, @@ -208,11 +208,14 @@ RemoveAppFromRegistry(INT Index) if (MessageBoxW(hMainWnd, szMsgText, szMsgTitle, MB_YESNO | MB_ICONQUESTION) == IDYES) { - wcsncat(szFullName, Info->szKeyName.GetString(), MAX_PATH - wcslen(szFullName)); + ATL::CStringW::CopyChars(szFullName, + MAX_PATH, + Info->szKeyName.GetString(), + MAX_PATH - wcslen(szFullName)); if (RegDeleteKeyW(Info->hRootKey, szFullName) == ERROR_SUCCESS) { - (VOID) ListView_DeleteItem(hListView, ItemIndex); + ListView_DeleteItem(hListView, ItemIndex); return; } @@ -267,21 +270,22 @@ EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc) } dwType = REG_SZ; - dwSize = MAX_PATH; + dwSize = MAX_PATH * sizeof(WCHAR); bIsUpdate = (RegQueryValueExW(Info.hSubKey, L"ParentKeyName", NULL, &dwType, - (LPBYTE) szParentKeyName.GetBuffer(dwSize), + (LPBYTE) szParentKeyName.GetBuffer(MAX_PATH), &dwSize) == ERROR_SUCCESS); szParentKeyName.ReleaseBuffer(); - dwSize = sizeof(szDisplayName); + dwType = REG_SZ; + dwSize = MAX_PATH * sizeof(WCHAR); if (RegQueryValueExW(Info.hSubKey, L"DisplayName", NULL, &dwType, - (LPBYTE) szDisplayName.GetBuffer(dwSize), + (LPBYTE) szDisplayName.GetBuffer(MAX_PATH), &dwSize) == ERROR_SUCCESS) { szDisplayName.ReleaseBuffer(); diff --git a/reactos/base/applications/rapps/loaddlg.cpp b/reactos/base/applications/rapps/loaddlg.cpp index 6ce1a174bd3..c0415c1bc07 100644 --- a/reactos/base/applications/rapps/loaddlg.cpp +++ b/reactos/base/applications/rapps/loaddlg.cpp @@ -366,8 +366,8 @@ ThreadFunc(LPVOID Context) memset(&urlComponents, 0, sizeof(urlComponents)); urlComponents.dwStructSize = sizeof(urlComponents); - - if (FAILED(StringCbLengthW(AppInfo->szUrlDownload, sizeof(AppInfo->szUrlDownload), &urlLength))) + + if (AppInfo->szUrlDownload.GetLength() > urlLength) goto end; urlLength /= sizeof(WCHAR); diff --git a/reactos/base/applications/rapps/misc.cpp b/reactos/base/applications/rapps/misc.cpp index e7cb87214a4..1115262c7b1 100644 --- a/reactos/base/applications/rapps/misc.cpp +++ b/reactos/base/applications/rapps/misc.cpp @@ -493,10 +493,3 @@ UINT ParserGetInt(const ATL::CStringW& KeyName, const ATL::CStringW& FileName) return (UINT) Result; } - -LPWSTR HeapBufferFromCStringW(const ATL::CStringW& String) -{ - LPWSTR szBuffer = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); - ATL::CString::CopyChars(szBuffer, MAX_PATH, String.GetString(), String.GetLength() + 1); - return szBuffer; -} \ No newline at end of file diff --git a/reactos/base/applications/rapps/rosui.h b/reactos/base/applications/rapps/rosui.h index 9456379bb32..b372dfca705 100644 --- a/reactos/base/applications/rapps/rosui.h +++ b/reactos/base/applications/rapps/rosui.h @@ -495,7 +495,8 @@ public: void GetWindowTextW(ATL::CStringW& szText) { - CWindow::GetWindowText(szText.GetBuffer(MAX_STR_LEN), MAX_STR_LEN); + INT length = CWindow::GetWindowTextLengthW(); + CWindow::GetWindowText(szText.GetBuffer(length), length); szText.ReleaseBuffer(); } }; diff --git a/reactos/base/applications/rapps/winmain.cpp b/reactos/base/applications/rapps/winmain.cpp index 35fff2a942f..82fffaf1d27 100644 --- a/reactos/base/applications/rapps/winmain.cpp +++ b/reactos/base/applications/rapps/winmain.cpp @@ -69,7 +69,10 @@ FillDefaultSettings(PSETTINGS_INFO pSettingsInfo) szDownloadDir.ReleaseBuffer(); szDownloadDir += L"\\RAPPS Downloads"; - StringCchCopyW(pSettingsInfo->szDownloadDir, _countof(pSettingsInfo->szDownloadDir), szDownloadDir.GetString()); + ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir, + _countof(pSettingsInfo->szDownloadDir), + szDownloadDir.GetString(), + szDownloadDir.GetLength() + 1); pSettingsInfo->bDelInstaller = FALSE; pSettingsInfo->Maximized = FALSE; @@ -79,8 +82,8 @@ FillDefaultSettings(PSETTINGS_INFO pSettingsInfo) pSettingsInfo->Height = 450; pSettingsInfo->Proxy = 0; - StringCbCopyW(pSettingsInfo->szProxyServer, sizeof(pSettingsInfo->szProxyServer), L""); - StringCbCopyW(pSettingsInfo->szNoProxyFor, sizeof(pSettingsInfo->szNoProxyFor), L""); + pSettingsInfo->szProxyServer[0] = UNICODE_NULL; + pSettingsInfo->szNoProxyFor[0] = UNICODE_NULL; } static BOOL