[SETUPLIB][REACTOS][USETUP] Re-organize the setup state variables and some helpers.

- Move a great deal of global variables into the USETUP_DATA structure
  (the SetupInf, the SetupFileQueue, the generic lists...).

- Place the common setup initialization code into an InitializeSetup()
  routine, and the cleanup code into FinishSetup().

- Implement the setup-code part support for the TXTSETUP.SIF setup
  source path override variables "SetupSourceDevice" and "SetupSourcePath"
  (see CORE-9023); support for them in SETUPLDR will be added later.
This commit is contained in:
Hermès Bélusca-Maïto 2018-01-05 02:51:51 +01:00
parent 9016b5f3ef
commit 1a173dfdb2
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
6 changed files with 365 additions and 250 deletions

View file

@ -500,7 +500,6 @@ InitPaths:
ERROR_NUMBER ERROR_NUMBER
LoadSetupInf( LoadSetupInf(
OUT HINF* SetupInf,
IN OUT PUSETUP_DATA pSetupData) IN OUT PUSETUP_DATA pSetupData)
{ {
INFCONTEXT Context; INFCONTEXT Context;
@ -514,17 +513,18 @@ LoadSetupInf(
DPRINT("SetupInf path: '%S'\n", FileNameBuffer); DPRINT("SetupInf path: '%S'\n", FileNameBuffer);
*SetupInf = SetupOpenInfFileExW(FileNameBuffer, pSetupData->SetupInf =
NULL, SetupOpenInfFileExW(FileNameBuffer,
/* INF_STYLE_WIN4 | */ INF_STYLE_OLDNT, NULL,
pSetupData->LanguageId, /* INF_STYLE_WIN4 | */ INF_STYLE_OLDNT,
&ErrorLine); pSetupData->LanguageId,
&ErrorLine);
if (*SetupInf == INVALID_HANDLE_VALUE) if (pSetupData->SetupInf == INVALID_HANDLE_VALUE)
return ERROR_LOAD_TXTSETUPSIF; return ERROR_LOAD_TXTSETUPSIF;
/* Open 'Version' section */ /* Open 'Version' section */
if (!SetupFindFirstLineW(*SetupInf, L"Version", L"Signature", &Context)) if (!SetupFindFirstLineW(pSetupData->SetupInf, L"Version", L"Signature", &Context))
return ERROR_CORRUPT_TXTSETUPSIF; return ERROR_CORRUPT_TXTSETUPSIF;
/* Get pointer 'Signature' key */ /* Get pointer 'Signature' key */
@ -541,7 +541,7 @@ LoadSetupInf(
INF_FreeData(Value); INF_FreeData(Value);
/* Open 'DiskSpaceRequirements' section */ /* Open 'DiskSpaceRequirements' section */
if (!SetupFindFirstLineW(*SetupInf, L"DiskSpaceRequirements", L"FreeSysPartDiskSpace", &Context)) if (!SetupFindFirstLineW(pSetupData->SetupInf, L"DiskSpaceRequirements", L"FreeSysPartDiskSpace", &Context))
return ERROR_CORRUPT_TXTSETUPSIF; return ERROR_CORRUPT_TXTSETUPSIF;
pSetupData->RequiredPartitionDiskSpace = ~0; pSetupData->RequiredPartitionDiskSpace = ~0;
@ -553,12 +553,48 @@ LoadSetupInf(
pSetupData->RequiredPartitionDiskSpace = (ULONG)IntValue; pSetupData->RequiredPartitionDiskSpace = (ULONG)IntValue;
// //
// TODO: Support "SetupSourceDevice" and "SetupSourcePath" in txtsetup.sif // Support "SetupSourceDevice" and "SetupSourcePath" in txtsetup.sif
// See CORE-9023 // See CORE-9023
// Support for that should also be added in setupldr.
// //
/* Update the Setup Source paths */
if (SetupFindFirstLineW(pSetupData->SetupInf, L"SetupData", L"SetupSourceDevice", &Context))
{
/*
* Get optional pointer 'SetupSourceDevice' key, its presence
* will dictate whether we also need 'SetupSourcePath'.
*/
if (INF_GetData(&Context, NULL, &Value))
{
/* Free the old source root path string and create the new one */
RtlFreeUnicodeString(&pSetupData->SourceRootPath);
RtlCreateUnicodeString(&pSetupData->SourceRootPath, Value);
INF_FreeData(Value);
if (!SetupFindFirstLineW(pSetupData->SetupInf, L"SetupData", L"SetupSourcePath", &Context))
{
/* The 'SetupSourcePath' value is mandatory! */
return ERROR_CORRUPT_TXTSETUPSIF;
}
/* Get pointer 'SetupSourcePath' key */
if (!INF_GetData(&Context, NULL, &Value))
{
/* The 'SetupSourcePath' value is mandatory! */
return ERROR_CORRUPT_TXTSETUPSIF;
}
/* Free the old source path string and create the new one */
RtlFreeUnicodeString(&pSetupData->SourceRootDir);
RtlCreateUnicodeString(&pSetupData->SourceRootDir, Value);
INF_FreeData(Value);
}
}
/* Search for 'DefaultPath' in the 'SetupData' section */ /* Search for 'DefaultPath' in the 'SetupData' section */
if (SetupFindFirstLineW(*SetupInf, L"SetupData", L"DefaultPath", &Context)) pSetupData->InstallationDirectory[0] = 0;
if (SetupFindFirstLineW(pSetupData->SetupInf, L"SetupData", L"DefaultPath", &Context))
{ {
/* Get pointer 'DefaultPath' key */ /* Get pointer 'DefaultPath' key */
if (!INF_GetData(&Context, NULL, &Value)) if (!INF_GetData(&Context, NULL, &Value))
@ -574,6 +610,175 @@ LoadSetupInf(
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
NTSTATUS
InitDestinationPaths(
IN OUT PUSETUP_DATA pSetupData,
IN PCWSTR InstallationDir,
IN PDISKENTRY DiskEntry, // FIXME: HACK!
IN PPARTENTRY PartEntry) // FIXME: HACK!
{
WCHAR PathBuffer[MAX_PATH];
//
// TODO: Check return status values of the functions!
//
/* Create 'pSetupData->DestinationRootPath' string */
RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
L"\\Device\\Harddisk%lu\\Partition%lu\\",
DiskEntry->DiskNumber,
PartEntry->PartitionNumber);
RtlCreateUnicodeString(&pSetupData->DestinationRootPath, PathBuffer);
DPRINT("DestinationRootPath: %wZ\n", &pSetupData->DestinationRootPath);
/** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
/* Create 'pSetupData->DestinationArcPath' */
RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
DiskEntry->BiosDiskNumber,
PartEntry->PartitionNumber);
ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallationDir);
RtlCreateUnicodeString(&pSetupData->DestinationArcPath, PathBuffer);
/** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
/* Create 'pSetupData->DestinationPath' string */
RtlFreeUnicodeString(&pSetupData->DestinationPath);
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
pSetupData->DestinationRootPath.Buffer, InstallationDir);
RtlCreateUnicodeString(&pSetupData->DestinationPath, PathBuffer);
/** Equivalent of 'NTOS_INSTALLATION::PathComponent' **/
// FIXME: This is only temporary!! Must be removed later!
/***/RtlCreateUnicodeString(&pSetupData->InstallPath, InstallationDir);/***/
return STATUS_SUCCESS;
}
// NTSTATUS
ERROR_NUMBER
InitializeSetup(
IN OUT PUSETUP_DATA pSetupData,
IN ULONG InitPhase)
{
if (InitPhase == 0)
{
RtlZeroMemory(pSetupData, sizeof(*pSetupData));
// pSetupData->ComputerList = NULL;
// pSetupData->DisplayList = NULL;
// pSetupData->KeyboardList = NULL;
// pSetupData->LayoutList = NULL;
// pSetupData->LanguageList = NULL;
/* Initialize global unicode strings */
RtlInitUnicodeString(&pSetupData->SourcePath, NULL);
RtlInitUnicodeString(&pSetupData->SourceRootPath, NULL);
RtlInitUnicodeString(&pSetupData->SourceRootDir, NULL);
RtlInitUnicodeString(&pSetupData->DestinationArcPath, NULL);
RtlInitUnicodeString(&pSetupData->DestinationPath, NULL);
RtlInitUnicodeString(&pSetupData->DestinationRootPath, NULL);
RtlInitUnicodeString(&pSetupData->SystemRootPath, NULL);
// FIXME: This is only temporary!! Must be removed later!
/***/RtlInitUnicodeString(&pSetupData->InstallPath, NULL);/***/
//
// TODO: Load and start SetupDD, and ask it for the information
//
return ERROR_SUCCESS;
}
else
if (InitPhase == 1)
{
ERROR_NUMBER Error;
NTSTATUS Status;
/* Get the source path and source root path */
//
// NOTE: Sometimes the source path may not be in SystemRoot !!
// (and this is the case when using the 1st-stage GUI setup!)
//
Status = GetSourcePaths(&pSetupData->SourcePath,
&pSetupData->SourceRootPath,
&pSetupData->SourceRootDir);
if (!NT_SUCCESS(Status))
{
DPRINT1("GetSourcePaths() failed (Status 0x%08lx)", Status);
return ERROR_NO_SOURCE_DRIVE;
}
/*
* Example of output:
* SourcePath: '\Device\CdRom0\I386'
* SourceRootPath: '\Device\CdRom0'
* SourceRootDir: '\I386'
*/
DPRINT1("SourcePath (1): '%wZ'\n", &pSetupData->SourcePath);
DPRINT1("SourceRootPath (1): '%wZ'\n", &pSetupData->SourceRootPath);
DPRINT1("SourceRootDir (1): '%wZ'\n", &pSetupData->SourceRootDir);
/* Load 'txtsetup.sif' from the installation media */
Error = LoadSetupInf(pSetupData);
if (Error != ERROR_SUCCESS)
{
DPRINT1("LoadSetupInf() failed (Error 0x%lx)", Error);
return Error;
}
DPRINT1("SourcePath (2): '%wZ'\n", &pSetupData->SourcePath);
DPRINT1("SourceRootPath (2): '%wZ'\n", &pSetupData->SourceRootPath);
DPRINT1("SourceRootDir (2): '%wZ'\n", &pSetupData->SourceRootDir);
return ERROR_SUCCESS;
}
return ERROR_SUCCESS;
}
VOID
FinishSetup(
IN OUT PUSETUP_DATA pSetupData)
{
/* Destroy the computer settings list */
if (pSetupData->ComputerList != NULL)
{
DestroyGenericList(pSetupData->ComputerList, TRUE);
pSetupData->ComputerList = NULL;
}
/* Destroy the display settings list */
if (pSetupData->DisplayList != NULL)
{
DestroyGenericList(pSetupData->DisplayList, TRUE);
pSetupData->DisplayList = NULL;
}
/* Destroy the keyboard settings list */
if (pSetupData->KeyboardList != NULL)
{
DestroyGenericList(pSetupData->KeyboardList, TRUE);
pSetupData->KeyboardList = NULL;
}
/* Destroy the keyboard layout list */
if (pSetupData->LayoutList != NULL)
{
DestroyGenericList(pSetupData->LayoutList, TRUE);
pSetupData->LayoutList = NULL;
}
/* Destroy the languages list */
if (pSetupData->LanguageList != NULL)
{
DestroyGenericList(pSetupData->LanguageList, FALSE);
pSetupData->LanguageList = NULL;
}
/* Close the Setup INF */
SetupCloseInfFile(pSetupData->SetupInf);
}
/* /*
* SIDEEFFECTS * SIDEEFFECTS
* Calls RegInitializeRegistry * Calls RegInitializeRegistry

View file

@ -55,8 +55,16 @@ extern HANDLE ProcessHeap;
/* TYPEDEFS *****************************************************************/ /* TYPEDEFS *****************************************************************/
struct _USETUP_DATA;
typedef struct _USETUP_DATA typedef struct _USETUP_DATA
{ {
/* Setup INFs *****/
HINF SetupInf;
/* Installation *****/
PVOID SetupFileQueue; // HSPFILEQ
/* SOURCE Paths *****/ /* SOURCE Paths *****/
UNICODE_STRING SourceRootPath; UNICODE_STRING SourceRootPath;
UNICODE_STRING SourceRootDir; UNICODE_STRING SourceRootDir;
@ -79,17 +87,28 @@ typedef struct _USETUP_DATA
UNICODE_STRING SystemRootPath; UNICODE_STRING SystemRootPath;
/* Path to the installation directory inside the ReactOS boot partition */ /* Path to the installation directory inside the ReactOS boot partition */
UNICODE_STRING DestinationPath; /** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
UNICODE_STRING DestinationArcPath; /** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/ UNICODE_STRING DestinationArcPath; /** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
UNICODE_STRING DestinationPath; /** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
UNICODE_STRING DestinationRootPath; UNICODE_STRING DestinationRootPath;
// FIXME: This is only temporary!! Must be removed later!
UNICODE_STRING InstallPath;
LONG DestinationDiskNumber; LONG DestinationDiskNumber;
LONG DestinationPartitionNumber; LONG DestinationPartitionNumber;
LONG MBRInstallType;
LONG MBRInstallType;
LONG FormatPartition; LONG FormatPartition;
LONG AutoPartition; LONG AutoPartition;
/* Settings lists *****/
PGENERIC_LIST ComputerList;
PGENERIC_LIST DisplayList;
PGENERIC_LIST KeyboardList;
PGENERIC_LIST LayoutList;
PGENERIC_LIST LanguageList;
/* Other stuff *****/
WCHAR LocaleID[9]; WCHAR LocaleID[9];
LANGID LanguageId; LANGID LanguageId;
@ -119,7 +138,23 @@ GetSourcePaths(
ERROR_NUMBER ERROR_NUMBER
LoadSetupInf( LoadSetupInf(
OUT HINF* SetupInf, IN OUT PUSETUP_DATA pSetupData);
NTSTATUS
InitDestinationPaths(
IN OUT PUSETUP_DATA pSetupData,
IN PCWSTR InstallationDir,
IN PDISKENTRY DiskEntry, // FIXME: HACK!
IN PPARTENTRY PartEntry); // FIXME: HACK!
// NTSTATUS
ERROR_NUMBER
InitializeSetup(
IN OUT PUSETUP_DATA pSetupData,
IN ULONG InitPhase);
VOID
FinishSetup(
IN OUT PUSETUP_DATA pSetupData); IN OUT PUSETUP_DATA pSetupData);

View file

@ -70,7 +70,7 @@ MoreOptDlgProc(HWND hwndDlg,
case IDOK: case IDOK:
SendMessage(GetDlgItem(hwndDlg, IDC_PATH), SendMessage(GetDlgItem(hwndDlg, IDC_PATH),
WM_GETTEXT, WM_GETTEXT,
(WPARAM)sizeof(pSetupData->USetupData.InstallationDirectory) / sizeof(TCHAR), (WPARAM)ARRAYSIZE(pSetupData->USetupData.InstallationDirectory),
(LPARAM)pSetupData->USetupData.InstallationDirectory); (LPARAM)pSetupData->USetupData.InstallationDirectory);
EndDialog(hwndDlg, IDOK); EndDialog(hwndDlg, IDOK);

View file

@ -555,16 +555,16 @@ DeviceDlgProc(
SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (DWORD_PTR)pSetupData); SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (DWORD_PTR)pSetupData);
hList = GetDlgItem(hwndDlg, IDC_COMPUTER); hList = GetDlgItem(hwndDlg, IDC_COMPUTER);
InitGenericComboList(hList, pSetupData->ComputerList, GetSettingDescription); InitGenericComboList(hList, pSetupData->USetupData.ComputerList, GetSettingDescription);
hList = GetDlgItem(hwndDlg, IDC_DISPLAY); hList = GetDlgItem(hwndDlg, IDC_DISPLAY);
InitGenericComboList(hList, pSetupData->DisplayList, GetSettingDescription); InitGenericComboList(hList, pSetupData->USetupData.DisplayList, GetSettingDescription);
hList = GetDlgItem(hwndDlg, IDC_KEYBOARD); hList = GetDlgItem(hwndDlg, IDC_KEYBOARD);
InitGenericComboList(hList, pSetupData->KeyboardList, GetSettingDescription); InitGenericComboList(hList, pSetupData->USetupData.KeyboardList, GetSettingDescription);
// hList = GetDlgItem(hwndDlg, IDC_KEYBOARD_LAYOUT); // hList = GetDlgItem(hwndDlg, IDC_KEYBOARD_LAYOUT);
// InitGenericComboList(hList, pSetupData->LayoutList, GetSettingDescription); // InitGenericComboList(hList, pSetupData->USetupData.LayoutList, GetSettingDescription);
break; break;
} }
@ -808,11 +808,11 @@ BOOL LoadSetupData(
/* Load the hardware, language and keyboard layout lists */ /* Load the hardware, language and keyboard layout lists */
pSetupData->ComputerList = CreateComputerTypeList(pSetupData->SetupInf); pSetupData->USetupData.ComputerList = CreateComputerTypeList(pSetupData->USetupData.SetupInf);
pSetupData->DisplayList = CreateDisplayDriverList(pSetupData->SetupInf); pSetupData->USetupData.DisplayList = CreateDisplayDriverList(pSetupData->USetupData.SetupInf);
pSetupData->KeyboardList = CreateKeyboardDriverList(pSetupData->SetupInf); pSetupData->USetupData.KeyboardList = CreateKeyboardDriverList(pSetupData->USetupData.SetupInf);
pSetupData->LanguageList = CreateLanguageList(pSetupData->SetupInf, pSetupData->DefaultLanguage); pSetupData->USetupData.LanguageList = CreateLanguageList(pSetupData->USetupData.SetupInf, pSetupData->DefaultLanguage);
pSetupData->PartitionList = CreatePartitionList(); pSetupData->PartitionList = CreatePartitionList();
@ -826,7 +826,7 @@ BOOL LoadSetupData(
wcscpy(pSetupData->DefaultLanguage, pSetupData->USetupData.LocaleID); wcscpy(pSetupData->DefaultLanguage, pSetupData->USetupData.LocaleID);
pSetupData->USetupData.LanguageId = (LANGID)(wcstol(pSetupData->SelectedLanguageId, NULL, 16) & 0xFFFF); pSetupData->USetupData.LanguageId = (LANGID)(wcstol(pSetupData->SelectedLanguageId, NULL, 16) & 0xFFFF);
pSetupData->LayoutList = CreateKeyboardLayoutList(pSetupData->SetupInf, pSetupData->SelectedLanguageId, pSetupData->DefaultKBLayout); pSetupData->USetupData.LayoutList = CreateKeyboardLayoutList(pSetupData->USetupData.SetupInf, pSetupData->SelectedLanguageId, pSetupData->DefaultKBLayout);
#if 0 #if 0
// get default for keyboard and language // get default for keyboard and language
@ -834,7 +834,7 @@ BOOL LoadSetupData(
pSetupData->DefaultLang = -1; pSetupData->DefaultLang = -1;
// TODO: get defaults from underlaying running system // TODO: get defaults from underlaying running system
if (SetupFindFirstLine(pSetupData->SetupInf, _T("NLS"), _T("DefaultLayout"), &InfContext)) if (SetupFindFirstLine(pSetupData->USetupData.SetupInf, _T("NLS"), _T("DefaultLayout"), &InfContext))
{ {
SetupGetStringField(&InfContext, 1, tmp, ARRAYSIZE(tmp), &LineLength); SetupGetStringField(&InfContext, 1, tmp, ARRAYSIZE(tmp), &LineLength);
for (Count = 0; Count < pSetupData->KbLayoutCount; Count++) for (Count = 0; Count < pSetupData->KbLayoutCount; Count++)
@ -847,7 +847,7 @@ BOOL LoadSetupData(
} }
} }
if (SetupFindFirstLine(pSetupData->SetupInf, _T("NLS"), _T("DefaultLanguage"), &InfContext)) if (SetupFindFirstLine(pSetupData->USetupData.SetupInf, _T("NLS"), _T("DefaultLanguage"), &InfContext))
{ {
SetupGetStringField(&InfContext, 1, tmp, ARRAYSIZE(tmp), &LineLength); SetupGetStringField(&InfContext, 1, tmp, ARRAYSIZE(tmp), &LineLength);
for (Count = 0; Count < pSetupData->LangCount; Count++) for (Count = 0; Count < pSetupData->LangCount; Count++)
@ -948,7 +948,6 @@ _tWinMain(HINSTANCE hInst,
LPTSTR lpszCmdLine, LPTSTR lpszCmdLine,
int nCmdShow) int nCmdShow)
{ {
NTSTATUS Status;
ULONG Error; ULONG Error;
INITCOMMONCONTROLSEX iccx; INITCOMMONCONTROLSEX iccx;
PROPSHEETHEADER psh; PROPSHEETHEADER psh;
@ -958,41 +957,23 @@ _tWinMain(HINSTANCE hInst,
ProcessHeap = GetProcessHeap(); ProcessHeap = GetProcessHeap();
/* Initialize global unicode strings */ /* Initialize Setup, phase 0 */
RtlInitUnicodeString(&SetupData.USetupData.SourcePath, NULL); InitializeSetup(&SetupData.USetupData, 0);
RtlInitUnicodeString(&SetupData.USetupData.SourceRootPath, NULL);
RtlInitUnicodeString(&SetupData.USetupData.SourceRootDir, NULL);
// RtlInitUnicodeString(&InstallPath, NULL);
RtlInitUnicodeString(&SetupData.USetupData.DestinationPath, NULL);
RtlInitUnicodeString(&SetupData.USetupData.DestinationArcPath, NULL);
RtlInitUnicodeString(&SetupData.USetupData.DestinationRootPath, NULL);
RtlInitUnicodeString(&SetupData.USetupData.SystemRootPath, NULL);
/* Get the source path and source root path */ /* Initialize Setup, phase 1 */
// Error = InitializeSetup(&SetupData.USetupData, 1);
// NOTE: Sometimes the source path may not be in SystemRoot !!
// (and this is the case when using the 1st-stage GUI setup!)
//
Status = GetSourcePaths(&SetupData.USetupData.SourcePath,
&SetupData.USetupData.SourceRootPath,
&SetupData.USetupData.SourceRootDir);
if (!NT_SUCCESS(Status))
{
DPRINT1("GetSourcePaths() failed (Status 0x%08lx)", Status);
// MUIDisplayError(ERROR_NO_SOURCE_DRIVE, Ir, POPUP_WAIT_ENTER);
MessageBoxW(NULL, L"GetSourcePaths failed!", L"Error", MB_ICONERROR);
goto Quit;
}
DPRINT1("SourcePath: '%wZ'\n", &SetupData.USetupData.SourcePath);
DPRINT1("SourceRootPath: '%wZ'\n", &SetupData.USetupData.SourceRootPath);
DPRINT1("SourceRootDir: '%wZ'\n", &SetupData.USetupData.SourceRootDir);
/* Load 'txtsetup.sif' from the installation media */
Error = LoadSetupInf(&SetupData.SetupInf, &SetupData.USetupData);
if (Error != ERROR_SUCCESS) if (Error != ERROR_SUCCESS)
{ {
// MUIDisplayError(Error, Ir, POPUP_WAIT_ENTER); //
DisplayError(NULL, IDS_CAPTION, IDS_NO_TXTSETUP_SIF); // TODO: Write an error mapper (much like the MUIDisplayError of USETUP)
//
if (Error == ERROR_NO_SOURCE_DRIVE)
MessageBoxW(NULL, L"GetSourcePaths failed!", L"Error", MB_ICONERROR);
else if (Error == ERROR_LOAD_TXTSETUPSIF)
DisplayError(NULL, IDS_CAPTION, IDS_NO_TXTSETUP_SIF);
else // FIXME!!
MessageBoxW(NULL, L"Unknown error!", L"Error", MB_ICONERROR);
goto Quit; goto Quit;
} }
@ -1003,7 +984,7 @@ _tWinMain(HINSTANCE hInst,
SetupData.hInstance = hInst; SetupData.hInstance = hInst;
CheckUnattendedSetup(&SetupData.USetupData); CheckUnattendedSetup(&SetupData.USetupData);
SetupData.bUnattend = IsUnattendedSetup; SetupData.bUnattend = IsUnattendedSetup; // FIXME :-)
/* Cache commonly-used strings */ /* Cache commonly-used strings */
LoadStringW(hInst, IDS_ABORTSETUP, SetupData.szAbortMessage, ARRAYSIZE(SetupData.szAbortMessage)); LoadStringW(hInst, IDS_ABORTSETUP, SetupData.szAbortMessage, ARRAYSIZE(SetupData.szAbortMessage));
@ -1124,9 +1105,9 @@ _tWinMain(HINSTANCE hInst,
if (SetupData.hTitleFont) if (SetupData.hTitleFont)
DeleteObject(SetupData.hTitleFont); DeleteObject(SetupData.hTitleFont);
SetupCloseInfFile(SetupData.SetupInf);
Quit: Quit:
/* Setup has finished */
FinishSetup(&SetupData.USetupData);
#if 0 // NOTE: Disabled for testing purposes only! #if 0 // NOTE: Disabled for testing purposes only!
EnablePrivilege(SE_SHUTDOWN_NAME, TRUE); EnablePrivilege(SE_SHUTDOWN_NAME, TRUE);

View file

@ -55,7 +55,6 @@
/* Setup library headers */ /* Setup library headers */
// #include <reactos/rosioctl.h> // #include <reactos/rosioctl.h>
#include <../lib/setuplib.h> #include <../lib/setuplib.h>
// #include "errorcode.h"
#if 0 #if 0
typedef struct _KBLAYOUT typedef struct _KBLAYOUT
@ -79,7 +78,13 @@ typedef struct _SETUPDATA
TCHAR szAbortTitle[64]; TCHAR szAbortTitle[64];
USETUP_DATA USetupData; USETUP_DATA USetupData;
HINF SetupInf;
BOOLEAN RepairUpdateFlag; // flag for update/repair an installed reactos
PPARTLIST PartitionList;
PNTOS_INSTALLATION CurrentInstallation;
PGENERIC_LIST NtOsInstallsList;
/* Settings */ /* Settings */
LONG DestPartSize; // if partition doesn't exist, size of partition LONG DestPartSize; // if partition doesn't exist, size of partition
@ -92,9 +97,6 @@ typedef struct _SETUPDATA
LONG SelectedDisplay; // selected display type (table index) LONG SelectedDisplay; // selected display type (table index)
LONG SelectedKeyboard; // selected keyboard type (table index) LONG SelectedKeyboard; // selected keyboard type (table index)
BOOLEAN RepairUpdateFlag; // flag for update/repair an installed reactos
/* txtsetup.sif data */ /* txtsetup.sif data */
// LONG DefaultLang; // default language (table index) // LONG DefaultLang; // default language (table index)
// LONG DefaultKBLayout; // default keyboard layout (table index) // LONG DefaultKBLayout; // default keyboard layout (table index)
@ -102,16 +104,6 @@ typedef struct _SETUPDATA
WCHAR DefaultLanguage[20]; // Copy of string inside LanguageList WCHAR DefaultLanguage[20]; // Copy of string inside LanguageList
WCHAR DefaultKBLayout[20]; // Copy of string inside KeyboardList WCHAR DefaultKBLayout[20]; // Copy of string inside KeyboardList
PGENERIC_LIST ComputerList;
PGENERIC_LIST DisplayList;
PGENERIC_LIST KeyboardList;
PGENERIC_LIST LayoutList;
PGENERIC_LIST LanguageList;
PPARTLIST PartitionList;
PNTOS_INSTALLATION CurrentInstallation;
PGENERIC_LIST NtOsInstallsList;
} SETUPDATA, *PSETUPDATA; } SETUPDATA, *PSETUPDATA;
extern HANDLE ProcessHeap; extern HANDLE ProcessHeap;

View file

@ -40,15 +40,9 @@
/* GLOBALS & LOCALS *********************************************************/ /* GLOBALS & LOCALS *********************************************************/
HANDLE ProcessHeap; HANDLE ProcessHeap;
BOOLEAN IsUnattendedSetup = FALSE; BOOLEAN IsUnattendedSetup = FALSE;
static USETUP_DATA USetupData;
/* static USETUP_DATA USetupData;
* NOTE: Technically only used for the COPYCONTEXT InstallPath member
* for the filequeue functionality.
*/
static UNICODE_STRING InstallPath;
// FIXME: Is it really useful?? Just used for SetDefaultPagefile... // FIXME: Is it really useful?? Just used for SetDefaultPagefile...
static WCHAR DestinationDriveLetter; static WCHAR DestinationDriveLetter;
@ -71,19 +65,9 @@ static FORMATMACHINESTATE FormatState = Start;
/*****************************************************/ /*****************************************************/
static HINF SetupInf;
static HSPFILEQ SetupFileQueue = NULL;
static PNTOS_INSTALLATION CurrentInstallation = NULL; static PNTOS_INSTALLATION CurrentInstallation = NULL;
static PGENERIC_LIST NtOsInstallsList = NULL; static PGENERIC_LIST NtOsInstallsList = NULL;
static PGENERIC_LIST ComputerList = NULL;
static PGENERIC_LIST DisplayList = NULL;
static PGENERIC_LIST KeyboardList = NULL;
static PGENERIC_LIST LayoutList = NULL;
static PGENERIC_LIST LanguageList = NULL;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
@ -404,10 +388,10 @@ UpdateKBLayout(VOID)
pszNewLayout = MUIDefaultKeyboardLayout(SelectedLanguageId); pszNewLayout = MUIDefaultKeyboardLayout(SelectedLanguageId);
if (LayoutList == NULL) if (USetupData.LayoutList == NULL)
{ {
LayoutList = CreateKeyboardLayoutList(SetupInf, SelectedLanguageId, DefaultKBLayout); USetupData.LayoutList = CreateKeyboardLayoutList(USetupData.SetupInf, SelectedLanguageId, DefaultKBLayout);
if (LayoutList == NULL) if (USetupData.LayoutList == NULL)
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
return; return;
@ -417,12 +401,12 @@ UpdateKBLayout(VOID)
/* Search for default layout (if provided) */ /* Search for default layout (if provided) */
if (pszNewLayout != NULL) if (pszNewLayout != NULL)
{ {
for (ListEntry = GetFirstListEntry(LayoutList); ListEntry; for (ListEntry = GetFirstListEntry(USetupData.LayoutList); ListEntry;
ListEntry = GetNextListEntry(ListEntry)) ListEntry = GetNextListEntry(ListEntry))
{ {
if (!wcscmp(pszNewLayout, ((PGENENTRY)GetListEntryData(ListEntry))->Id)) if (!wcscmp(pszNewLayout, ((PGENENTRY)GetListEntryData(ListEntry))->Id))
{ {
SetCurrentListEntry(LayoutList, ListEntry); SetCurrentListEntry(USetupData.LayoutList, ListEntry);
break; break;
} }
} }
@ -491,10 +475,10 @@ LanguagePage(PINPUT_RECORD Ir)
BOOL RefreshPage = FALSE; BOOL RefreshPage = FALSE;
/* Initialize the computer settings list */ /* Initialize the computer settings list */
if (LanguageList == NULL) if (USetupData.LanguageList == NULL)
{ {
LanguageList = CreateLanguageList(SetupInf, DefaultLanguage); USetupData.LanguageList = CreateLanguageList(USetupData.SetupInf, DefaultLanguage);
if (LanguageList == NULL) if (USetupData.LanguageList == NULL)
{ {
PopupError("Setup failed to initialize available translations", NULL, NULL, POPUP_WAIT_NONE); PopupError("Setup failed to initialize available translations", NULL, NULL, POPUP_WAIT_NONE);
return WELCOME_PAGE; return WELCOME_PAGE;
@ -512,13 +496,13 @@ LanguagePage(PINPUT_RECORD Ir)
* If there is no language or just a single one in the list, * If there is no language or just a single one in the list,
* skip the language selection process altogether. * skip the language selection process altogether.
*/ */
if (GetNumberOfListEntries(LanguageList) <= 1) if (GetNumberOfListEntries(USetupData.LanguageList) <= 1)
{ {
USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF); USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
return WELCOME_PAGE; return WELCOME_PAGE;
} }
InitGenericListUi(&ListUi, LanguageList, GetSettingDescription); InitGenericListUi(&ListUi, USetupData.LanguageList, GetSettingDescription);
DrawGenericList(&ListUi, DrawGenericList(&ListUi,
2, 18, 2, 18,
xScreen - 3, xScreen - 3,
@ -566,10 +550,10 @@ LanguagePage(PINPUT_RECORD Ir)
} }
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{ {
ASSERT(GetNumberOfListEntries(LanguageList) >= 1); ASSERT(GetNumberOfListEntries(USetupData.LanguageList) >= 1);
SelectedLanguageId = SelectedLanguageId =
((PGENENTRY)GetListEntryData(GetCurrentListEntry(LanguageList)))->Id; ((PGENENTRY)GetListEntryData(GetCurrentListEntry(USetupData.LanguageList)))->Id;
USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF); USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
@ -592,10 +576,10 @@ LanguagePage(PINPUT_RECORD Ir)
if (RefreshPage) if (RefreshPage)
{ {
ASSERT(GetNumberOfListEntries(LanguageList) >= 1); ASSERT(GetNumberOfListEntries(USetupData.LanguageList) >= 1);
NewLanguageId = NewLanguageId =
((PGENENTRY)GetListEntryData(GetCurrentListEntry(LanguageList)))->Id; ((PGENENTRY)GetListEntryData(GetCurrentListEntry(USetupData.LanguageList)))->Id;
if (wcscmp(SelectedLanguageId, NewLanguageId)) if (wcscmp(SelectedLanguageId, NewLanguageId))
{ {
@ -632,7 +616,7 @@ LanguagePage(PINPUT_RECORD Ir)
* Init USetupData.SourcePath * Init USetupData.SourcePath
* Init USetupData.SourceRootPath * Init USetupData.SourceRootPath
* Init USetupData.SourceRootDir * Init USetupData.SourceRootDir
* Init SetupInf * Init USetupData.SetupInf
* Init USetupData.RequiredPartitionDiskSpace * Init USetupData.RequiredPartitionDiskSpace
* Init IsUnattendedSetup * Init IsUnattendedSetup
* If unattended, init *List and sets the Codepage * If unattended, init *List and sets the Codepage
@ -645,29 +629,14 @@ LanguagePage(PINPUT_RECORD Ir)
static PAGE_NUMBER static PAGE_NUMBER
SetupStartPage(PINPUT_RECORD Ir) SetupStartPage(PINPUT_RECORD Ir)
{ {
NTSTATUS Status;
ULONG Error; ULONG Error;
PGENERIC_LIST_ENTRY ListEntry; PGENERIC_LIST_ENTRY ListEntry;
PCWSTR LocaleId; PCWSTR LocaleId;
CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT)); CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
/* Get the source path and source root path */ /* Initialize Setup, phase 1 */
Status = GetSourcePaths(&USetupData.SourcePath, Error = InitializeSetup(&USetupData, 1);
&USetupData.SourceRootPath,
&USetupData.SourceRootDir);
if (!NT_SUCCESS(Status))
{
CONSOLE_PrintTextXY(6, 15, "GetSourcePaths() failed (Status 0x%08lx)", Status);
MUIDisplayError(ERROR_NO_SOURCE_DRIVE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
DPRINT1("SourcePath: '%wZ'\n", &USetupData.SourcePath);
DPRINT1("SourceRootPath: '%wZ'\n", &USetupData.SourceRootPath);
DPRINT1("SourceRootDir: '%wZ'\n", &USetupData.SourceRootDir);
/* Load 'txtsetup.sif' from the installation media */
Error = LoadSetupInf(&SetupInf, &USetupData);
if (Error != ERROR_SUCCESS) if (Error != ERROR_SUCCESS)
{ {
MUIDisplayError(Error, Ir, POPUP_WAIT_ENTER); MUIDisplayError(Error, Ir, POPUP_WAIT_ENTER);
@ -688,41 +657,41 @@ SetupStartPage(PINPUT_RECORD Ir)
// TODO: Read options from inf // TODO: Read options from inf
/* Load the hardware, language and keyboard layout lists */ /* Load the hardware, language and keyboard layout lists */
ComputerList = CreateComputerTypeList(SetupInf); USetupData.ComputerList = CreateComputerTypeList(USetupData.SetupInf);
DisplayList = CreateDisplayDriverList(SetupInf); USetupData.DisplayList = CreateDisplayDriverList(USetupData.SetupInf);
KeyboardList = CreateKeyboardDriverList(SetupInf); USetupData.KeyboardList = CreateKeyboardDriverList(USetupData.SetupInf);
LanguageList = CreateLanguageList(SetupInf, DefaultLanguage); USetupData.LanguageList = CreateLanguageList(USetupData.SetupInf, DefaultLanguage);
/* new part */ /* new part */
SelectedLanguageId = DefaultLanguage; SelectedLanguageId = DefaultLanguage;
wcscpy(DefaultLanguage, USetupData.LocaleID); wcscpy(DefaultLanguage, USetupData.LocaleID);
USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF); USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
LayoutList = CreateKeyboardLayoutList(SetupInf, SelectedLanguageId, DefaultKBLayout); USetupData.LayoutList = CreateKeyboardLayoutList(USetupData.SetupInf, SelectedLanguageId, DefaultKBLayout);
/* first we hack LanguageList */ /* first we hack LanguageList */
for (ListEntry = GetFirstListEntry(LanguageList); ListEntry; for (ListEntry = GetFirstListEntry(USetupData.LanguageList); ListEntry;
ListEntry = GetNextListEntry(ListEntry)) ListEntry = GetNextListEntry(ListEntry))
{ {
LocaleId = ((PGENENTRY)GetListEntryData(ListEntry))->Id; LocaleId = ((PGENENTRY)GetListEntryData(ListEntry))->Id;
if (!wcsicmp(USetupData.LocaleID, LocaleId)) if (!wcsicmp(USetupData.LocaleID, LocaleId))
{ {
DPRINT("found %S in LanguageList\n", LocaleId); DPRINT("found %S in LanguageList\n", LocaleId);
SetCurrentListEntry(LanguageList, ListEntry); SetCurrentListEntry(USetupData.LanguageList, ListEntry);
break; break;
} }
} }
/* now LayoutList */ /* now LayoutList */
for (ListEntry = GetFirstListEntry(LayoutList); ListEntry; for (ListEntry = GetFirstListEntry(USetupData.LayoutList); ListEntry;
ListEntry = GetNextListEntry(ListEntry)) ListEntry = GetNextListEntry(ListEntry))
{ {
LocaleId = ((PGENENTRY)GetListEntryData(ListEntry))->Id; LocaleId = ((PGENENTRY)GetListEntryData(ListEntry))->Id;
if (!wcsicmp(USetupData.LocaleID, LocaleId)) if (!wcsicmp(USetupData.LocaleID, LocaleId))
{ {
DPRINT("found %S in LayoutList\n", LocaleId); DPRINT("found %S in LayoutList\n", LocaleId);
SetCurrentListEntry(LayoutList, ListEntry); SetCurrentListEntry(USetupData.LayoutList, ListEntry);
break; break;
} }
} }
@ -1131,10 +1100,10 @@ OemDriverPage(PINPUT_RECORD Ir)
* QuitPage * QuitPage
* *
* SIDEEFFECTS * SIDEEFFECTS
* Init ComputerList * Init USetupData.ComputerList
* Init DisplayList * Init USetupData.DisplayList
* Init KeyboardList * Init USetupData.KeyboardList
* Init LayoutList * Init USetupData.LayoutList
* *
* RETURNS * RETURNS
* Number of the next page. * Number of the next page.
@ -1145,10 +1114,10 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
static ULONG Line = 16; static ULONG Line = 16;
/* Initialize the computer settings list */ /* Initialize the computer settings list */
if (ComputerList == NULL) if (USetupData.ComputerList == NULL)
{ {
ComputerList = CreateComputerTypeList(SetupInf); USetupData.ComputerList = CreateComputerTypeList(USetupData.SetupInf);
if (ComputerList == NULL) if (USetupData.ComputerList == NULL)
{ {
MUIDisplayError(ERROR_LOAD_COMPUTER, Ir, POPUP_WAIT_ENTER); MUIDisplayError(ERROR_LOAD_COMPUTER, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE; return QUIT_PAGE;
@ -1156,10 +1125,10 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
} }
/* Initialize the display settings list */ /* Initialize the display settings list */
if (DisplayList == NULL) if (USetupData.DisplayList == NULL)
{ {
DisplayList = CreateDisplayDriverList(SetupInf); USetupData.DisplayList = CreateDisplayDriverList(USetupData.SetupInf);
if (DisplayList == NULL) if (USetupData.DisplayList == NULL)
{ {
MUIDisplayError(ERROR_LOAD_DISPLAY, Ir, POPUP_WAIT_ENTER); MUIDisplayError(ERROR_LOAD_DISPLAY, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE; return QUIT_PAGE;
@ -1167,10 +1136,10 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
} }
/* Initialize the keyboard settings list */ /* Initialize the keyboard settings list */
if (KeyboardList == NULL) if (USetupData.KeyboardList == NULL)
{ {
KeyboardList = CreateKeyboardDriverList(SetupInf); USetupData.KeyboardList = CreateKeyboardDriverList(USetupData.SetupInf);
if (KeyboardList == NULL) if (USetupData.KeyboardList == NULL)
{ {
MUIDisplayError(ERROR_LOAD_KEYBOARD, Ir, POPUP_WAIT_ENTER); MUIDisplayError(ERROR_LOAD_KEYBOARD, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE; return QUIT_PAGE;
@ -1178,10 +1147,10 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
} }
/* Initialize the keyboard layout list */ /* Initialize the keyboard layout list */
if (LayoutList == NULL) if (USetupData.LayoutList == NULL)
{ {
LayoutList = CreateKeyboardLayoutList(SetupInf, SelectedLanguageId, DefaultKBLayout); USetupData.LayoutList = CreateKeyboardLayoutList(USetupData.SetupInf, SelectedLanguageId, DefaultKBLayout);
if (LayoutList == NULL) if (USetupData.LayoutList == NULL)
{ {
/* FIXME: report error */ /* FIXME: report error */
MUIDisplayError(ERROR_LOAD_KBLAYOUT, Ir, POPUP_WAIT_ENTER); MUIDisplayError(ERROR_LOAD_KBLAYOUT, Ir, POPUP_WAIT_ENTER);
@ -1197,10 +1166,10 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
MUIDisplayPage(DEVICE_SETTINGS_PAGE); MUIDisplayPage(DEVICE_SETTINGS_PAGE);
DrawGenericListCurrentItem(ComputerList, GetSettingDescription, 25, 11); DrawGenericListCurrentItem(USetupData.ComputerList, GetSettingDescription, 25, 11);
DrawGenericListCurrentItem(DisplayList , GetSettingDescription, 25, 12); DrawGenericListCurrentItem(USetupData.DisplayList , GetSettingDescription, 25, 12);
DrawGenericListCurrentItem(KeyboardList, GetSettingDescription, 25, 13); DrawGenericListCurrentItem(USetupData.KeyboardList, GetSettingDescription, 25, 13);
DrawGenericListCurrentItem(LayoutList , GetSettingDescription, 25, 14); DrawGenericListCurrentItem(USetupData.LayoutList , GetSettingDescription, 25, 14);
CONSOLE_InvertTextXY(24, Line, 48, 1); CONSOLE_InvertTextXY(24, Line, 48, 1);
@ -1343,7 +1312,7 @@ ComputerSettingsPage(PINPUT_RECORD Ir)
GENERIC_LIST_UI ListUi; GENERIC_LIST_UI ListUi;
MUIDisplayPage(COMPUTER_SETTINGS_PAGE); MUIDisplayPage(COMPUTER_SETTINGS_PAGE);
InitGenericListUi(&ListUi, ComputerList, GetSettingDescription); InitGenericListUi(&ListUi, USetupData.ComputerList, GetSettingDescription);
DrawGenericList(&ListUi, DrawGenericList(&ListUi,
2, 18, 2, 18,
xScreen - 3, xScreen - 3,
@ -1369,7 +1338,7 @@ DisplaySettingsPage(PINPUT_RECORD Ir)
GENERIC_LIST_UI ListUi; GENERIC_LIST_UI ListUi;
MUIDisplayPage(DISPLAY_SETTINGS_PAGE); MUIDisplayPage(DISPLAY_SETTINGS_PAGE);
InitGenericListUi(&ListUi, DisplayList, GetSettingDescription); InitGenericListUi(&ListUi, USetupData.DisplayList, GetSettingDescription);
DrawGenericList(&ListUi, DrawGenericList(&ListUi,
2, 18, 2, 18,
xScreen - 3, xScreen - 3,
@ -1395,7 +1364,7 @@ KeyboardSettingsPage(PINPUT_RECORD Ir)
GENERIC_LIST_UI ListUi; GENERIC_LIST_UI ListUi;
MUIDisplayPage(KEYBOARD_SETTINGS_PAGE); MUIDisplayPage(KEYBOARD_SETTINGS_PAGE);
InitGenericListUi(&ListUi, KeyboardList, GetSettingDescription); InitGenericListUi(&ListUi, USetupData.KeyboardList, GetSettingDescription);
DrawGenericList(&ListUi, DrawGenericList(&ListUi,
2, 18, 2, 18,
xScreen - 3, xScreen - 3,
@ -1421,7 +1390,7 @@ LayoutSettingsPage(PINPUT_RECORD Ir)
GENERIC_LIST_UI ListUi; GENERIC_LIST_UI ListUi;
MUIDisplayPage(LAYOUT_SETTINGS_PAGE); MUIDisplayPage(LAYOUT_SETTINGS_PAGE);
InitGenericListUi(&ListUi, LayoutList, GetSettingDescription); InitGenericListUi(&ListUi, USetupData.LayoutList, GetSettingDescription);
DrawGenericList(&ListUi, DrawGenericList(&ListUi,
2, 18, 2, 18,
xScreen - 3, xScreen - 3,
@ -3224,38 +3193,11 @@ BuildInstallPaths(PWSTR InstallDir,
PDISKENTRY DiskEntry, PDISKENTRY DiskEntry,
PPARTENTRY PartEntry) PPARTENTRY PartEntry)
{ {
WCHAR PathBuffer[MAX_PATH]; NTSTATUS Status;
/** Equivalent of 'NTOS_INSTALLATION::PathComponent' **/ Status = InitDestinationPaths(&USetupData, InstallDir, DiskEntry, PartEntry);
/* Create 'InstallPath' string */ // TODO: Check Status
RtlFreeUnicodeString(&InstallPath); UNREFERENCED_PARAMETER(Status);
RtlCreateUnicodeString(&InstallPath, InstallDir);
/* Create 'USetupData.DestinationRootPath' string */
RtlFreeUnicodeString(&USetupData.DestinationRootPath);
RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
L"\\Device\\Harddisk%lu\\Partition%lu\\",
DiskEntry->DiskNumber,
PartEntry->PartitionNumber);
RtlCreateUnicodeString(&USetupData.DestinationRootPath, PathBuffer);
DPRINT("DestinationRootPath: %wZ\n", &USetupData.DestinationRootPath);
/** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
/* Create 'USetupData.DestinationPath' string */
RtlFreeUnicodeString(&USetupData.DestinationPath);
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
USetupData.DestinationRootPath.Buffer, InstallDir);
RtlCreateUnicodeString(&USetupData.DestinationPath, PathBuffer);
/** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
/* Create 'USetupData.DestinationArcPath' */
RtlFreeUnicodeString(&USetupData.DestinationArcPath);
RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
DiskEntry->BiosDiskNumber,
PartEntry->PartitionNumber);
ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallDir);
RtlCreateUnicodeString(&USetupData.DestinationArcPath, PathBuffer);
/* Initialize DestinationDriveLetter */ /* Initialize DestinationDriveLetter */
DestinationDriveLetter = (WCHAR)PartEntry->DriveLetter; DestinationDriveLetter = (WCHAR)PartEntry->DriveLetter;
@ -3594,7 +3536,7 @@ AddSectionToCopyQueueCab(HINF InfFile,
break; break;
} }
if (!SetupQueueCopy(SetupFileQueue, if (!SetupQueueCopy(USetupData.SetupFileQueue,
SourceCabinet, SourceCabinet,
USetupData.SourceRootPath.Buffer, USetupData.SourceRootPath.Buffer,
USetupData.SourceRootDir.Buffer, USetupData.SourceRootDir.Buffer,
@ -3728,7 +3670,7 @@ AddSectionToCopyQueue(HINF InfFile,
DPRINT("RelativePath(2): '%S'\n", CompleteOrigDirName); DPRINT("RelativePath(2): '%S'\n", CompleteOrigDirName);
} }
if (!SetupQueueCopy(SetupFileQueue, if (!SetupQueueCopy(USetupData.SetupFileQueue,
SourceCabinet, SourceCabinet,
USetupData.SourceRootPath.Buffer, USetupData.SourceRootPath.Buffer,
CompleteOrigDirName, CompleteOrigDirName,
@ -3767,7 +3709,7 @@ PrepareCopyPageInfFile(HINF InfFile,
/* Add specific files depending of computer type */ /* Add specific files depending of computer type */
if (SourceCabinet == NULL) if (SourceCabinet == NULL)
{ {
if (!ProcessComputerFiles(InfFile, ComputerList, &AdditionalSectionName)) if (!ProcessComputerFiles(InfFile, USetupData.ComputerList, &AdditionalSectionName))
return FALSE; return FALSE;
if (AdditionalSectionName) if (AdditionalSectionName)
@ -3905,21 +3847,21 @@ PrepareCopyPage(PINPUT_RECORD Ir)
MUIDisplayPage(PREPARE_COPY_PAGE); MUIDisplayPage(PREPARE_COPY_PAGE);
/* Create the file queue */ /* Create the file queue */
SetupFileQueue = SetupOpenFileQueue(); USetupData.SetupFileQueue = SetupOpenFileQueue();
if (SetupFileQueue == NULL) if (USetupData.SetupFileQueue == NULL)
{ {
MUIDisplayError(ERROR_COPY_QUEUE, Ir, POPUP_WAIT_ENTER); MUIDisplayError(ERROR_COPY_QUEUE, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE; return QUIT_PAGE;
} }
if (!PrepareCopyPageInfFile(SetupInf, NULL, Ir)) if (!PrepareCopyPageInfFile(USetupData.SetupInf, NULL, Ir))
{ {
/* FIXME: show an error dialog */ /* FIXME: show an error dialog */
return QUIT_PAGE; return QUIT_PAGE;
} }
/* Search for the 'Cabinets' section */ /* Search for the 'Cabinets' section */
if (!SetupFindFirstLineW(SetupInf, L"Cabinets", NULL, &CabinetsContext)) if (!SetupFindFirstLineW(USetupData.SetupInf, L"Cabinets", NULL, &CabinetsContext))
{ {
return FILE_COPY_PAGE; return FILE_COPY_PAGE;
} }
@ -4078,7 +4020,7 @@ FileCopyPage(PINPUT_RECORD Ir)
/* Create context for the copy process */ /* Create context for the copy process */
CopyContext.DestinationRootPath = USetupData.DestinationRootPath.Buffer; CopyContext.DestinationRootPath = USetupData.DestinationRootPath.Buffer;
CopyContext.InstallPath = InstallPath.Buffer; CopyContext.InstallPath = USetupData.InstallPath.Buffer;
CopyContext.TotalOperations = 0; CopyContext.TotalOperations = 0;
CopyContext.CompletedOperations = 0; CopyContext.CompletedOperations = 0;
@ -4128,12 +4070,12 @@ FileCopyPage(PINPUT_RECORD Ir)
/* Do the file copying */ /* Do the file copying */
SetupCommitFileQueueW(NULL, SetupCommitFileQueueW(NULL,
SetupFileQueue, USetupData.SetupFileQueue,
FileCopyCallback, FileCopyCallback,
&CopyContext); &CopyContext);
/* If we get here, we're done, so cleanup the queue and progress bar */ /* If we get here, we're done, so cleanup the queue and progress bar */
SetupCloseFileQueue(SetupFileQueue); SetupCloseFileQueue(USetupData.SetupFileQueue);
DestroyProgressBar(CopyContext.ProgressBar); DestroyProgressBar(CopyContext.ProgressBar);
DestroyProgressBar(CopyContext.MemoryBars[0]); DestroyProgressBar(CopyContext.MemoryBars[0]);
DestroyProgressBar(CopyContext.MemoryBars[1]); DestroyProgressBar(CopyContext.MemoryBars[1]);
@ -4199,15 +4141,15 @@ RegistryPage(PINPUT_RECORD Ir)
MUIDisplayPage(REGISTRY_PAGE); MUIDisplayPage(REGISTRY_PAGE);
Error = UpdateRegistry(SetupInf, Error = UpdateRegistry(USetupData.SetupInf,
&USetupData, &USetupData,
RepairUpdateFlag, RepairUpdateFlag,
PartitionList, PartitionList,
DestinationDriveLetter, DestinationDriveLetter,
SelectedLanguageId, SelectedLanguageId,
DisplayList, USetupData.DisplayList,
LayoutList, USetupData.LayoutList,
LanguageList, USetupData.LanguageList,
RegistryStatus); RegistryStatus);
if (Error != ERROR_SUCCESS) if (Error != ERROR_SUCCESS)
{ {
@ -4794,6 +4736,7 @@ QuitPage(PINPUT_RECORD Ir)
DestroyPartitionList(PartitionList); DestroyPartitionList(PartitionList);
PartitionList = NULL; PartitionList = NULL;
} }
TempPartition = NULL; TempPartition = NULL;
FormatState = Start; FormatState = Start;
@ -4804,41 +4747,6 @@ QuitPage(PINPUT_RECORD Ir)
FileSystemList = NULL; FileSystemList = NULL;
} }
/* Destroy the computer settings list */
if (ComputerList != NULL)
{
DestroyGenericList(ComputerList, TRUE);
ComputerList = NULL;
}
/* Destroy the display settings list */
if (DisplayList != NULL)
{
DestroyGenericList(DisplayList, TRUE);
DisplayList = NULL;
}
/* Destroy the keyboard settings list */
if (KeyboardList != NULL)
{
DestroyGenericList(KeyboardList, TRUE);
KeyboardList = NULL;
}
/* Destroy the keyboard layout list */
if (LayoutList != NULL)
{
DestroyGenericList(LayoutList, TRUE);
LayoutList = NULL;
}
/* Destroy the languages list */
if (LanguageList != NULL)
{
DestroyGenericList(LanguageList, FALSE);
LanguageList = NULL;
}
CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2)); CONSOLE_SetStatusText(MUIGetString(STRING_REBOOTCOMPUTER2));
/* Wait for maximum 15 seconds or an ENTER key before quitting */ /* Wait for maximum 15 seconds or an ENTER key before quitting */
@ -4920,7 +4828,7 @@ RunUSetup(VOID)
0, 0,
0, 0,
PnpEventThread, PnpEventThread,
&SetupInf, &USetupData.SetupInf,
&hPnpThread, &hPnpThread,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -4936,15 +4844,8 @@ RunUSetup(VOID)
return STATUS_APP_INIT_FAILURE; return STATUS_APP_INIT_FAILURE;
} }
/* Initialize global unicode strings */ /* Initialize Setup, phase 0 */
RtlInitUnicodeString(&USetupData.SourcePath, NULL); InitializeSetup(&USetupData, 0);
RtlInitUnicodeString(&USetupData.SourceRootPath, NULL);
RtlInitUnicodeString(&USetupData.SourceRootDir, NULL);
RtlInitUnicodeString(&InstallPath, NULL);
RtlInitUnicodeString(&USetupData.DestinationPath, NULL);
RtlInitUnicodeString(&USetupData.DestinationArcPath, NULL);
RtlInitUnicodeString(&USetupData.DestinationRootPath, NULL);
RtlInitUnicodeString(&USetupData.SystemRootPath, NULL);
/* Hide the cursor */ /* Hide the cursor */
CONSOLE_SetCursorType(TRUE, FALSE); CONSOLE_SetCursorType(TRUE, FALSE);
@ -5109,7 +5010,8 @@ RunUSetup(VOID)
} }
} }
SetupCloseInfFile(SetupInf); /* Setup has finished */
FinishSetup(&USetupData);
if (Page == RECOVERY_PAGE) if (Page == RECOVERY_PAGE)
RecoveryConsole(); RecoveryConsole();