Author: ashaposhnikov
Date: Mon Jul 10 22:26:01 2017
New Revision: 75316

URL: http://svn.reactos.org/svn/reactos?rev=75316&view=rev
Log:
[RAPPS] Some fixes
- winmain.cpp, loaddlg.cpp, installed.cpp: 
  Changed string-related opreations
- installed.cpp: Fixed buffer sizing when calling RegQueryValueExW()
- misc.cpp: Removed unused function
- rosui.h: Made use of GetWindowTextLength()
        

Modified:
    branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp
    branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp
    branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp
    branches/GSoC_2017/rapps/reactos/base/applications/rapps/rosui.h
    branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp

Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp?rev=75316&r1=75315&r2=75316&view=diff
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp      
[iso-8859-1] (original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp      
[iso-8859-1] Mon Jul 10 22:26:01 2017
@@ -32,7 +32,7 @@
         return TRUE;
     }
 
-    szString = L"---";
+    StringCchCopyW(szString, MAX_PATH, L"---");
     return FALSE;
 }
 
@@ -44,8 +44,8 @@
     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 @@
     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)
-    {
-        DWORD dwSize = MAX_PATH;
+                      szPath.GetString(), 0, keyWow | KEY_READ,
+                      &hKey) == ERROR_SUCCESS)
+    {
+        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 @@
     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 @@
 
     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 @@
             }
 
             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();

Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp?rev=75316&r1=75315&r2=75316&view=diff
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp        
[iso-8859-1] (original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp        
[iso-8859-1] Mon Jul 10 22:26:01 2017
@@ -366,8 +366,8 @@
 
     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);

Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp?rev=75316&r1=75315&r2=75316&view=diff
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp   
[iso-8859-1] (original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp   
[iso-8859-1] Mon Jul 10 22:26:01 2017
@@ -493,10 +493,3 @@
 
     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;
-}

Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/rosui.h
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/applications/rapps/rosui.h?rev=75316&r1=75315&r2=75316&view=diff
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/rosui.h    
[iso-8859-1] (original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/rosui.h    
[iso-8859-1] Mon Jul 10 22:26:01 2017
@@ -495,7 +495,8 @@
 
     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();
     }
 };

Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp?rev=75316&r1=75315&r2=75316&view=diff
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp        
[iso-8859-1] (original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp        
[iso-8859-1] Mon Jul 10 22:26:01 2017
@@ -69,7 +69,10 @@
         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 @@
     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


Reply via email to