[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.

svn path=/trunk/; revision=54971
This commit is contained in:
Rafal Harabien 2012-01-15 13:24:26 +00:00
parent e94b30cdf1
commit cb74343620

View file

@ -46,7 +46,7 @@ SETUPDATA SetupData;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
BOOL BOOL
GetRosInstallCD(WCHAR * szPath, DWORD dwPathLength); GetRosInstallCD(WCHAR *pwszPath, DWORD cchPathMax);
#ifdef VMWINST #ifdef VMWINST
static BOOL static BOOL
@ -883,7 +883,6 @@ LocalePageDlgProc(HWND hwndDlg,
LPARAM lParam) LPARAM lParam)
{ {
PSETUPDATA SetupData; PSETUPDATA SetupData;
WCHAR szBuffer[1024];
/* Retrieve pointer to the global setup data */ /* Retrieve pointer to the global setup data */
SetupData = (PSETUPDATA)GetWindowLongPtr (hwndDlg, GWL_USERDATA); SetupData = (PSETUPDATA)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
@ -907,18 +906,12 @@ LocalePageDlgProc(HWND hwndDlg,
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDC_CUSTOMLOCALE: case IDC_CUSTOMLOCALE:
{ RunControlPanelApplet(hwndDlg, L"rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,5");
wcscpy(szBuffer, L"rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,5");
RunControlPanelApplet(hwndDlg, szBuffer);
/* FIXME: Update input locale name */ /* FIXME: Update input locale name */
}
break; break;
case IDC_CUSTOMLAYOUT: case IDC_CUSTOMLAYOUT:
{ RunControlPanelApplet(hwndDlg, L"rundll32.exe shell32.dll,Control_RunDLL input.dll,@1");
wcscpy(szBuffer, L"rundll32.exe shell32.dll,Control_RunDLL input.dll,@1");
RunControlPanelApplet(hwndDlg, szBuffer);
}
break; break;
} }
} }
@ -935,17 +928,13 @@ LocalePageDlgProc(HWND hwndDlg,
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT); PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
if (SetupData->UnattendSetup) if (SetupData->UnattendSetup)
{ {
WCHAR szPath[MAX_PATH]; WCHAR wszPath[MAX_PATH], wszBuf[1024];
if (GetRosInstallCD(szPath, MAX_PATH)) if (GetRosInstallCD(wszPath, _countof(wszPath)))
{ swprintf(wszBuf, L"rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,/f:\"%sreactos\\unattend.inf\"", wszPath);
swprintf(szBuffer, L"rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,/f:\"%S\\reactos\\unattend.inf\"", szPath);
}
else else
{ wcscpy(wszBuf, L"rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,/f:\"unattend.inf\"");
wcscpy(szBuffer, L"rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,/f:\"unattend.inf\"");
}
RunControlPanelApplet(hwndDlg, szBuffer); RunControlPanelApplet(hwndDlg, wszBuf);
SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_DATETIMEPAGE); SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_DATETIMEPAGE);
return TRUE; return TRUE;
} }
@ -2238,35 +2227,32 @@ ProcessUnattendInf(HINF hUnattendedInf)
*/ */
BOOL BOOL
GetRosInstallCD(WCHAR * szPath, DWORD dwPathLength) GetRosInstallCD(WCHAR *pwszPath, DWORD cchPathMax)
{ {
WCHAR szDrives[512]; WCHAR wszDrives[512];
WCHAR szDrive[] = L"D:\\"; DWORD cchDrives;
DWORD dwLength, dwIndex; WCHAR *pwszDrive;
WCHAR * pDrive;
dwLength = GetLogicalDriveStringsW(sizeof(szDrives) / sizeof(WCHAR), szDrives);
if (dwLength > (sizeof(szDrives) / sizeof(WCHAR)) || dwLength == 0) cchDrives = GetLogicalDriveStringsW(_countof(wszDrives) - 1, wszDrives);
if (cchDrives == 0 || cchDrives >= _countof(wszDrives))
{ {
/* buffer too small or failure */ /* buffer too small or failure */
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"GetLogicalDriveStringsW failed"); LogItem(SYSSETUP_SEVERITY_INFORMATION, L"GetLogicalDriveStringsW failed");
return FALSE; return FALSE;
} }
pDrive = szDrives; for (pwszDrive = wszDrives; pwszDrive[0]; pwszDrive += wcslen(pwszDrive) + 1)
for (dwIndex = 0; dwIndex < dwLength; dwIndex++)
{ {
szDrive[0] = pDrive[dwIndex]; if (GetDriveTypeW(pwszDrive) == DRIVE_CDROM)
if (GetDriveTypeW(szDrive) == DRIVE_CDROM)
{ {
WCHAR szBuffer[MAX_PATH]; WCHAR wszBuf[MAX_PATH];
wcscpy(szBuffer, szDrive); wsprintf(wszBuf, L"%sreactos\\system32\\ntoskrnl.exe", pwszDrive);
wcscat(szBuffer, L"reactos\\system32\\ntoskrnl.exe"); LogItem(SYSSETUP_SEVERITY_INFORMATION, wszBuf);
LogItem(SYSSETUP_SEVERITY_INFORMATION, szBuffer); if (GetFileAttributesW(wszBuf) != INVALID_FILE_ATTRIBUTES)
if (GetFileAttributesW(szBuffer) != INVALID_FILE_ATTRIBUTES)
{ {
/* the file exists, so this is the right drive */ /* 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; return TRUE;
} }
} }