https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8e53386de965211e954e2a944fbca35d47edad5a
commit 8e53386de965211e954e2a944fbca35d47edad5a Author: Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org> AuthorDate: Fri Mar 14 13:52:22 2025 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org> CommitDate: Fri Mar 14 21:38:39 2025 +0100 [SETUPLIB][REACTOS][USETUP] Don't export setup data. Make IsUnattendedSetup local to the installer. --- base/setup/lib/bootsup.c | 3 +- base/setup/lib/setuplib.c | 7 +++-- base/setup/lib/setuplib.h | 4 +-- base/setup/lib/setuplib.spec | 8 ++---- base/setup/lib/utils/partinfo.c | 64 +++++++++++++++++++++++++++++++++++++---- base/setup/lib/utils/partinfo.h | 30 +++++-------------- base/setup/reactos/drivepage.c | 32 ++++----------------- base/setup/reactos/reactos.c | 4 +-- base/setup/usetup/partlist.c | 32 ++++----------------- base/setup/usetup/usetup.c | 4 +-- 10 files changed, 89 insertions(+), 99 deletions(-) diff --git a/base/setup/lib/bootsup.c b/base/setup/lib/bootsup.c index 1ee5f8c133d..aa0ed8f3194 100644 --- a/base/setup/lib/bootsup.c +++ b/base/setup/lib/bootsup.c @@ -19,7 +19,8 @@ #include "bootcode.h" #include "fsutil.h" -#include "setuplib.h" // HACK for IsUnattendedSetup +#include "setuplib.h" +extern BOOLEAN IsUnattendedSetup; // HACK #include "bootsup.h" diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c index 862c9020719..a4b80bd2a13 100644 --- a/base/setup/lib/setuplib.c +++ b/base/setup/lib/setuplib.c @@ -27,7 +27,7 @@ BOOLEAN IsUnattendedSetup = FALSE; /* FUNCTIONS ****************************************************************/ -VOID +BOOLEAN NTAPI CheckUnattendedSetup( IN OUT PUSETUP_DATA pSetupData) @@ -47,7 +47,7 @@ CheckUnattendedSetup( if (DoesFileExist(NULL, UnattendInfPath) == FALSE) { DPRINT("Does not exist: %S\n", UnattendInfPath); - return; + return IsUnattendedSetup; } /* Load 'unattend.inf' from installation media */ @@ -59,7 +59,7 @@ CheckUnattendedSetup( if (UnattendInf == INVALID_HANDLE_VALUE) { DPRINT("SpInfOpenInfFile() failed\n"); - return; + return IsUnattendedSetup; } /* Open 'Unattend' section */ @@ -200,6 +200,7 @@ CheckUnattendedSetup( Quit: SpInfCloseInfFile(UnattendInf); + return IsUnattendedSetup; } VOID diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h index 3b513f7d2b8..d0b49a7757c 100644 --- a/base/setup/lib/setuplib.h +++ b/base/setup/lib/setuplib.h @@ -30,8 +30,6 @@ extern "C" { #endif -extern SPLIBAPI BOOLEAN IsUnattendedSetup; // HACK - /* NOTE: Please keep the header inclusion order! */ #include "errorcode.h" @@ -167,7 +165,7 @@ typedef struct _USETUP_DATA #include "substset.h" -VOID +BOOLEAN NTAPI CheckUnattendedSetup( IN OUT PUSETUP_DATA pSetupData); diff --git a/base/setup/lib/setuplib.spec b/base/setup/lib/setuplib.spec index a2809a06b0a..acfaa4ce680 100644 --- a/base/setup/lib/setuplib.spec +++ b/base/setup/lib/setuplib.spec @@ -1,8 +1,4 @@ -@ extern IsUnattendedSetup -@ extern MbrPartitionTypes -@ extern GptPartitionTypes - ;; fileqsup and infsupp function pointers to be initialized by the user of this library ;;@ extern SpFileExports ;;@ extern SpInfExports @@ -10,7 +6,6 @@ ;; infsupp @ cdecl INF_GetDataField(ptr long ptr) ## -private - ;; filesup @ cdecl ConcatPathsV(ptr long long ptr) @ cdecl CombinePathsV(ptr long long ptr) @@ -44,6 +39,9 @@ @ cdecl IsPartitionActive(ptr) ## -private @ cdecl SelectPartition(ptr long long) +;; partinfo +@ stdcall LookupPartitionTypeString(long ptr) + ;; osdetect @ stdcall CreateNTOSInstallationsList(ptr) @ stdcall FindSubStrI(wstr wstr) diff --git a/base/setup/lib/utils/partinfo.c b/base/setup/lib/utils/partinfo.c index 064b7dc633e..6f813b97c51 100644 --- a/base/setup/lib/utils/partinfo.c +++ b/base/setup/lib/utils/partinfo.c @@ -1,14 +1,14 @@ /* * PROJECT: ReactOS Setup Library - * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) * PURPOSE: MBR and GPT Partition types - * COPYRIGHT: Copyright 2018-2020 Hermes Belusca-Maito + * COPYRIGHT: Copyright 2018-2025 Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org> */ #include "precomp.h" #include "partinfo.h" -/* MBR PARTITION TYPES ******************************************************/ +/* MBR PARTITION TYPES *******************************************************/ /* * This partition type list is based from: @@ -42,8 +42,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +typedef struct _MBR_PARTITION_TYPE +{ + UCHAR Type; + PCSTR Description; +} MBR_PARTITION_TYPE, *PMBR_PARTITION_TYPE; + /* Known MBR partition type codes and descriptions */ -const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES] = +const MBR_PARTITION_TYPE MbrPartitionTypes[] = { { 0x00, "(Empty)" }, // PARTITION_ENTRY_UNUSED { 0x01, "FAT12" }, // PARTITION_FAT_12 @@ -201,7 +207,7 @@ const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES] = }; -/* GPT PARTITION TYPES ******************************************************/ +/* GPT PARTITION TYPES *******************************************************/ #define GUID_CONST(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } @@ -267,8 +273,14 @@ DEFINE_GUID(PARTITION_DPP_GUID, 0x57434F53, 0x94CB, 0x43F0, 0xA5, 0 * https://www.magnumdb.com/search?q=PARTITION_* */ +typedef struct _GPT_PARTITION_TYPE +{ + GUID Guid; + PCSTR Description; +} GPT_PARTITION_TYPE, *PGPT_PARTITION_TYPE; + /* Known GPT partition type GUIDs and descriptions */ -const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES] = +const GPT_PARTITION_TYPE GptPartitionTypes[] = { /* * EFI specification @@ -784,4 +796,44 @@ const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES] = "ArcaOS Type 1" }, }; + +/* PARTITION TYPES LOOKUP ****************************************************/ + +PCSTR +NTAPI +LookupPartitionTypeString( + _In_ PARTITION_STYLE PartitionStyle, + _In_ PVOID PartitionType) +{ + UINT i; + + /* Do the table lookup */ + if (PartitionStyle == PARTITION_STYLE_MBR) + { + for (i = 0; i < _countof(MbrPartitionTypes); ++i) + { + if (*(PUCHAR)PartitionType == MbrPartitionTypes[i].Type) + { + return MbrPartitionTypes[i].Description; + } + } + } +#if 0 // TODO: GPT support! + else if (PartitionStyle == PARTITION_STYLE_GPT) + { + for (i = 0; i < _countof(GptPartitionTypes); ++i) + { + if (IsEqualPartitionType((PGUID)PartitionType, + &GptPartitionTypes[i].Guid)) + { + return GptPartitionTypes[i].Description; + } + } + } +#endif + + /* The partition type is unknown */ + return NULL; +} + /* EOF */ diff --git a/base/setup/lib/utils/partinfo.h b/base/setup/lib/utils/partinfo.h index dac7af89158..774a39982b3 100644 --- a/base/setup/lib/utils/partinfo.h +++ b/base/setup/lib/utils/partinfo.h @@ -1,32 +1,16 @@ /* * PROJECT: ReactOS Setup Library - * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) * PURPOSE: MBR and GPT Partition types - * COPYRIGHT: Copyright 2018-2020 Hermes Belusca-Maito + * COPYRIGHT: Copyright 2018-2025 Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org> */ #pragma once -/* MBR PARTITION TYPES ******************************************************/ - -typedef struct _MBR_PARTITION_TYPE -{ - UCHAR Type; - PCSTR Description; -} MBR_PARTITION_TYPE, *PMBR_PARTITION_TYPE; - -#define NUM_MBR_PARTITION_TYPES 153 -extern SPLIBAPI const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES]; - -/* GPT PARTITION TYPES ******************************************************/ - -typedef struct _GPT_PARTITION_TYPE -{ - GUID Guid; - PCSTR Description; -} GPT_PARTITION_TYPE, *PGPT_PARTITION_TYPE; - -#define NUM_GPT_PARTITION_TYPES 177 -extern SPLIBAPI const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES]; +PCSTR +NTAPI +LookupPartitionTypeString( + _In_ PARTITION_STYLE PartitionStyle, + _In_ PVOID PartitionType); /* EOF */ diff --git a/base/setup/reactos/drivepage.c b/base/setup/reactos/drivepage.c index dc4fc64cfb5..274aa069ac3 100644 --- a/base/setup/reactos/drivepage.c +++ b/base/setup/reactos/drivepage.c @@ -896,36 +896,14 @@ GetPartitionTypeString( } else { - UINT i; - /* Do the table lookup */ - if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_MBR) - { - for (i = 0; i < ARRAYSIZE(MbrPartitionTypes); ++i) - { - if (PartEntry->PartitionType == MbrPartitionTypes[i].Type) - { - StringCchCopyA(strBuffer, cchBuffer, - MbrPartitionTypes[i].Description); - return; - } - } - } -#if 0 // TODO: GPT support! - else if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_GPT) + PCSTR Description = LookupPartitionTypeString(PartEntry->DiskEntry->DiskStyle, + &PartEntry->PartitionType); + if (Description) { - for (i = 0; i < ARRAYSIZE(GptPartitionTypes); ++i) - { - if (IsEqualPartitionType(PartEntry->PartitionType, - GptPartitionTypes[i].Guid)) - { - StringCchCopyA(strBuffer, cchBuffer, - GptPartitionTypes[i].Description); - return; - } - } + StringCchCopyA(strBuffer, cchBuffer, Description); + return; } -#endif /* We are here because the partition type is unknown */ if (cchBuffer > 0) *strBuffer = '\0'; diff --git a/base/setup/reactos/reactos.c b/base/setup/reactos/reactos.c index 35a68250ff6..d84d3da37a6 100644 --- a/base/setup/reactos/reactos.c +++ b/base/setup/reactos/reactos.c @@ -39,6 +39,7 @@ HANDLE ProcessHeap; SETUPDATA SetupData; +static BOOLEAN IsUnattendedSetup; /* The partition where to perform the installation */ PPARTENTRY InstallPartition = NULL; @@ -2880,8 +2881,7 @@ _tWinMain(HINSTANCE hInst, } /* Retrieve any supplemental options from the unattend file */ - CheckUnattendedSetup(&SetupData.USetupData); - SetupData.bUnattend = IsUnattendedSetup; // FIXME :-) + SetupData.bUnattend = IsUnattendedSetup = CheckUnattendedSetup(&SetupData.USetupData); /* Load extra setup data (HW lists etc...) */ if (!LoadSetupData(&SetupData)) diff --git a/base/setup/usetup/partlist.c b/base/setup/usetup/partlist.c index a7eb50a8b59..7d41bea9c3c 100644 --- a/base/setup/usetup/partlist.c +++ b/base/setup/usetup/partlist.c @@ -49,36 +49,14 @@ GetPartitionTypeString( } else { - UINT i; - /* Do the table lookup */ - if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_MBR) - { - for (i = 0; i < ARRAYSIZE(MbrPartitionTypes); ++i) - { - if (PartEntry->PartitionType == MbrPartitionTypes[i].Type) - { - RtlStringCchCopyA(strBuffer, cchBuffer, - MbrPartitionTypes[i].Description); - return; - } - } - } -#if 0 // TODO: GPT support! - else if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_GPT) + PCSTR Description = LookupPartitionTypeString(PartEntry->DiskEntry->DiskStyle, + &PartEntry->PartitionType); + if (Description) { - for (i = 0; i < ARRAYSIZE(GptPartitionTypes); ++i) - { - if (IsEqualPartitionType(PartEntry->PartitionType, - GptPartitionTypes[i].Guid)) - { - RtlStringCchCopyA(strBuffer, cchBuffer, - GptPartitionTypes[i].Description); - return; - } - } + RtlStringCchCopyA(strBuffer, cchBuffer, Description); + return; } -#endif /* We are here because the partition type is unknown */ if (cchBuffer > 0) *strBuffer = '\0'; diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index 13b4238aa46..d3c62e6b490 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -42,6 +42,7 @@ HANDLE ProcessHeap; static USETUP_DATA USetupData; +static BOOLEAN IsUnattendedSetup; /* The partition where to perform the installation */ static PPARTENTRY InstallPartition = NULL; @@ -604,8 +605,7 @@ SetupStartPage(PINPUT_RECORD Ir) if (WaitNoPendingInstallEvents(NULL) != STATUS_WAIT_0) DPRINT1("WaitNoPendingInstallEvents() failed to wait!\n"); - CheckUnattendedSetup(&USetupData); - + IsUnattendedSetup = CheckUnattendedSetup(&USetupData); if (IsUnattendedSetup) { // TODO: Read options from inf