[SETUPLIB] Move the initialization of other default values into InitializeSetup()

This commit is contained in:
Hermès Bélusca-Maïto 2023-12-16 12:52:39 +01:00
parent c9c5fd1a18
commit 9b9065df52
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -104,7 +104,7 @@ CheckUnattendedSetup(
INF_FreeData(Value);
/* Search for 'DestinationDiskNumber' in the 'Unattend' section */
/* Search for 'DestinationDiskNumber' */
if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context))
{
DPRINT("SpInfFindFirstLine() failed for key 'DestinationDiskNumber'\n");
@ -119,7 +119,7 @@ CheckUnattendedSetup(
pSetupData->DestinationDiskNumber = (LONG)IntValue;
/* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
/* Search for 'DestinationPartitionNumber' */
if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
{
DPRINT("SpInfFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
@ -134,56 +134,47 @@ CheckUnattendedSetup(
pSetupData->DestinationPartitionNumber = (LONG)IntValue;
/* Search for 'InstallationDirectory' in the 'Unattend' section (optional) */
/* Search for 'InstallationDirectory' (optional) */
if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"InstallationDirectory", &Context))
{
/* Get pointer 'InstallationDirectory' key */
if (!INF_GetData(&Context, NULL, &Value))
if (INF_GetData(&Context, NULL, &Value))
{
RtlStringCchCopyW(pSetupData->InstallationDirectory,
ARRAYSIZE(pSetupData->InstallationDirectory),
Value);
INF_FreeData(Value);
}
else
{
DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
goto Quit;
}
RtlStringCchCopyW(pSetupData->InstallationDirectory,
ARRAYSIZE(pSetupData->InstallationDirectory),
Value);
INF_FreeData(Value);
}
IsUnattendedSetup = TRUE;
DPRINT("Running unattended setup\n");
/* Search for 'BootLoaderLocation' in the 'Unattend' section */
pSetupData->BootLoaderLocation = 2; // Default to "system partition"
/* Search for 'BootLoaderLocation' (optional) */
if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"BootLoaderLocation", &Context))
{
if (SpInfGetIntField(&Context, 1, &IntValue))
{
pSetupData->BootLoaderLocation = IntValue;
}
}
/* Search for 'FormatPartition' in the 'Unattend' section */
pSetupData->FormatPartition = 0;
/* Search for 'FormatPartition' (optional) */
if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FormatPartition", &Context))
{
if (SpInfGetIntField(&Context, 1, &IntValue))
{
pSetupData->FormatPartition = IntValue;
}
}
pSetupData->AutoPartition = 0;
/* Search for 'AutoPartition' (optional) */
if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"AutoPartition", &Context))
{
if (SpInfGetIntField(&Context, 1, &IntValue))
{
pSetupData->AutoPartition = IntValue;
}
}
/* Search for LocaleID in the 'Unattend' section */
/* Search for 'LocaleID' (optional) */
if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"LocaleID", &Context))
{
if (INF_GetData(&Context, NULL, &Value))
@ -193,17 +184,14 @@ CheckUnattendedSetup(
ARRAYSIZE(pSetupData->LocaleID),
L"%08lx", Id);
INF_FreeData(Value);
}
}
}
/* Search for FsType in the 'Unattend' section */
pSetupData->FsType = 0;
/* Search for 'FsType' (optional) */
if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FsType", &Context))
{
if (SpInfGetIntField(&Context, 1, &IntValue))
{
pSetupData->FsType = IntValue;
}
}
Quit:
@ -1021,6 +1009,14 @@ InitializeSetup(
DPRINT1("SourceRootPath (1): '%wZ'\n", &pSetupData->SourceRootPath);
DPRINT1("SourceRootDir (1): '%wZ'\n", &pSetupData->SourceRootDir);
/* Set up default values */
pSetupData->DestinationDiskNumber = 0;
pSetupData->DestinationPartitionNumber = 1;
pSetupData->BootLoaderLocation = 2; // Default to "System partition"
pSetupData->FormatPartition = 0;
pSetupData->AutoPartition = 0;
pSetupData->FsType = 0;
/* Load 'txtsetup.sif' from the installation media */
Error = LoadSetupInf(pSetupData);
if (Error != ERROR_SUCCESS)