Author: rharabien
Date: Sun Jan 15 13:24:26 2012
New Revision: 54971

URL: http://svn.reactos.org/svn/reactos?rev=54971&view=rev
Log:
[SYSSETUP]
- Fix GetRosInstallCD - GetLogicalDriveStringsW returns drive paths, not 
letters.
- When building intl.cpl command line for unattended setup don't use %S - 
swprint interprets it as multi-byte string. Use "%s" instead. This bug caused 
yesterdays KVM problems.

Modified:
    trunk/reactos/dll/win32/syssetup/wizard.c

Modified: trunk/reactos/dll/win32/syssetup/wizard.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/wizard.c?rev=54971&r1=54970&r2=54971&view=diff
==============================================================================
--- trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] Sun Jan 15 13:24:26 
2012
@@ -46,7 +46,7 @@
 
 /* FUNCTIONS ****************************************************************/
 BOOL
-GetRosInstallCD(WCHAR * szPath, DWORD dwPathLength);
+GetRosInstallCD(WCHAR *pwszPath, DWORD cchPathMax);
 
 #ifdef VMWINST
 static BOOL
@@ -883,7 +883,6 @@
                   LPARAM lParam)
 {
     PSETUPDATA SetupData;
-    WCHAR szBuffer[1024];
 
     /* Retrieve pointer to the global setup data */
     SetupData = (PSETUPDATA)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
@@ -907,19 +906,13 @@
                 switch (LOWORD(wParam))
                 {
                     case IDC_CUSTOMLOCALE:
-                    {
-                        wcscpy(szBuffer, L"rundll32.exe 
shell32.dll,Control_RunDLL intl.cpl,,5");
-                        RunControlPanelApplet(hwndDlg, szBuffer);
+                        RunControlPanelApplet(hwndDlg, L"rundll32.exe 
shell32.dll,Control_RunDLL intl.cpl,,5");
                         /* FIXME: Update input locale name */
-                    }
-                    break;
+                        break;
 
                     case IDC_CUSTOMLAYOUT:
-                    {
-                        wcscpy(szBuffer, L"rundll32.exe 
shell32.dll,Control_RunDLL input.dll,@1");
-                        RunControlPanelApplet(hwndDlg, szBuffer);
-                    }
-                    break;
+                        RunControlPanelApplet(hwndDlg, L"rundll32.exe 
shell32.dll,Control_RunDLL input.dll,@1");
+                        break;
                 }
             }
             break;
@@ -935,17 +928,13 @@
                     PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | 
PSWIZB_NEXT);
                     if (SetupData->UnattendSetup)
                     {
-                        WCHAR szPath[MAX_PATH];
-                        if (GetRosInstallCD(szPath, MAX_PATH))
-                        {
-                            swprintf(szBuffer, L"rundll32.exe 
shell32.dll,Control_RunDLL intl.cpl,,/f:\"%S\\reactos\\unattend.inf\"", szPath);
-                        }
+                        WCHAR wszPath[MAX_PATH], wszBuf[1024];
+                        if (GetRosInstallCD(wszPath, _countof(wszPath)))
+                            swprintf(wszBuf, L"rundll32.exe 
shell32.dll,Control_RunDLL intl.cpl,,/f:\"%sreactos\\unattend.inf\"", wszPath);
                         else
-                        {
-                            wcscpy(szBuffer, L"rundll32.exe 
shell32.dll,Control_RunDLL intl.cpl,,/f:\"unattend.inf\"");
-                        }
-
-                        RunControlPanelApplet(hwndDlg, szBuffer);
+                            wcscpy(wszBuf, L"rundll32.exe 
shell32.dll,Control_RunDLL intl.cpl,,/f:\"unattend.inf\"");
+
+                        RunControlPanelApplet(hwndDlg, wszBuf);
                         SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, 
IDD_DATETIMEPAGE);
                         return TRUE;
                     }
@@ -2238,35 +2227,32 @@
  */
 
 BOOL
-GetRosInstallCD(WCHAR * szPath, DWORD dwPathLength)
-{
-    WCHAR szDrives[512];
-    WCHAR szDrive[] = L"D:\\";
-    DWORD dwLength, dwIndex;
-    WCHAR * pDrive;
-    dwLength = GetLogicalDriveStringsW(sizeof(szDrives) / sizeof(WCHAR), 
szDrives);
-
-    if (dwLength > (sizeof(szDrives) / sizeof(WCHAR)) || dwLength == 0)
+GetRosInstallCD(WCHAR *pwszPath, DWORD cchPathMax)
+{
+    WCHAR wszDrives[512];
+    DWORD cchDrives;
+    WCHAR *pwszDrive;
+
+    cchDrives = GetLogicalDriveStringsW(_countof(wszDrives) - 1, wszDrives);
+    if (cchDrives == 0 || cchDrives >= _countof(wszDrives))
     {
         /* buffer too small or failure */
         LogItem(SYSSETUP_SEVERITY_INFORMATION, L"GetLogicalDriveStringsW 
failed");
         return FALSE;
     }
 
-    pDrive = szDrives;
-    for (dwIndex = 0; dwIndex < dwLength; dwIndex++)
-    {
-        szDrive[0] = pDrive[dwIndex];
-        if (GetDriveTypeW(szDrive) == DRIVE_CDROM)
-        {
-            WCHAR szBuffer[MAX_PATH];
-            wcscpy(szBuffer, szDrive);
-            wcscat(szBuffer, L"reactos\\system32\\ntoskrnl.exe");
-            LogItem(SYSSETUP_SEVERITY_INFORMATION, szBuffer);
-            if (GetFileAttributesW(szBuffer) != INVALID_FILE_ATTRIBUTES)
+    for (pwszDrive = wszDrives; pwszDrive[0]; pwszDrive += wcslen(pwszDrive) + 
1)
+    {
+        if (GetDriveTypeW(pwszDrive) == DRIVE_CDROM)
+        {
+            WCHAR wszBuf[MAX_PATH];
+            wsprintf(wszBuf, L"%sreactos\\system32\\ntoskrnl.exe", pwszDrive);
+            LogItem(SYSSETUP_SEVERITY_INFORMATION, wszBuf);
+            if (GetFileAttributesW(wszBuf) != INVALID_FILE_ATTRIBUTES)
             {
                 /* the file exists, so this is the right drive */
-                wcsncpy(szPath, szDrive, dwPathLength);
+                wcsncpy(pwszPath, pwszDrive, cchPathMax);
+                OutputDebugStringW(L"GetRosInstallCD: 
");OutputDebugStringW(pwszPath);OutputDebugStringW(L"\n");
                 return TRUE;
             }
         }


Reply via email to