* PURPOSE: GUI controls
* PROGRAMMERS: Eric Kohl
* Pierre Schweitzer <heis_spiter@hotmail.com>
+ * Ismael Ferreras Morezuelas <swyterzone+ros@gmail.com>
*/
/* INCLUDES *****************************************************************/
#include <time.h>
#include <winnls.h>
#include <windowsx.h>
+#include <wincon.h>
+#include <shlobj.h>
#define NDEBUG
#include <debug.h>
-#define VMWINST
-
#define PM_REGISTRATION_NOTIFY (WM_APP + 1)
/* Private Message used to communicate progress from the background
registration thread to the main thread.
PVOID DefaultContext;
} REGISTRATIONDATA, *PREGISTRATIONDATA;
-/* GLOBALS ******************************************************************/
-
-SETUPDATA SetupData;
-
/* FUNCTIONS ****************************************************************/
extern void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow);
-BOOL
-GetRosInstallCD(WCHAR *pwszPath, DWORD cchPathMax);
-
-#ifdef VMWINST
-static BOOL
-RunVMWInstall(HWND hWnd)
-{
- PROCESS_INFORMATION ProcInfo;
- MSG msg;
- DWORD ret;
- STARTUPINFOW si;
- WCHAR InstallName[] = L"vmwinst.exe";
-
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
-
- if(CreateProcessW(NULL, InstallName, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS,
- NULL, NULL, &si, &ProcInfo))
- {
- EnableWindow(hWnd, FALSE);
- for (;;)
- {
- while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
- {
- if (msg.message == WM_QUIT)
- goto done;
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- ret = MsgWaitForMultipleObjects(1, &ProcInfo.hProcess, FALSE, INFINITE, QS_ALLEVENTS | QS_ALLINPUT);
- if (ret == WAIT_OBJECT_0)
- break;
- }
-done:
- EnableWindow(hWnd, TRUE);
-
- CloseHandle(ProcInfo.hThread);
- CloseHandle(ProcInfo.hProcess);
- return TRUE;
- }
- return FALSE;
-}
-#endif
static VOID
CenterWindow(HWND hWnd)
static HFONT
CreateTitleFont(VOID)
{
- NONCLIENTMETRICSW ncm;
- LOGFONTW LogFont;
+ LOGFONTW LogFont = {0};
HDC hdc;
- INT FontSize;
HFONT hFont;
- ncm.cbSize = sizeof(NONCLIENTMETRICSW);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
-
- LogFont = ncm.lfMessageFont;
- LogFont.lfWeight = FW_BOLD;
+ LogFont.lfWeight = FW_HEAVY;
wcscpy(LogFont.lfFaceName, L"MS Shell Dlg");
hdc = GetDC(NULL);
- FontSize = 12;
- LogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * FontSize / 72;
+ LogFont.lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72);
+
hFont = CreateFontIndirectW(&LogFont);
+
ReleaseDC(NULL, hdc);
return hFont;
}
+static HFONT
+CreateBoldFont(VOID)
+{
+ LOGFONTW tmpFont = {0};
+ HFONT hBoldFont;
+ HDC hDc;
+
+ /* Grabs the Drawing Context */
+ hDc = GetDC(NULL);
+
+ tmpFont.lfHeight = -MulDiv(8, GetDeviceCaps(hDc, LOGPIXELSY), 72);
+ tmpFont.lfWeight = FW_HEAVY;
+ wcscpy(tmpFont.lfFaceName, L"MS Shell Dlg");
+
+ hBoldFont = CreateFontIndirectW(&tmpFont);
+
+ ReleaseDC(NULL, hDc);
+
+ return hBoldFont;
+}
+
static INT_PTR CALLBACK
GplDlgProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
+ PSETUPDATA pSetupData;
+
+ pSetupData = (PSETUPDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
switch (uMsg)
{
case WM_INITDIALOG:
{
- PSETUPDATA SetupData;
HWND hwndControl;
DWORD dwStyle;
/* Get pointer to the global setup data */
- SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
+ pSetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pSetupData);
hwndControl = GetParent(hwndDlg);
SendDlgItemMessage(hwndDlg,
IDC_WELCOMETITLE,
WM_SETFONT,
- (WPARAM)SetupData->hTitleFont,
+ (WPARAM)pSetupData->hTitleFont,
(LPARAM)TRUE);
}
break;
switch (lpnm->code)
{
case PSN_SETACTIVE:
+ LogItem(L"BEGIN", L"WelcomePage");
/* Enable the Next button */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
- if (SetupData.UnattendSetup)
+ if (pSetupData->UnattendSetup)
{
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_ACKPAGE);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_ACKPAGE);
return TRUE;
}
break;
+ case PSN_WIZNEXT:
+ LogItem(L"END", L"WelcomePage");
+ break;
+
case PSN_WIZBACK:
- SetupData.UnattendSetup = FALSE;
+ pSetupData->UnattendSetup = FALSE;
break;
default:
PWCHAR Projects;
PWCHAR End, CurrentProject;
INT ProjectsSize, ProjectsCount;
+ PSETUPDATA pSetupData;
+
+ pSetupData = (PSETUPDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
switch (uMsg)
{
case WM_INITDIALOG:
{
+ pSetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pSetupData);
+
Projects = NULL;
ProjectsSize = 256;
- do
+ while (TRUE)
{
Projects = HeapAlloc(GetProcessHeap(), 0, ProjectsSize * sizeof(WCHAR));
if (NULL == Projects)
HeapFree(GetProcessHeap(), 0, Projects);
ProjectsSize *= 2;
}
- while (1);
+
CurrentProject = Projects;
- while (L'\0' != *CurrentProject)
+ while (*CurrentProject != L'\0')
{
End = wcschr(CurrentProject, L'\n');
if (NULL != End)
case PSN_SETACTIVE:
/* Enable the Back and Next buttons */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- if (SetupData.UnattendSetup)
+ if (pSetupData->UnattendSetup)
{
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_LOCALEPAGE);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_LOCALEPAGE);
return TRUE;
}
break;
case PSN_WIZBACK:
- SetupData.UnattendSetup = FALSE;
+ pSetupData->UnattendSetup = FALSE;
break;
default:
HKEY hKey;
LONG res;
-
-
res = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"Software\\Microsoft\\Windows NT\\CurrentVersion",
0,
WCHAR Title[64];
WCHAR ErrorName[256];
LPNMHDR lpnm;
+ PSETUPDATA pSetupData;
+
+ pSetupData = (PSETUPDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
switch (uMsg)
{
case WM_INITDIALOG:
{
+ pSetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pSetupData);
+
+ /* set a localized ('Owner') placeholder string as default */
+ if (LoadStringW(hDllInstance, IDS_MACHINE_OWNER_NAME, OwnerName, _countof(OwnerName)))
+ {
+ SendDlgItemMessage(hwndDlg, IDC_OWNERNAME, WM_SETTEXT, 0, (LPARAM)OwnerName);
+ }
+
SendDlgItemMessage(hwndDlg, IDC_OWNERNAME, EM_LIMITTEXT, 50, 0);
SendDlgItemMessage(hwndDlg, IDC_OWNERORGANIZATION, EM_LIMITTEXT, 50, 0);
/* Set focus to owner name */
SetFocus(GetDlgItem(hwndDlg, IDC_OWNERNAME));
+
+ /* Select the default text to quickly overwrite it by typing */
+ SendDlgItemMessage(hwndDlg, IDC_OWNERNAME, EM_SETSEL, 0, -1);
}
break;
case PSN_SETACTIVE:
/* Enable the Back and Next buttons */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- if (SetupData.UnattendSetup)
+ if (pSetupData->UnattendSetup)
{
- SendMessage(GetDlgItem(hwndDlg, IDC_OWNERNAME), WM_SETTEXT, 0, (LPARAM)SetupData.OwnerName);
- SendMessage(GetDlgItem(hwndDlg, IDC_OWNERORGANIZATION), WM_SETTEXT, 0, (LPARAM)SetupData.OwnerOrganization);
- if (WriteOwnerSettings(SetupData.OwnerName, SetupData.OwnerOrganization))
+ SendMessage(GetDlgItem(hwndDlg, IDC_OWNERNAME), WM_SETTEXT, 0, (LPARAM)pSetupData->OwnerName);
+ SendMessage(GetDlgItem(hwndDlg, IDC_OWNERORGANIZATION), WM_SETTEXT, 0, (LPARAM)pSetupData->OwnerOrganization);
+ if (WriteOwnerSettings(pSetupData->OwnerName, pSetupData->OwnerOrganization))
{
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_COMPUTERPAGE);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_COMPUTERPAGE);
return TRUE;
}
}
OwnerName[0] = 0;
if (GetDlgItemTextW(hwndDlg, IDC_OWNERNAME, OwnerName, 50) == 0)
{
- if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, sizeof(Title) / sizeof(Title[0])))
+ if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, ARRAYSIZE(Title)))
{
wcscpy(Title, L"ReactOS Setup");
}
- if (0 == LoadStringW(hDllInstance, IDS_WZD_NAME, ErrorName, sizeof(ErrorName) / sizeof(ErrorName[0])))
+ if (0 == LoadStringW(hDllInstance, IDS_WZD_NAME, ErrorName, ARRAYSIZE(ErrorName)))
{
wcscpy(ErrorName, L"Setup cannot continue until you enter your name.");
}
MessageBoxW(hwndDlg, ErrorName, Title, MB_ICONERROR | MB_OK);
SetFocus(GetDlgItem(hwndDlg, IDC_OWNERNAME));
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, -1);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
return TRUE;
}
if (!WriteOwnerSettings(OwnerName, OwnerOrganization))
{
SetFocus(GetDlgItem(hwndDlg, IDC_OWNERNAME));
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, -1);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
return TRUE;
}
case PSN_WIZBACK:
- SetupData.UnattendSetup = FALSE;
+ pSetupData->UnattendSetup = FALSE;
break;
default:
{
if (hwndDlg != NULL)
{
- if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, sizeof(Title) / sizeof(Title[0])))
+ if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, ARRAYSIZE(Title)))
{
wcscpy(Title, L"ReactOS Setup");
}
if (0 == LoadStringW(hDllInstance, IDS_WZD_SETCOMPUTERNAME, ErrorComputerName,
- sizeof(ErrorComputerName) / sizeof(ErrorComputerName[0])))
+ ARRAYSIZE(ErrorComputerName)))
{
wcscpy(ErrorComputerName, L"Setup failed to set the computer name.");
}
/* Try to also set DNS hostname */
SetComputerNameExW(ComputerNamePhysicalDnsHostname, ComputerName);
- /* Set the account domain name */
- SetAccountDomain(ComputerName, NULL);
+ /* Set the accounts domain name */
+ SetAccountsDomainSid(NULL, ComputerName);
return TRUE;
}
if (LoadStringW(hDllInstance,
IDS_ADMINISTRATOR_NAME,
szAdministratorName,
- sizeof(szAdministratorName) / sizeof(WCHAR)) == 0)
+ ARRAYSIZE(szAdministratorName)) == 0)
{
wcscpy(szAdministratorName, L"Administrator");
}
return FALSE;
lError = RegSetValueEx(hKey,
- L"DefaultDomain",
+ L"DefaultDomainName",
0,
REG_SZ,
(LPBYTE)Domain,
(wcslen(Domain)+ 1) * sizeof(WCHAR));
if (lError != ERROR_SUCCESS)
{
- DPRINT1("RegSetValueEx(\"DefaultDomain\") failed!\n");
+ DPRINT1("RegSetValueEx(\"DefaultDomainName\") failed!\n");
}
lError = RegSetValueEx(hKey,
WCHAR Title[64];
WCHAR EmptyComputerName[256], NotMatchPassword[256], WrongPassword[256];
LPNMHDR lpnm;
+ PSETUPDATA pSetupData;
+
+ pSetupData = (PSETUPDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
- if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, sizeof(Title) / sizeof(Title[0])))
+ if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, ARRAYSIZE(Title)))
{
wcscpy(Title, L"ReactOS Setup");
}
switch (uMsg)
{
case WM_INITDIALOG:
+ pSetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pSetupData);
+
/* Generate a new pseudo-random computer name */
GenerateComputerName(ComputerName);
/* Set focus to computer name */
SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
- if (SetupData.UnattendSetup)
+ if (pSetupData->UnattendSetup)
{
- SendMessage(GetDlgItem(hwndDlg, IDC_COMPUTERNAME), WM_SETTEXT, 0, (LPARAM)SetupData.ComputerName);
- SendMessage(GetDlgItem(hwndDlg, IDC_ADMINPASSWORD1), WM_SETTEXT, 0, (LPARAM)SetupData.AdminPassword);
- SendMessage(GetDlgItem(hwndDlg, IDC_ADMINPASSWORD2), WM_SETTEXT, 0, (LPARAM)SetupData.AdminPassword);
- WriteComputerSettings(SetupData.ComputerName, NULL);
- SetAdministratorPassword(SetupData.AdminPassword);
+ SendMessage(GetDlgItem(hwndDlg, IDC_COMPUTERNAME), WM_SETTEXT, 0, (LPARAM)pSetupData->ComputerName);
+ SendMessage(GetDlgItem(hwndDlg, IDC_ADMINPASSWORD1), WM_SETTEXT, 0, (LPARAM)pSetupData->AdminPassword);
+ SendMessage(GetDlgItem(hwndDlg, IDC_ADMINPASSWORD2), WM_SETTEXT, 0, (LPARAM)pSetupData->AdminPassword);
+ WriteComputerSettings(pSetupData->ComputerName, NULL);
+ SetAdministratorPassword(pSetupData->AdminPassword);
}
/* Store the administrator account name as the default user name */
- WriteDefaultLogonData(SetupData.ComputerName);
+ WriteDefaultLogonData(pSetupData->ComputerName);
break;
case PSN_SETACTIVE:
/* Enable the Back and Next buttons */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
- if (SetupData.UnattendSetup && WriteComputerSettings(SetupData.ComputerName, hwndDlg))
+ if (pSetupData->UnattendSetup && WriteComputerSettings(pSetupData->ComputerName, hwndDlg))
{
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_DATETIMEPAGE);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_THEMEPAGE);
return TRUE;
}
break;
if (0 == GetDlgItemTextW(hwndDlg, IDC_COMPUTERNAME, ComputerName, MAX_COMPUTERNAME_LENGTH + 1))
{
if (0 == LoadStringW(hDllInstance, IDS_WZD_COMPUTERNAME, EmptyComputerName,
- sizeof(EmptyComputerName) / sizeof(EmptyComputerName[0])))
+ ARRAYSIZE(EmptyComputerName)))
{
wcscpy(EmptyComputerName, L"Setup cannot continue until you enter the name of your computer.");
}
MessageBoxW(hwndDlg, EmptyComputerName, Title, MB_ICONERROR | MB_OK);
SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, -1);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
return TRUE;
}
if (!WriteComputerSettings(ComputerName, hwndDlg))
{
SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, -1);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
return TRUE;
}
(GetDlgItemText(hwndDlg, IDC_ADMINPASSWORD2, Password2, 128) == 0))
{
if (0 == LoadStringW(hDllInstance, IDS_WZD_PASSWORDEMPTY, EmptyPassword,
- sizeof(EmptyPassword) / sizeof(EmptyPassword[0])))
+ ARRAYSIZE(EmptyPassword)))
{
wcscpy(EmptyPassword, L"You must enter a password !");
}
MessageBoxW(hwndDlg, EmptyPassword, Title, MB_ICONERROR | MB_OK);
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, -1);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
return TRUE;
}
#else
if (wcscmp(Password1, Password2))
{
if (0 == LoadStringW(hDllInstance, IDS_WZD_PASSWORDMATCH, NotMatchPassword,
- sizeof(NotMatchPassword) / sizeof(NotMatchPassword[0])))
+ ARRAYSIZE(NotMatchPassword)))
{
wcscpy(NotMatchPassword, L"The passwords you entered do not match. Please enter the desired password again.");
}
MessageBoxW(hwndDlg, NotMatchPassword, Title, MB_ICONERROR | MB_OK);
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, -1);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
return TRUE;
}
if (!isprint(*Password))
{
if (0 == LoadStringW(hDllInstance, IDS_WZD_PASSWORDCHAR, WrongPassword,
- sizeof(WrongPassword) / sizeof(WrongPassword[0])))
+ ARRAYSIZE(WrongPassword)))
{
wcscpy(WrongPassword, L"The password you entered contains invalid characters. Please enter a cleaned password.");
}
MessageBoxW(hwndDlg, WrongPassword, Title, MB_ICONERROR | MB_OK);
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, -1);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
return TRUE;
}
Password++;
break;
case PSN_WIZBACK:
- SetupData.UnattendSetup = FALSE;
+ pSetupData->UnattendSetup = FALSE;
break;
default:
static BOOL
RunControlPanelApplet(HWND hwnd, PCWSTR pwszCPLParameters)
{
- if (pwszCPLParameters)
- {
- STARTUPINFOW StartupInfo;
- PROCESS_INFORMATION ProcessInformation;
- WCHAR CmdLine[MAX_PATH] = L"rundll32.exe shell32.dll,Control_RunDLL ";
+ MSG msg;
+ STARTUPINFOW StartupInfo;
+ PROCESS_INFORMATION ProcessInformation;
+ WCHAR CmdLine[MAX_PATH] = L"rundll32.exe shell32.dll,Control_RunDLL ";
- ZeroMemory(&StartupInfo, sizeof(StartupInfo));
- StartupInfo.cb = sizeof(StartupInfo);
+ if (!pwszCPLParameters)
+ {
+ MessageBoxW(hwnd, L"Error: Failed to launch the Control Panel Applet.", NULL, MB_ICONERROR);
+ return FALSE;
+ }
- ASSERT(_countof(CmdLine) > wcslen(CmdLine) + wcslen(pwszCPLParameters));
- wcscat(CmdLine, pwszCPLParameters);
+ ZeroMemory(&StartupInfo, sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(StartupInfo);
+ ZeroMemory(&ProcessInformation, sizeof(ProcessInformation));
- if (!CreateProcessW(NULL,
- CmdLine,
- NULL,
- NULL,
- FALSE,
- 0,
- NULL,
- NULL,
- &StartupInfo,
- &ProcessInformation))
- {
- MessageBoxW(hwnd, L"Error: Failed to launch the Control Panel Applet.", NULL, MB_ICONERROR);
- return FALSE;
- }
+ ASSERT(_countof(CmdLine) > wcslen(CmdLine) + wcslen(pwszCPLParameters));
+ wcscat(CmdLine, pwszCPLParameters);
- WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
- CloseHandle(ProcessInformation.hThread);
- CloseHandle(ProcessInformation.hProcess);
- return TRUE;
- }
- else
+ if (!CreateProcessW(NULL,
+ CmdLine,
+ NULL,
+ NULL,
+ FALSE,
+ 0,
+ NULL,
+ NULL,
+ &StartupInfo,
+ &ProcessInformation))
{
MessageBoxW(hwnd, L"Error: Failed to launch the Control Panel Applet.", NULL, MB_ICONERROR);
return FALSE;
}
+
+ while ((MsgWaitForMultipleObjects(1, &ProcessInformation.hProcess, FALSE, INFINITE, QS_ALLINPUT|QS_ALLPOSTMESSAGE )) != WAIT_OBJECT_0)
+ {
+ while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+ }
+ CloseHandle(ProcessInformation.hThread);
+ CloseHandle(ProcessInformation.hProcess);
+ return TRUE;
}
static VOID
lcid = GetSystemDefaultLCID();
- if (GetLocaleInfoW(MAKELCID(lcid, SORT_DEFAULT), LOCALE_ILANGUAGE, Locale, sizeof(Locale) / sizeof(Locale[0])) != 0)
+ if (GetLocaleInfoW(MAKELCID(lcid, SORT_DEFAULT), LOCALE_ILANGUAGE, Locale, ARRAYSIZE(Locale)) != 0)
{
if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Control Panel\\International",
0, NULL, REG_OPTION_NON_VOLATILE,
PSETUPDATA SetupData;
/* Retrieve pointer to the global setup data */
- SetupData = (PSETUPDATA)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
+ SetupData = (PSETUPDATA)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg)
{
{
/* Save pointer to the global setup data */
SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
- SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)SetupData);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (DWORD_PTR)SetupData);
WriteUserLocale();
SetKeyboardLayoutName(GetDlgItem(hwndDlg, IDC_LAYOUTTEXT));
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
if (SetupData->UnattendSetup)
{
- WCHAR wszPath[MAX_PATH];
- if (GetRosInstallCD(wszPath, _countof(wszPath)))
+ // if (!*SetupData->SourcePath)
{
- WCHAR wszParams[1024];
- swprintf(wszParams, L"intl.cpl,,/f:\"%sreactos\\unattend.inf\"", wszPath);
- RunControlPanelApplet(hwndDlg, wszParams);
- }
- else
- {
- RunControlPanelApplet(hwndDlg, L"intl.cpl,,/f:\"unattend.inf\"");
+ RunControlPanelApplet(hwndDlg, L"intl.cpl,,/f:\"$winnt$.inf\""); // Should be in System32
}
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_OWNERPAGE);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, IDD_OWNERPAGE);
return TRUE;
}
break;
BOOL bFound = FALSE;
unsigned long iLanguageID;
- if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
- 0,
- KEY_ALL_ACCESS,
- &hKey))
- return FALSE;
-
- dwValueSize = 9 * sizeof(WCHAR);
- if (RegQueryValueExW(hKey,
- L"Default",
- NULL,
- NULL,
- (LPBYTE)szLanguageIdString,
- &dwValueSize))
+ if (*lpIndex == -1)
{
+ *lpIndex = 85; /* fallback to GMT time zone */
+
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
+ 0,
+ KEY_ALL_ACCESS,
+ &hKey))
+ return FALSE;
+
+ dwValueSize = 9 * sizeof(WCHAR);
+ if (RegQueryValueExW(hKey,
+ L"Default",
+ NULL,
+ NULL,
+ (LPBYTE)szLanguageIdString,
+ &dwValueSize))
+ {
+ RegCloseKey(hKey);
+ return FALSE;
+ }
+
+ iLanguageID = wcstoul(szLanguageIdString, NULL, 16);
RegCloseKey(hKey);
- return FALSE;
}
-
- iLanguageID = wcstoul(szLanguageIdString, NULL, 16);
- RegCloseKey(hKey);
+ else
+ {
+ iLanguageID = *lpIndex;
+ }
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
return Ret;
}
+
+static VOID
+UpdateLocalSystemTime(HWND hwnd)
+{
+ SYSTEMTIME LocalTime;
+
+ GetLocalTime(&LocalTime);
+ DateTime_SetSystemtime(GetDlgItem(hwnd, IDC_DATEPICKER), GDT_VALID, &LocalTime);
+ DateTime_SetSystemtime(GetDlgItem(hwnd, IDC_TIMEPICKER), GDT_VALID, &LocalTime);
+}
+
+
static BOOL
WriteDateTimeSettings(HWND hwndDlg, PSETUPDATA SetupData)
{
WCHAR Title[64];
WCHAR ErrorLocalTime[256];
+
GetLocalSystemTime(hwndDlg, SetupData);
SetLocalTimeZone(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
SetupData);
SetAutoDaylightInfo(GetDlgItem(hwndDlg, IDC_AUTODAYLIGHT));
- if(!SetSystemLocalTime(hwndDlg, SetupData))
+ if (!SetSystemLocalTime(hwndDlg, SetupData))
{
- if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, sizeof(Title) / sizeof(Title[0])))
+ if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, ARRAYSIZE(Title)))
{
wcscpy(Title, L"ReactOS Setup");
}
if (0 == LoadStringW(hDllInstance, IDS_WZD_LOCALTIME, ErrorLocalTime,
- sizeof(ErrorLocalTime) / sizeof(ErrorLocalTime[0])))
+ ARRAYSIZE(ErrorLocalTime)))
{
wcscpy(ErrorLocalTime, L"Setup was unable to set the local time.");
}
return TRUE;
}
+
static INT_PTR CALLBACK
DateTimePageDlgProc(HWND hwndDlg,
UINT uMsg,
PSETUPDATA SetupData;
/* Retrieve pointer to the global setup data */
- SetupData = (PSETUPDATA)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
+ SetupData = (PSETUPDATA)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg)
{
case WM_INITDIALOG:
- {
/* Save pointer to the global setup data */
SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
- SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)SetupData);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (DWORD_PTR)SetupData);
CreateTimeZoneList(SetupData);
else
{
ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
- SetupData, 85 /* GMT time zone */);
+ SetupData, -1);
SendDlgItemMessage(hwndDlg, IDC_AUTODAYLIGHT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
}
+ break;
- }
- break;
-
+ case WM_TIMER:
+ UpdateLocalSystemTime(hwndDlg);
+ break;
case WM_NOTIFY:
- {
- LPNMHDR lpnm = (LPNMHDR)lParam;
-
- switch (lpnm->code)
+ switch (((LPNMHDR)lParam)->code)
{
case PSN_SETACTIVE:
/* Enable the Back and Next buttons */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
if (SetupData->UnattendSetup && WriteDateTimeSettings(hwndDlg, SetupData))
{
- SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, IDD_PROCESSPAGE);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, SetupData->uFirstNetworkWizardPage);
return TRUE;
}
+ SetTimer(hwndDlg, 1, 1000, NULL);
+ break;
+
+ case PSN_KILLACTIVE:
+ case DTN_DATETIMECHANGE:
+ KillTimer(hwndDlg, 1);
break;
case PSN_WIZNEXT:
- {
WriteDateTimeSettings(hwndDlg, SetupData);
- }
- break;
+ break;
case PSN_WIZBACK:
SetupData->UnattendSetup = FALSE;
default:
break;
}
- }
- break;
+ break;
case WM_DESTROY:
DestroyTimeZoneList(SetupData);
return FALSE;
}
+static struct ThemeInfo
+{
+ LPCWSTR PreviewBitmap;
+ UINT DisplayName;
+ LPCWSTR ThemeFile;
+
+} Themes[] = {
+ { MAKEINTRESOURCE(IDB_CLASSIC), IDS_CLASSIC, NULL },
+ { MAKEINTRESOURCE(IDB_LAUTUS), IDS_LAUTUS, L"themes\\lautus\\lautus.msstyles" },
+ { MAKEINTRESOURCE(IDB_LUNAR), IDS_LUNAR, L"themes\\lunar\\lunar.msstyles" },
+};
+
+static INT_PTR CALLBACK
+ThemePageDlgProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ PSETUPDATA SetupData;
+ LPNMLISTVIEW pnmv;
+
+ /* Retrieve pointer to the global setup data */
+ SetupData = (PSETUPDATA)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ HWND hListView;
+ HIMAGELIST himl;
+ DWORD n;
+ LVITEM lvi = {0};
+
+ /* Save pointer to the global setup data */
+ SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (DWORD_PTR)SetupData);
+
+ hListView = GetDlgItem(hwndDlg, IDC_THEMEPICKER);
+
+ /* Common */
+ himl = ImageList_Create(180, 163, ILC_COLOR32 | ILC_MASK, ARRAYSIZE(Themes), 1);
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE |LVIF_STATE;
+
+ for (n = 0; n < ARRAYSIZE(Themes); ++n)
+ {
+ WCHAR DisplayName[100] = {0};
+ /* Load the bitmap */
+ HANDLE image = LoadImageW(hDllInstance, Themes[n].PreviewBitmap, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ ImageList_AddMasked(himl, image, RGB(255,0,255));
+
+ /* Load the string */
+ LoadStringW(hDllInstance, Themes[n].DisplayName, DisplayName, ARRAYSIZE(DisplayName));
+ DisplayName[ARRAYSIZE(DisplayName)-1] = UNICODE_NULL;
+
+ /* Add the listview item */
+ lvi.iItem = n;
+ lvi.iImage = n;
+ lvi.pszText = DisplayName;
+ ListView_InsertItem(hListView, &lvi);
+ }
+
+ /* Register the imagelist */
+ ListView_SetImageList(hListView, himl, LVSIL_NORMAL);
+ /* Transparant background */
+ ListView_SetBkColor(hListView, CLR_NONE);
+ ListView_SetTextBkColor(hListView, CLR_NONE);
+ /* Reduce the size between the items */
+ ListView_SetIconSpacing(hListView, 190, 173);
+ break;
+ }
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ //case LVN_ITEMCHANGING:
+ case LVN_ITEMCHANGED:
+ pnmv = (LPNMLISTVIEW)lParam;
+ if ((pnmv->uChanged & LVIF_STATE) && (pnmv->uNewState & LVIS_SELECTED))
+ {
+ int iTheme = pnmv->iItem;
+ DPRINT1("Selected theme: %S\n", Themes[iTheme].DisplayName);
+
+ if (Themes[iTheme].ThemeFile)
+ {
+ WCHAR wszParams[1024];
+ WCHAR wszTheme[MAX_PATH];
+ WCHAR* format = L"desk.cpl desk,@Appearance /Action:ActivateMSTheme /file:\"%s\"";
+
+ SHGetFolderPathAndSubDirW(0, CSIDL_RESOURCES, NULL, SHGFP_TYPE_DEFAULT, Themes[iTheme].ThemeFile, wszTheme);
+ swprintf(wszParams, format, wszTheme);
+ RunControlPanelApplet(hwndDlg, wszParams);
+ }
+ else
+ {
+ RunControlPanelApplet(hwndDlg, L"desk.cpl desk,@Appearance /Action:ActivateMSTheme");
+ }
+ }
+ break;
+ case PSN_SETACTIVE:
+ /* Enable the Back and Next buttons */
+ PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
+ if (SetupData->UnattendSetup)
+ {
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, SetupData->uFirstNetworkWizardPage);
+ return TRUE;
+ }
+ break;
+
+ case PSN_WIZNEXT:
+ break;
+
+ case PSN_WIZBACK:
+ SetupData->UnattendSetup = FALSE;
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return FALSE;
+}
static UINT CALLBACK
RegistrationNotificationProc(PVOID Context,
}
if (0 == LoadStringW(hDllInstance, MessageID,
ErrorMessage,
- sizeof(ErrorMessage) /
- sizeof(ErrorMessage[0])))
+ ARRAYSIZE(ErrorMessage)))
{
ErrorMessage[0] = L'\0';
}
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL,
StatusInfo->Win32Error, 0,
ErrorMessage + wcslen(ErrorMessage),
- sizeof(ErrorMessage) / sizeof(ErrorMessage[0]) -
- wcslen(ErrorMessage), NULL);
+ ARRAYSIZE(ErrorMessage) - wcslen(ErrorMessage),
+ NULL);
}
RegistrationNotify.ErrorMessage = ErrorMessage;
}
{
if (0 == LoadStringW(hDllInstance, IDS_UNKNOWN_ERROR,
UnknownError,
- sizeof(UnknownError) / sizeof(UnknownError[0]) -
- 20))
+ ARRAYSIZE(UnknownError) - 20))
{
wcscpy(UnknownError, L"Unknown error");
}
PREGISTRATIONDATA RegistrationData;
DllCount = -1;
- if (! SetupFindFirstLineW(hSysSetupInf, L"RegistrationPhase2",
- L"RegisterDlls", &Context))
+ if (!SetupFindFirstLineW(hSysSetupInf, L"RegistrationPhase2",
+ L"RegisterDlls", &Context))
{
DPRINT1("No RegistrationPhase2 section found\n");
return FALSE;
}
- if (! SetupGetStringFieldW(&Context, 1, SectionName,
- sizeof(SectionName) / sizeof(SectionName[0]),
- NULL))
+ if (!SetupGetStringFieldW(&Context, 1, SectionName,
+ ARRAYSIZE(SectionName),
+ NULL))
{
DPRINT1("Unable to retrieve section name\n");
return FALSE;
RegistrationData->hwndDlg = hwndDlg;
RegistrationData->DllCount = DllCount;
RegistrationThread = CreateThread(NULL, 0, RegistrationProc,
- (LPVOID) RegistrationData, 0, NULL);
+ RegistrationData, 0, NULL);
if (RegistrationThread != NULL)
{
CloseHandle(RegistrationThread);
WCHAR Title[64];
/* Retrieve pointer to the global setup data */
- SetupData = (PSETUPDATA)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
+ SetupData = (PSETUPDATA)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg)
{
{
/* Save pointer to the global setup data */
SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
- SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)SetupData);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (DWORD_PTR)SetupData);
}
break;
{
if (0 != LoadStringW(hDllInstance, RegistrationNotify->ActivityID,
Activity,
- sizeof(Activity) / sizeof(Activity[0])))
+ ARRAYSIZE(Activity)))
{
SendDlgItemMessageW(hwndDlg, IDC_ACTIVITY, WM_SETTEXT,
0, (LPARAM) Activity);
if (NULL != RegistrationNotify->ErrorMessage)
{
if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP,
- Title, sizeof(Title) / sizeof(Title[0])))
+ Title, ARRAYSIZE(Title)))
{
wcscpy(Title, L"ReactOS Setup");
}
if (wParam)
{
-#ifdef VMWINST
- if(!SetupData->UnattendSetup && !SetupData->DisableVmwInst)
- RunVMWInstall(GetParent(hwndDlg));
-#endif
-
/* Enable the Back and Next buttons */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
PropSheet_PressButton(GetParent(hwndDlg), PSBTN_NEXT);
/* Get pointer to the global setup data */
PSETUPDATA SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
- /* Run the Wine Gecko prompt */
- Control_RunDLLW(GetDesktopWindow(), 0, L"appwiz.cpl install_gecko", SW_SHOW);
+ if (!SetupData->UnattendSetup || !SetupData->DisableGeckoInst)
+ {
+ /* Run the Wine Gecko prompt */
+ Control_RunDLLW(hwndDlg, 0, L"appwiz.cpl install_gecko", SW_SHOW);
+ }
/* Set title font */
SendDlgItemMessage(hwndDlg,
}
-BOOL
-ProcessUnattendInf(HINF hUnattendedInf)
+/*
+ * GetInstallSourceWin32 retrieves the path to the ReactOS installation medium
+ * in Win32 format, for later use by syssetup and storage in the registry.
+ */
+static BOOL
+GetInstallSourceWin32(
+ OUT PWSTR pwszPath,
+ IN DWORD cchPathMax,
+ IN PCWSTR pwszNTPath)
+{
+ WCHAR wszDrives[512];
+ WCHAR wszNTPath[512]; // MAX_PATH ?
+ DWORD cchDrives;
+ PWCHAR pwszDrive;
+
+ *pwszPath = UNICODE_NULL;
+
+ cchDrives = GetLogicalDriveStringsW(_countof(wszDrives) - 1, wszDrives);
+ if (cchDrives == 0 || cchDrives >= _countof(wszDrives))
+ {
+ /* Buffer too small or failure */
+ LogItem(NULL, L"GetLogicalDriveStringsW failed");
+ return FALSE;
+ }
+
+ for (pwszDrive = wszDrives; *pwszDrive; pwszDrive += wcslen(pwszDrive) + 1)
+ {
+ WCHAR wszBuf[MAX_PATH];
+
+ /* Retrieve the NT path corresponding to the current Win32 DOS path */
+ pwszDrive[2] = UNICODE_NULL; // Temporarily remove the backslash
+ QueryDosDeviceW(pwszDrive, wszNTPath, _countof(wszNTPath));
+ pwszDrive[2] = L'\\'; // Restore the backslash
+
+ wcscat(wszNTPath, L"\\"); // Concat a backslash
+
+ /* Logging */
+ wsprintf(wszBuf, L"Testing '%s' --> '%s' %s a CD",
+ pwszDrive, wszNTPath,
+ (GetDriveTypeW(pwszDrive) == DRIVE_CDROM) ? L"is" : L"is not");
+ LogItem(NULL, wszBuf);
+
+ /* Check whether the NT path corresponds to the NT installation source path */
+ if (!_wcsicmp(wszNTPath, pwszNTPath))
+ {
+ /* Found it! */
+ wcscpy(pwszPath, pwszDrive); // cchPathMax
+
+ /* Logging */
+ wsprintf(wszBuf, L"GetInstallSourceWin32: %s", pwszPath);
+ LogItem(NULL, wszBuf);
+ wcscat(wszBuf, L"\n");
+ OutputDebugStringW(wszBuf);
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+VOID
+ProcessUnattendSection(
+ IN OUT PSETUPDATA pSetupData)
{
INFCONTEXT InfContext;
WCHAR szName[256];
DWORD LineLength;
HKEY hKey;
- if (!SetupFindFirstLineW(hUnattendedInf,
+ if (!SetupFindFirstLineW(pSetupData->hSetupInf,
L"Unattend",
L"UnattendSetupEnabled",
&InfContext))
{
- DPRINT1("Error: Cant find UnattendSetupEnabled Key! %d\n", GetLastError());
- return FALSE;
+ DPRINT1("Error: Cannot find UnattendSetupEnabled Key! %d\n", GetLastError());
+ return;
}
if (!SetupGetStringFieldW(&InfContext,
1,
szValue,
- sizeof(szValue) / sizeof(WCHAR),
+ ARRAYSIZE(szValue),
&LineLength))
{
DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
- return FALSE;
+ return;
}
- if (wcscmp(szValue, L"yes") != 0)
+ if (_wcsicmp(szValue, L"yes") != 0)
{
DPRINT("Unattend setup was disabled by UnattendSetupEnabled key.\n");
- return FALSE;
+ return;
}
- if (!SetupFindFirstLineW(hUnattendedInf,
+ pSetupData->UnattendSetup = TRUE;
+
+ if (!SetupFindFirstLineW(pSetupData->hSetupInf,
L"Unattend",
NULL,
&InfContext))
{
DPRINT1("Error: SetupFindFirstLine failed %d\n", GetLastError());
- return FALSE;
+ return;
}
-
do
{
if (!SetupGetStringFieldW(&InfContext,
0,
szName,
- sizeof(szName) / sizeof(WCHAR),
+ ARRAYSIZE(szName),
&LineLength))
{
DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
- return FALSE;
+ return;
}
if (!SetupGetStringFieldW(&InfContext,
1,
szValue,
- sizeof(szValue) / sizeof(WCHAR),
+ ARRAYSIZE(szValue),
&LineLength))
{
DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
- return FALSE;
+ return;
}
DPRINT1("Name %S Value %S\n", szName, szValue);
- if (!wcscmp(szName, L"FullName"))
+ if (!_wcsicmp(szName, L"FullName"))
{
- if ((sizeof(SetupData.OwnerName) / sizeof(TCHAR)) > LineLength)
+ if (ARRAYSIZE(pSetupData->OwnerName) > LineLength)
{
- wcscpy(SetupData.OwnerName, szValue);
+ wcscpy(pSetupData->OwnerName, szValue);
}
}
- else if (!wcscmp(szName, L"OrgName"))
+ else if (!_wcsicmp(szName, L"OrgName"))
{
- if ((sizeof(SetupData.OwnerOrganization) / sizeof(WCHAR)) > LineLength)
+ if (ARRAYSIZE(pSetupData->OwnerOrganization) > LineLength)
{
- wcscpy(SetupData.OwnerOrganization, szValue);
+ wcscpy(pSetupData->OwnerOrganization, szValue);
}
}
- else if (!wcscmp(szName, L"ComputerName"))
+ else if (!_wcsicmp(szName, L"ComputerName"))
{
- if ((sizeof(SetupData.ComputerName) / sizeof(WCHAR)) > LineLength)
+ if (ARRAYSIZE(pSetupData->ComputerName) > LineLength)
{
- wcscpy(SetupData.ComputerName, szValue);
+ wcscpy(pSetupData->ComputerName, szValue);
}
}
- else if (!wcscmp(szName, L"AdminPassword"))
+ else if (!_wcsicmp(szName, L"AdminPassword"))
{
- if ((sizeof(SetupData.AdminPassword) / sizeof(WCHAR)) > LineLength)
+ if (ARRAYSIZE(pSetupData->AdminPassword) > LineLength)
{
- wcscpy(SetupData.AdminPassword, szValue);
+ wcscpy(pSetupData->AdminPassword, szValue);
}
}
- else if (!wcscmp(szName, L"TimeZoneIndex"))
+ else if (!_wcsicmp(szName, L"TimeZoneIndex"))
{
- SetupData.TimeZoneIndex = _wtoi(szValue);
+ pSetupData->TimeZoneIndex = _wtoi(szValue);
}
- else if (!wcscmp(szName, L"DisableAutoDaylightTimeSet"))
+ else if (!_wcsicmp(szName, L"DisableAutoDaylightTimeSet"))
{
- SetupData.DisableAutoDaylightTimeSet = _wtoi(szValue);
+ pSetupData->DisableAutoDaylightTimeSet = _wtoi(szValue);
}
- else if (!wcscmp(szName, L"DisableVmwInst"))
+ else if (!_wcsicmp(szName, L"DisableGeckoInst"))
{
- if(!wcscmp(szValue, L"yes"))
- SetupData.DisableVmwInst = 1;
+ if (!_wcsicmp(szValue, L"yes"))
+ pSetupData->DisableGeckoInst = TRUE;
else
- SetupData.DisableVmwInst = 0;
+ pSetupData->DisableGeckoInst = FALSE;
}
+ } while (SetupFindNextLine(&InfContext, &InfContext));
+
+ if (SetupFindFirstLineW(pSetupData->hSetupInf,
+ L"Display",
+ NULL,
+ &InfContext))
+ {
+ DEVMODEW dm = { { 0 } };
+ dm.dmSize = sizeof(dm);
+ if (EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm))
+ {
+ do
+ {
+ int iValue;
+ if (!SetupGetStringFieldW(&InfContext,
+ 0,
+ szName,
+ ARRAYSIZE(szName),
+ &LineLength))
+ {
+ DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
+ return;
+ }
+
+ if (!SetupGetStringFieldW(&InfContext,
+ 1,
+ szValue,
+ ARRAYSIZE(szValue),
+ &LineLength))
+ {
+ DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
+ return;
+ }
+ iValue = _wtoi(szValue);
+ DPRINT1("Name %S Value %i\n", szName, iValue);
+
+ if (!iValue)
+ continue;
+
+ if (!_wcsicmp(szName, L"BitsPerPel"))
+ {
+ dm.dmFields |= DM_BITSPERPEL;
+ dm.dmBitsPerPel = iValue;
+ }
+ else if (!_wcsicmp(szName, L"XResolution"))
+ {
+ dm.dmFields |= DM_PELSWIDTH;
+ dm.dmPelsWidth = iValue;
+ }
+ else if (!_wcsicmp(szName, L"YResolution"))
+ {
+ dm.dmFields |= DM_PELSHEIGHT;
+ dm.dmPelsHeight = iValue;
+ }
+ else if (!_wcsicmp(szName, L"VRefresh"))
+ {
+ dm.dmFields |= DM_DISPLAYFREQUENCY;
+ dm.dmDisplayFrequency = iValue;
+ }
+ } while (SetupFindNextLine(&InfContext, &InfContext));
+
+ ChangeDisplaySettingsW(&dm, CDS_UPDATEREGISTRY);
+ }
}
- while (SetupFindNextLine(&InfContext, &InfContext));
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
&hKey) != ERROR_SUCCESS)
{
DPRINT1("Error: failed to open HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\n");
- return TRUE;
+ return;
}
-
- if (SetupFindFirstLineW(hUnattendedInf,
+ if (SetupFindFirstLineW(pSetupData->hSetupInf,
L"GuiRunOnce",
NULL,
&InfContext))
{
-
int i = 0;
do
{
- if(SetupGetStringFieldW(&InfContext,
- 0,
- szValue,
- sizeof(szValue) / sizeof(WCHAR),
- NULL))
+ if (SetupGetStringFieldW(&InfContext,
+ 0,
+ szValue,
+ ARRAYSIZE(szValue),
+ NULL))
{
WCHAR szPath[MAX_PATH];
swprintf(szName, L"%d", i);
}
}
}
- } while(SetupFindNextLine(&InfContext, &InfContext));
+ } while (SetupFindNextLine(&InfContext, &InfContext));
}
RegCloseKey(hKey);
- return TRUE;
}
-/*
- * GetRosInstallCD should find the path to ros installation medium
- * BUG 1
- * If there are more than one CDDrive in it containing a ReactOS
- * installation cd, then it will pick the first one regardless if
- * it is really the installation cd
- *
- * The best way to implement this is to set the key
- * HKLM\Software\Microsoft\Windows NT\CurrentVersion\SourcePath (REG_SZ)
- */
-
-BOOL
-GetRosInstallCD(WCHAR *pwszPath, DWORD cchPathMax)
+VOID
+ProcessSetupInf(
+ IN OUT PSETUPDATA pSetupData)
{
- WCHAR wszDrives[512];
- DWORD cchDrives;
- WCHAR *pwszDrive;
+ WCHAR szPath[MAX_PATH];
+ WCHAR szValue[MAX_PATH];
+ INFCONTEXT InfContext;
+ DWORD LineLength;
+ HKEY hKey;
+ LONG res;
- cchDrives = GetLogicalDriveStringsW(_countof(wszDrives) - 1, wszDrives);
- if (cchDrives == 0 || cchDrives >= _countof(wszDrives))
+ pSetupData->hSetupInf = INVALID_HANDLE_VALUE;
+
+ /* Retrieve the path of the setup INF */
+ GetSystemDirectoryW(szPath, _countof(szPath));
+ wcscat(szPath, L"\\$winnt$.inf");
+
+ /* Open the setup INF */
+ pSetupData->hSetupInf = SetupOpenInfFileW(szPath,
+ NULL,
+ INF_STYLE_OLDNT,
+ NULL);
+ if (pSetupData->hSetupInf == INVALID_HANDLE_VALUE)
{
- /* buffer too small or failure */
- LogItem(SYSSETUP_SEVERITY_INFORMATION, L"GetLogicalDriveStringsW failed");
- return FALSE;
+ DPRINT1("Error: Cannot open the setup information file %S with error %d\n", szPath, GetLastError());
+ return;
}
- for (pwszDrive = wszDrives; pwszDrive[0]; pwszDrive += wcslen(pwszDrive) + 1)
+
+ /* Retrieve the NT source path from which the 1st-stage installer was run */
+ if (!SetupFindFirstLineW(pSetupData->hSetupInf,
+ L"data",
+ L"sourcepath",
+ &InfContext))
{
- 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(pwszPath, pwszDrive, cchPathMax);
- OutputDebugStringW(L"GetRosInstallCD: ");OutputDebugStringW(pwszPath);OutputDebugStringW(L"\n");
- return TRUE;
- }
- }
+ DPRINT1("Error: Cannot find sourcepath Key! %d\n", GetLastError());
+ return;
+ }
+
+ if (!SetupGetStringFieldW(&InfContext,
+ 1,
+ szValue,
+ ARRAYSIZE(szValue),
+ &LineLength))
+ {
+ DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
+ return;
}
- return FALSE;
-}
+ *pSetupData->SourcePath = UNICODE_NULL;
+
+ /* Close the setup INF as we are going to modify it manually */
+ if (pSetupData->hSetupInf != INVALID_HANDLE_VALUE)
+ SetupCloseInfFile(pSetupData->hSetupInf);
-VOID
-ProcessUnattendSetup(VOID)
-{
- WCHAR szPath[MAX_PATH];
- HINF hUnattendedInf;
- DWORD dwLength;
- if (!GetRosInstallCD(szPath, MAX_PATH))
+ /* Find the installation source path in Win32 format */
+ if (!GetInstallSourceWin32(pSetupData->SourcePath,
+ _countof(pSetupData->SourcePath),
+ szValue))
{
- /* no cd drive found */
- return;
+ *pSetupData->SourcePath = UNICODE_NULL;
}
- dwLength = wcslen(szPath);
- if (dwLength + 21 > MAX_PATH)
+ /* Save the path in Win32 format in the setup INF */
+ swprintf(szValue, L"\"%s\"", pSetupData->SourcePath);
+ WritePrivateProfileStringW(L"data", L"dospath", szValue, szPath);
+
+ /*
+ * Save it also in the registry, in the following keys:
+ * - HKLM\Software\Microsoft\Windows\CurrentVersion\Setup ,
+ * values "SourcePath" and "ServicePackSourcePath" (REG_SZ);
+ * - HKLM\Software\Microsoft\Windows NT\CurrentVersion ,
+ * value "SourcePath" (REG_SZ); set to the full path (e.g. D:\I386).
+ */
+#if 0
+ res = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"Software\\Microsoft\\Windows NT\\CurrentVersion",
+ 0,
+ KEY_ALL_ACCESS,
+ &hKey);
+
+ if (res != ERROR_SUCCESS)
{
- /* FIXME
- * allocate bigger buffer
- */
- return;
+ return FALSE;
}
+#endif
- wcscat(szPath, L"reactos\\unattend.inf");
+ res = RegCreateKeyExW(HKEY_LOCAL_MACHINE,
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\Setup",
+ 0, NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS, // KEY_WRITE
+ NULL,
+ &hKey,
+ NULL);
+ if (res == ERROR_SUCCESS)
+ {
+ res = RegSetValueExW(hKey,
+ L"SourcePath",
+ 0,
+ REG_SZ,
+ (LPBYTE)pSetupData->SourcePath,
+ (wcslen(pSetupData->SourcePath) + 1) * sizeof(WCHAR));
+
+ res = RegSetValueExW(hKey,
+ L"ServicePackSourcePath",
+ 0,
+ REG_SZ,
+ (LPBYTE)pSetupData->SourcePath,
+ (wcslen(pSetupData->SourcePath) + 1) * sizeof(WCHAR));
+
+ RegCloseKey(hKey);
+ }
- hUnattendedInf = SetupOpenInfFileW(szPath,
- NULL,
- INF_STYLE_OLDNT,
- NULL);
- if (hUnattendedInf != INVALID_HANDLE_VALUE)
+ /* Now, re-open the setup INF (this must succeed) */
+ pSetupData->hSetupInf = SetupOpenInfFileW(szPath,
+ NULL,
+ INF_STYLE_OLDNT,
+ NULL);
+ if (pSetupData->hSetupInf == INVALID_HANDLE_VALUE)
{
- SetupData.UnattendSetup = ProcessUnattendInf(hUnattendedInf);
- SetupCloseInfFile(hUnattendedInf);
+ DPRINT1("Error: Cannot open the setup information file %S with error %d\n", szPath, GetLastError());
+ return;
}
+
+ /* Process the unattended section of the setup file */
+ ProcessUnattendSection(pSetupData);
}
+typedef DWORD(WINAPI *PFNREQUESTWIZARDPAGES)(PDWORD, HPROPSHEETPAGE *, PSETUPDATA);
VOID
InstallWizard(VOID)
{
PROPSHEETHEADER psh;
- HPROPSHEETPAGE ahpsp[8];
+ HPROPSHEETPAGE *phpage = NULL;
PROPSHEETPAGE psp = {0};
UINT nPages = 0;
HWND hWnd;
MSG msg;
+ PSETUPDATA pSetupData = NULL;
+ HMODULE hNetShell = NULL;
+ PFNREQUESTWIZARDPAGES pfn = NULL;
+ DWORD dwPageCount = 9, dwNetworkPageCount = 0;
+
+ LogItem(L"BEGIN_SECTION", L"InstallWizard");
+
+ /* Allocate setup data */
+ pSetupData = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ sizeof(SETUPDATA));
+ if (pSetupData == NULL)
+ {
+ LogItem(NULL, L"SetupData allocation failed!");
+ MessageBoxW(NULL,
+ L"Setup failed to allocate global data!",
+ L"ReactOS Setup",
+ MB_ICONERROR | MB_OK);
+ goto done;
+ }
- /* Clear setup data */
- ZeroMemory(&SetupData, sizeof(SETUPDATA));
+ hNetShell = LoadLibraryW(L"netshell.dll");
+ if (hNetShell != NULL)
+ {
+ DPRINT("Netshell.dll loaded!\n");
- ProcessUnattendSetup();
+ pfn = (PFNREQUESTWIZARDPAGES)GetProcAddress(hNetShell,
+ "NetSetupRequestWizardPages");
+ if (pfn != NULL)
+ {
+ pfn(&dwNetworkPageCount, NULL, NULL);
+ dwPageCount += dwNetworkPageCount;
+ }
+ }
+
+ DPRINT("PageCount: %lu\n", dwPageCount);
+
+ phpage = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ dwPageCount * sizeof(HPROPSHEETPAGE));
+ if (phpage == NULL)
+ {
+ LogItem(NULL, L"Page array allocation failed!");
+ MessageBoxW(NULL,
+ L"Setup failed to allocate page array!",
+ L"ReactOS Setup",
+ MB_ICONERROR | MB_OK);
+ goto done;
+ }
+
+ /* Process the $winnt$.inf setup file */
+ ProcessSetupInf(pSetupData);
/* Create the Welcome page */
psp.dwSize = sizeof(PROPSHEETPAGE);
psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
psp.hInstance = hDllInstance;
- psp.lParam = (LPARAM)&SetupData;
+ psp.lParam = (LPARAM)pSetupData;
psp.pfnDlgProc = WelcomeDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_WELCOMEPAGE);
- ahpsp[nPages++] = CreatePropertySheetPage(&psp);
+ phpage[nPages++] = CreatePropertySheetPage(&psp);
/* Create the Acknowledgements page */
psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_ACKSUBTITLE);
psp.pszTemplate = MAKEINTRESOURCE(IDD_ACKPAGE);
psp.pfnDlgProc = AckPageDlgProc;
- ahpsp[nPages++] = CreatePropertySheetPage(&psp);
+ phpage[nPages++] = CreatePropertySheetPage(&psp);
/* Create the Locale page */
psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_LOCALESUBTITLE);
psp.pfnDlgProc = LocalePageDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_LOCALEPAGE);
- ahpsp[nPages++] = CreatePropertySheetPage(&psp);
-
+ phpage[nPages++] = CreatePropertySheetPage(&psp);
/* Create the Owner page */
psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_OWNERSUBTITLE);
psp.pszTemplate = MAKEINTRESOURCE(IDD_OWNERPAGE);
psp.pfnDlgProc = OwnerPageDlgProc;
- ahpsp[nPages++] = CreatePropertySheetPage(&psp);
+ phpage[nPages++] = CreatePropertySheetPage(&psp);
/* Create the Computer page */
psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_COMPUTERSUBTITLE);
psp.pfnDlgProc = ComputerPageDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_COMPUTERPAGE);
- ahpsp[nPages++] = CreatePropertySheetPage(&psp);
-
+ phpage[nPages++] = CreatePropertySheetPage(&psp);
/* Create the DateTime page */
psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_DATETIMESUBTITLE);
psp.pfnDlgProc = DateTimePageDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_DATETIMEPAGE);
- ahpsp[nPages++] = CreatePropertySheetPage(&psp);
+ phpage[nPages++] = CreatePropertySheetPage(&psp);
+
+ /* Create the theme selection page */
+ psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
+ psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_THEMESELECTIONTITLE);
+ psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_THEMESELECTIONSUBTITLE);
+ psp.pfnDlgProc = ThemePageDlgProc;
+ psp.pszTemplate = MAKEINTRESOURCE(IDD_THEMEPAGE);
+ phpage[nPages++] = CreatePropertySheetPage(&psp);
+ pSetupData->uFirstNetworkWizardPage = IDD_PROCESSPAGE;
+ pSetupData->uPostNetworkWizardPage = IDD_PROCESSPAGE;
+
+ if (pfn)
+ {
+ pfn(&dwNetworkPageCount, &phpage[nPages], pSetupData);
+ nPages += dwNetworkPageCount;
+ }
/* Create the Process page */
psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_PROCESSSUBTITLE);
psp.pfnDlgProc = ProcessPageDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_PROCESSPAGE);
- ahpsp[nPages++] = CreatePropertySheetPage(&psp);
-
+ phpage[nPages++] = CreatePropertySheetPage(&psp);
/* Create the Finish page */
psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
psp.pfnDlgProc = FinishDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_FINISHPAGE);
- ahpsp[nPages++] = CreatePropertySheetPage(&psp);
+ phpage[nPages++] = CreatePropertySheetPage(&psp);
+
+ ASSERT(nPages == dwPageCount);
/* Create the property sheet */
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.hwndParent = NULL;
psh.nPages = nPages;
psh.nStartPage = 0;
- psh.phpage = ahpsp;
+ psh.phpage = phpage;
psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER);
/* Create title font */
- SetupData.hTitleFont = CreateTitleFont();
+ pSetupData->hTitleFont = CreateTitleFont();
+ pSetupData->hBoldFont = CreateBoldFont();
/* Display the wizard */
hWnd = (HWND)PropertySheet(&psh);
while (GetMessage(&msg, NULL, 0, 0))
{
- if(!IsDialogMessage(hWnd, &msg))
+ if (!IsDialogMessage(hWnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
- DeleteObject(SetupData.hTitleFont);
+ DeleteObject(pSetupData->hBoldFont);
+ DeleteObject(pSetupData->hTitleFont);
+
+ if (pSetupData->hSetupInf != INVALID_HANDLE_VALUE)
+ SetupCloseInfFile(pSetupData->hSetupInf);
+
+done:
+ if (phpage != NULL)
+ HeapFree(GetProcessHeap(), 0, phpage);
+
+ if (hNetShell != NULL)
+ FreeLibrary(hNetShell);
+
+ if (pSetupData != NULL)
+ HeapFree(GetProcessHeap(), 0, pSetupData);
+
+ LogItem(L"END_SECTION", L"InstallWizard");
}
/* EOF */