mirror of
https://github.com/reactos/reactos.git
synced 2025-01-06 06:20:13 +00:00
* make 2nd stage setup semi-unattendable (locale page is missing)
* to enable add the boot\bootdata\unattend.inf 6 optional to boot\bootdata\packages\reactos.dff svn path=/trunk/; revision=23517
This commit is contained in:
parent
6845ab891c
commit
1547291dcc
2 changed files with 285 additions and 46 deletions
|
@ -37,8 +37,6 @@ typedef struct _TIMEZONE_ENTRY
|
|||
ULONG Index;
|
||||
} TIMEZONE_ENTRY, *PTIMEZONE_ENTRY;
|
||||
|
||||
|
||||
|
||||
typedef struct _SETUPDATA
|
||||
{
|
||||
HFONT hTitleFont;
|
||||
|
@ -47,10 +45,14 @@ typedef struct _SETUPDATA
|
|||
TCHAR OwnerOrganization[51];
|
||||
TCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1]; /* max. 63 characters */
|
||||
TCHAR AdminPassword[15]; /* max. 14 characters */
|
||||
BOOL UnattendSetup;
|
||||
|
||||
SYSTEMTIME SystemTime;
|
||||
PTIMEZONE_ENTRY TimeZoneListHead;
|
||||
PTIMEZONE_ENTRY TimeZoneListTail;
|
||||
DWORD TimeZoneIndex;
|
||||
DWORD DisableAutoDaylightTimeSet;
|
||||
LCID LocaleID;
|
||||
} SETUPDATA, *PSETUPDATA;
|
||||
|
||||
|
||||
|
|
|
@ -268,6 +268,15 @@ WelcomeDlgProc(HWND hwndDlg,
|
|||
case PSN_SETACTIVE:
|
||||
/* Enable the Next button */
|
||||
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
|
||||
if (SetupData.UnattendSetup)
|
||||
{
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_ACKPAGE);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PSN_WIZBACK:
|
||||
SetupData.UnattendSetup = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -360,6 +369,15 @@ AckPageDlgProc(HWND hwndDlg,
|
|||
case PSN_SETACTIVE:
|
||||
/* Enable the Back and Next buttons */
|
||||
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
|
||||
if (SetupData.UnattendSetup)
|
||||
{
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_OWNERPAGE);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PSN_WIZBACK:
|
||||
SetupData.UnattendSetup = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -375,6 +393,50 @@ AckPageDlgProc(HWND hwndDlg,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static
|
||||
BOOL
|
||||
WriteOwnerSettings(TCHAR * OwnerName,
|
||||
TCHAR * OwnerOrganization)
|
||||
{
|
||||
HKEY hKey;
|
||||
LONG res;
|
||||
|
||||
|
||||
|
||||
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
_T("Software\\Microsoft\\Windows NT\\CurrentVersion"),
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey);
|
||||
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
res = RegSetValueEx(hKey,
|
||||
_T("RegisteredOwner"),
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)OwnerName,
|
||||
(_tcslen(OwnerName) + 1) * sizeof(TCHAR));
|
||||
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
res = RegSetValueEx(hKey,
|
||||
_T("RegisteredOrganization"),
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)OwnerOrganization,
|
||||
(_tcslen(OwnerOrganization) + 1) * sizeof(TCHAR));
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return (res == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
OwnerPageDlgProc(HWND hwndDlg,
|
||||
|
@ -384,7 +446,6 @@ OwnerPageDlgProc(HWND hwndDlg,
|
|||
{
|
||||
TCHAR OwnerName[51];
|
||||
TCHAR OwnerOrganization[51];
|
||||
HKEY hKey;
|
||||
LPNMHDR lpnm;
|
||||
|
||||
switch (uMsg)
|
||||
|
@ -409,6 +470,16 @@ OwnerPageDlgProc(HWND hwndDlg,
|
|||
case PSN_SETACTIVE:
|
||||
/* Enable the Back and Next buttons */
|
||||
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
|
||||
if (SetupData.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))
|
||||
{
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_COMPUTERPAGE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PSN_WIZNEXT:
|
||||
|
@ -429,30 +500,15 @@ OwnerPageDlgProc(HWND hwndDlg,
|
|||
OwnerOrganization[0] = 0;
|
||||
GetDlgItemTextW(hwndDlg, IDC_OWNERORGANIZATION, OwnerOrganization, 50);
|
||||
|
||||
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
_T("Software\\Microsoft\\Windows NT\\CurrentVersion"),
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
&hKey);
|
||||
/* FIXME: check error code */
|
||||
if (!WriteOwnerSettings(OwnerName, OwnerOrganization))
|
||||
{
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_OWNERNAME));
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
RegSetValueEx(hKey,
|
||||
_T("RegisteredOwner"),
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)OwnerName,
|
||||
(_tcslen(OwnerName) + 1) * sizeof(TCHAR));
|
||||
/* FIXME: check error code */
|
||||
|
||||
RegSetValueEx(hKey,
|
||||
_T("RegisteredOrganization"),
|
||||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)OwnerOrganization,
|
||||
(_tcslen(OwnerOrganization) + 1) * sizeof(TCHAR));
|
||||
/* FIXME: check error code */
|
||||
|
||||
RegCloseKey(hKey);
|
||||
case PSN_WIZBACK:
|
||||
SetupData.UnattendSetup = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -467,7 +523,25 @@ OwnerPageDlgProc(HWND hwndDlg,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
static
|
||||
BOOL
|
||||
WriteComputerSettings(TCHAR * ComputerName, HWND hwndDlg)
|
||||
{
|
||||
if (!SetComputerName(ComputerName))
|
||||
{
|
||||
MessageBox(hwndDlg,
|
||||
_T("Setup failed to set the computer name."),
|
||||
_T("ReactOS Setup"),
|
||||
MB_ICONERROR | MB_OK);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Try to also set DNS hostname */
|
||||
SetComputerNameEx(ComputerNamePhysicalDnsHostname, ComputerName);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
ComputerPageDlgProc(HWND hwndDlg,
|
||||
|
@ -499,6 +573,13 @@ ComputerPageDlgProc(HWND hwndDlg,
|
|||
|
||||
/* Set focus to computer name */
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
|
||||
if (SetupData.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);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -512,6 +593,11 @@ ComputerPageDlgProc(HWND hwndDlg,
|
|||
case PSN_SETACTIVE:
|
||||
/* Enable the Back and Next buttons */
|
||||
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
|
||||
if (SetupData.UnattendSetup && WriteComputerSettings(SetupData.ComputerName, hwndDlg))
|
||||
{
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_LOCALEPAGE);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PSN_WIZNEXT:
|
||||
|
@ -528,18 +614,12 @@ ComputerPageDlgProc(HWND hwndDlg,
|
|||
|
||||
/* FIXME: check computer name for invalid characters */
|
||||
|
||||
if (!SetComputerName(ComputerName))
|
||||
{
|
||||
MessageBox(hwndDlg,
|
||||
_T("Setup failed to set the computer name."),
|
||||
_T("ReactOS Setup"),
|
||||
MB_ICONERROR | MB_OK);
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
|
||||
return TRUE;
|
||||
}
|
||||
/* Try to also set DNS hostname */
|
||||
SetComputerNameEx(ComputerNamePhysicalDnsHostname, ComputerName);
|
||||
if (!WriteComputerSettings(ComputerName, hwndDlg))
|
||||
{
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Check admin passwords */
|
||||
GetDlgItemText(hwndDlg, IDC_ADMINPASSWORD1, Password1, 15);
|
||||
|
@ -560,6 +640,10 @@ ComputerPageDlgProc(HWND hwndDlg,
|
|||
/* FIXME: Set admin password */
|
||||
break;
|
||||
|
||||
case PSN_WIZBACK:
|
||||
SetupData.UnattendSetup = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -666,6 +750,14 @@ RunInputLocalePage(HWND hwnd)
|
|||
FreeLibrary(hDll);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
SetInputLocale()
|
||||
{
|
||||
//TODO
|
||||
//store the default locale
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
LocalePageDlgProc(HWND hwndDlg,
|
||||
|
@ -722,11 +814,20 @@ LocalePageDlgProc(HWND hwndDlg,
|
|||
case PSN_SETACTIVE:
|
||||
/* Enable the Back and Next buttons */
|
||||
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
|
||||
if (SetupData->UnattendSetup && SetInputLocale())
|
||||
{
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_DATETIMEPAGE);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PSN_WIZNEXT:
|
||||
break;
|
||||
|
||||
case PSN_WIZBACK:
|
||||
SetupData->UnattendSetup = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1044,17 +1145,15 @@ GetTimeZoneListIndex(LPDWORD lpIndex)
|
|||
|
||||
|
||||
static VOID
|
||||
ShowTimeZoneList(HWND hwnd, PSETUPDATA SetupData)
|
||||
ShowTimeZoneList(HWND hwnd, PSETUPDATA SetupData, DWORD dwEntryIndex)
|
||||
{
|
||||
PTIMEZONE_ENTRY Entry;
|
||||
DWORD dwIndex = 0;
|
||||
DWORD dwEntryIndex = 0;
|
||||
DWORD dwCount;
|
||||
|
||||
#if 0
|
||||
GetTimeZoneListIndex(&dwEntryIndex);
|
||||
#endif
|
||||
dwEntryIndex = 85; /* GMT time zone */
|
||||
|
||||
Entry = SetupData->TimeZoneListHead;
|
||||
while (Entry != NULL)
|
||||
|
@ -1235,6 +1334,25 @@ SetSystemLocalTime(HWND hwnd, PSETUPDATA SetupData)
|
|||
return Ret;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
WriteDateTimeSettings(HWND hwndDlg, PSETUPDATA SetupData)
|
||||
{
|
||||
GetLocalSystemTime(hwndDlg, SetupData);
|
||||
SetLocalTimeZone(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
|
||||
SetupData);
|
||||
|
||||
SetAutoDaylightInfo(GetDlgItem(hwndDlg, IDC_AUTODAYLIGHT));
|
||||
if(!SetSystemLocalTime(hwndDlg, SetupData))
|
||||
{
|
||||
MessageBox(hwndDlg,
|
||||
_T("Setup was unable to set the local time."),
|
||||
_T("ReactOS Setup"),
|
||||
MB_ICONWARNING | MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK
|
||||
DateTimePageDlgProc(HWND hwndDlg,
|
||||
|
@ -1256,11 +1374,25 @@ DateTimePageDlgProc(HWND hwndDlg,
|
|||
SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)SetupData);
|
||||
|
||||
CreateTimeZoneList(SetupData);
|
||||
|
||||
if (SetupData->UnattendSetup)
|
||||
{
|
||||
ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
|
||||
SetupData, SetupData->TimeZoneIndex);
|
||||
|
||||
ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
|
||||
SetupData);
|
||||
if (!SetupData->DisableAutoDaylightTimeSet)
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg, IDC_AUTODAYLIGHT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
|
||||
SetupData, 85 /* GMT time zone */);
|
||||
|
||||
SendDlgItemMessage(hwndDlg, IDC_AUTODAYLIGHT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
|
||||
}
|
||||
|
||||
SendDlgItemMessage(hwndDlg, IDC_AUTODAYLIGHT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1274,6 +1406,11 @@ DateTimePageDlgProc(HWND hwndDlg,
|
|||
case PSN_SETACTIVE:
|
||||
/* Enable the Back and Next buttons */
|
||||
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
|
||||
if (SetupData->UnattendSetup && WriteDateTimeSettings(hwndDlg, SetupData))
|
||||
{
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_PROCESSPAGE);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PSN_WIZNEXT:
|
||||
|
@ -1292,6 +1429,10 @@ DateTimePageDlgProc(HWND hwndDlg,
|
|||
}
|
||||
break;
|
||||
|
||||
case PSN_WIZBACK:
|
||||
SetupData->UnattendSetup = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1610,6 +1751,10 @@ ProcessPageDlgProc(HWND hwndDlg,
|
|||
case PSN_WIZNEXT:
|
||||
break;
|
||||
|
||||
case PSN_WIZBACK:
|
||||
SetupData->UnattendSetup = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1745,8 +1890,8 @@ FinishDlgProc(HWND hwndDlg,
|
|||
KillTimer(hwndDlg, 1);
|
||||
|
||||
/* Skip the progress page */
|
||||
PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_DATETIMEPAGE);
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
|
||||
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_DATETIMEPAGE);
|
||||
SetupData.UnattendSetup = FALSE;
|
||||
return TRUE;
|
||||
|
||||
case PSN_WIZFINISH:
|
||||
|
@ -1765,6 +1910,86 @@ FinishDlgProc(HWND hwndDlg,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
BOOL
|
||||
ProcessUnattendInf(HINF hUnattendedInf)
|
||||
{
|
||||
INFCONTEXT InfContext;
|
||||
TCHAR szName[256];
|
||||
TCHAR szValue[256];
|
||||
DWORD LineLength;
|
||||
|
||||
if (!SetupFindFirstLine(hUnattendedInf,
|
||||
_T("Unattend"),
|
||||
NULL,
|
||||
&InfContext))
|
||||
{
|
||||
DPRINT1("Error: SetupFindFirstLine failed %d\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (!SetupGetStringField(&InfContext,
|
||||
0,
|
||||
szName,
|
||||
sizeof(szName) / sizeof(TCHAR),
|
||||
&LineLength))
|
||||
{
|
||||
DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!SetupGetStringField(&InfContext,
|
||||
1,
|
||||
szValue,
|
||||
sizeof(szValue) / sizeof(TCHAR),
|
||||
&LineLength))
|
||||
{
|
||||
DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
DPRINT1("Name %S Value %S\n",szName, szValue);
|
||||
if (!_tcscmp(szName, _T("FullName")))
|
||||
{
|
||||
if ((sizeof(SetupData.OwnerName) / sizeof(TCHAR)) > LineLength)
|
||||
{
|
||||
_tcscpy(SetupData.OwnerName, szValue);
|
||||
}
|
||||
}
|
||||
else if (!_tcscmp(szName, _T("OrgName")))
|
||||
{
|
||||
if ((sizeof(SetupData.OwnerOrganization) / sizeof(TCHAR)) > LineLength)
|
||||
{
|
||||
_tcscpy(SetupData.OwnerOrganization, szValue);
|
||||
}
|
||||
}
|
||||
else if (!_tcscmp(szName, _T("ComputerName")))
|
||||
{
|
||||
if ((sizeof(SetupData.ComputerName) / sizeof(TCHAR)) > LineLength)
|
||||
{
|
||||
_tcscpy(SetupData.ComputerName, szValue);
|
||||
}
|
||||
}
|
||||
else if (!_tcscmp(szName, _T("AdminPassword")))
|
||||
{
|
||||
if ((sizeof(SetupData.AdminPassword) / sizeof(TCHAR)) > LineLength)
|
||||
{
|
||||
_tcscpy(SetupData.AdminPassword, szValue);
|
||||
}
|
||||
}
|
||||
else if (!_tcscmp(szName, _T("TimeZoneIndex")))
|
||||
{
|
||||
SetupData.TimeZoneIndex = _ttoi(szValue);
|
||||
}
|
||||
else if (_tcscmp(szName, _T("DisableAutoDaylightTimeSet")))
|
||||
{
|
||||
SetupData.DisableAutoDaylightTimeSet = _ttoi(szValue);
|
||||
}
|
||||
}
|
||||
while (SetupFindNextLine(&InfContext, &InfContext));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
|
@ -1774,10 +1999,22 @@ InstallWizard(VOID)
|
|||
HPROPSHEETPAGE ahpsp[8];
|
||||
PROPSHEETPAGE psp = {0};
|
||||
UINT nPages = 0;
|
||||
HINF hUnattendedInf;
|
||||
|
||||
/* Clear setup data */
|
||||
ZeroMemory(&SetupData, sizeof(SETUPDATA));
|
||||
|
||||
hUnattendedInf = SetupOpenInfFileW(L"unattend.inf",
|
||||
NULL,
|
||||
INF_STYLE_OLDNT,
|
||||
NULL);
|
||||
|
||||
if (hUnattendedInf != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
SetupData.UnattendSetup = ProcessUnattendInf(hUnattendedInf);
|
||||
SetupCloseInfFile(hUnattendedInf);
|
||||
}
|
||||
|
||||
/* Create the Welcome page */
|
||||
psp.dwSize = sizeof(PROPSHEETPAGE);
|
||||
psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
|
||||
|
|
Loading…
Reference in a new issue