Skip to content

Commit 8e53386

Browse files
committed
[SETUPLIB][REACTOS][USETUP] Don't export setup data. Make IsUnattendedSetup local to the installer.
1 parent 8d80203 commit 8e53386

File tree

10 files changed

+89
-99
lines changed

10 files changed

+89
-99
lines changed

base/setup/lib/bootsup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#include "bootcode.h"
2020
#include "fsutil.h"
2121

22-
#include "setuplib.h" // HACK for IsUnattendedSetup
22+
#include "setuplib.h"
23+
extern BOOLEAN IsUnattendedSetup; // HACK
2324

2425
#include "bootsup.h"
2526

base/setup/lib/setuplib.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ BOOLEAN IsUnattendedSetup = FALSE;
2727

2828
/* FUNCTIONS ****************************************************************/
2929

30-
VOID
30+
BOOLEAN
3131
NTAPI
3232
CheckUnattendedSetup(
3333
IN OUT PUSETUP_DATA pSetupData)
@@ -47,7 +47,7 @@ CheckUnattendedSetup(
4747
if (DoesFileExist(NULL, UnattendInfPath) == FALSE)
4848
{
4949
DPRINT("Does not exist: %S\n", UnattendInfPath);
50-
return;
50+
return IsUnattendedSetup;
5151
}
5252

5353
/* Load 'unattend.inf' from installation media */
@@ -59,7 +59,7 @@ CheckUnattendedSetup(
5959
if (UnattendInf == INVALID_HANDLE_VALUE)
6060
{
6161
DPRINT("SpInfOpenInfFile() failed\n");
62-
return;
62+
return IsUnattendedSetup;
6363
}
6464

6565
/* Open 'Unattend' section */
@@ -200,6 +200,7 @@ CheckUnattendedSetup(
200200

201201
Quit:
202202
SpInfCloseInfFile(UnattendInf);
203+
return IsUnattendedSetup;
203204
}
204205

205206
VOID

base/setup/lib/setuplib.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ extern "C" {
3030

3131
#endif
3232

33-
extern SPLIBAPI BOOLEAN IsUnattendedSetup; // HACK
34-
3533
/* NOTE: Please keep the header inclusion order! */
3634

3735
#include "errorcode.h"
@@ -167,7 +165,7 @@ typedef struct _USETUP_DATA
167165

168166
#include "substset.h"
169167

170-
VOID
168+
BOOLEAN
171169
NTAPI
172170
CheckUnattendedSetup(
173171
IN OUT PUSETUP_DATA pSetupData);

base/setup/lib/setuplib.spec

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11

2-
@ extern IsUnattendedSetup
3-
@ extern MbrPartitionTypes
4-
@ extern GptPartitionTypes
5-
62
;; fileqsup and infsupp function pointers to be initialized by the user of this library
73
;;@ extern SpFileExports
84
;;@ extern SpInfExports
95
106
;; infsupp
117
@ cdecl INF_GetDataField(ptr long ptr) ## -private
128

13-
149
;; filesup
1510
@ cdecl ConcatPathsV(ptr long long ptr)
1611
@ cdecl CombinePathsV(ptr long long ptr)
@@ -44,6 +39,9 @@
4439
@ cdecl IsPartitionActive(ptr) ## -private
4540
@ cdecl SelectPartition(ptr long long)
4641

42+
;; partinfo
43+
@ stdcall LookupPartitionTypeString(long ptr)
44+
4745
;; osdetect
4846
@ stdcall CreateNTOSInstallationsList(ptr)
4947
@ stdcall FindSubStrI(wstr wstr)

base/setup/lib/utils/partinfo.c

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
22
* PROJECT: ReactOS Setup Library
3-
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
3+
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
44
* PURPOSE: MBR and GPT Partition types
5-
* COPYRIGHT: Copyright 2018-2020 Hermes Belusca-Maito
5+
* COPYRIGHT: Copyright 2018-2025 Hermès Bélusca-Maïto <[email protected]>
66
*/
77

88
#include "precomp.h"
99
#include "partinfo.h"
1010

11-
/* MBR PARTITION TYPES ******************************************************/
11+
/* MBR PARTITION TYPES *******************************************************/
1212

1313
/*
1414
* This partition type list is based from:
@@ -42,8 +42,14 @@
4242
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4343
*/
4444

45+
typedef struct _MBR_PARTITION_TYPE
46+
{
47+
UCHAR Type;
48+
PCSTR Description;
49+
} MBR_PARTITION_TYPE, *PMBR_PARTITION_TYPE;
50+
4551
/* Known MBR partition type codes and descriptions */
46-
const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES] =
52+
const MBR_PARTITION_TYPE MbrPartitionTypes[] =
4753
{
4854
{ 0x00, "(Empty)" }, // PARTITION_ENTRY_UNUSED
4955
{ 0x01, "FAT12" }, // PARTITION_FAT_12
@@ -201,7 +207,7 @@ const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES] =
201207
};
202208

203209

204-
/* GPT PARTITION TYPES ******************************************************/
210+
/* GPT PARTITION TYPES *******************************************************/
205211

206212
#define GUID_CONST(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
207213
{ 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
267273
* https://www.magnumdb.com/search?q=PARTITION_*
268274
*/
269275

276+
typedef struct _GPT_PARTITION_TYPE
277+
{
278+
GUID Guid;
279+
PCSTR Description;
280+
} GPT_PARTITION_TYPE, *PGPT_PARTITION_TYPE;
281+
270282
/* Known GPT partition type GUIDs and descriptions */
271-
const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES] =
283+
const GPT_PARTITION_TYPE GptPartitionTypes[] =
272284
{
273285
/*
274286
* EFI specification
@@ -784,4 +796,44 @@ const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES] =
784796
"ArcaOS Type 1" },
785797
};
786798

799+
800+
/* PARTITION TYPES LOOKUP ****************************************************/
801+
802+
PCSTR
803+
NTAPI
804+
LookupPartitionTypeString(
805+
_In_ PARTITION_STYLE PartitionStyle,
806+
_In_ PVOID PartitionType)
807+
{
808+
UINT i;
809+
810+
/* Do the table lookup */
811+
if (PartitionStyle == PARTITION_STYLE_MBR)
812+
{
813+
for (i = 0; i < _countof(MbrPartitionTypes); ++i)
814+
{
815+
if (*(PUCHAR)PartitionType == MbrPartitionTypes[i].Type)
816+
{
817+
return MbrPartitionTypes[i].Description;
818+
}
819+
}
820+
}
821+
#if 0 // TODO: GPT support!
822+
else if (PartitionStyle == PARTITION_STYLE_GPT)
823+
{
824+
for (i = 0; i < _countof(GptPartitionTypes); ++i)
825+
{
826+
if (IsEqualPartitionType((PGUID)PartitionType,
827+
&GptPartitionTypes[i].Guid))
828+
{
829+
return GptPartitionTypes[i].Description;
830+
}
831+
}
832+
}
833+
#endif
834+
835+
/* The partition type is unknown */
836+
return NULL;
837+
}
838+
787839
/* EOF */

base/setup/lib/utils/partinfo.h

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
/*
22
* PROJECT: ReactOS Setup Library
3-
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
3+
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
44
* PURPOSE: MBR and GPT Partition types
5-
* COPYRIGHT: Copyright 2018-2020 Hermes Belusca-Maito
5+
* COPYRIGHT: Copyright 2018-2025 Hermès Bélusca-Maïto <[email protected]>
66
*/
77

88
#pragma once
99

10-
/* MBR PARTITION TYPES ******************************************************/
11-
12-
typedef struct _MBR_PARTITION_TYPE
13-
{
14-
UCHAR Type;
15-
PCSTR Description;
16-
} MBR_PARTITION_TYPE, *PMBR_PARTITION_TYPE;
17-
18-
#define NUM_MBR_PARTITION_TYPES 153
19-
extern SPLIBAPI const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES];
20-
21-
/* GPT PARTITION TYPES ******************************************************/
22-
23-
typedef struct _GPT_PARTITION_TYPE
24-
{
25-
GUID Guid;
26-
PCSTR Description;
27-
} GPT_PARTITION_TYPE, *PGPT_PARTITION_TYPE;
28-
29-
#define NUM_GPT_PARTITION_TYPES 177
30-
extern SPLIBAPI const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES];
10+
PCSTR
11+
NTAPI
12+
LookupPartitionTypeString(
13+
_In_ PARTITION_STYLE PartitionStyle,
14+
_In_ PVOID PartitionType);
3115

3216
/* EOF */

base/setup/reactos/drivepage.c

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -896,36 +896,14 @@ GetPartitionTypeString(
896896
}
897897
else
898898
{
899-
UINT i;
900-
901899
/* Do the table lookup */
902-
if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_MBR)
903-
{
904-
for (i = 0; i < ARRAYSIZE(MbrPartitionTypes); ++i)
905-
{
906-
if (PartEntry->PartitionType == MbrPartitionTypes[i].Type)
907-
{
908-
StringCchCopyA(strBuffer, cchBuffer,
909-
MbrPartitionTypes[i].Description);
910-
return;
911-
}
912-
}
913-
}
914-
#if 0 // TODO: GPT support!
915-
else if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
900+
PCSTR Description = LookupPartitionTypeString(PartEntry->DiskEntry->DiskStyle,
901+
&PartEntry->PartitionType);
902+
if (Description)
916903
{
917-
for (i = 0; i < ARRAYSIZE(GptPartitionTypes); ++i)
918-
{
919-
if (IsEqualPartitionType(PartEntry->PartitionType,
920-
GptPartitionTypes[i].Guid))
921-
{
922-
StringCchCopyA(strBuffer, cchBuffer,
923-
GptPartitionTypes[i].Description);
924-
return;
925-
}
926-
}
904+
StringCchCopyA(strBuffer, cchBuffer, Description);
905+
return;
927906
}
928-
#endif
929907

930908
/* We are here because the partition type is unknown */
931909
if (cchBuffer > 0) *strBuffer = '\0';

base/setup/reactos/reactos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
HANDLE ProcessHeap;
4141
SETUPDATA SetupData;
42+
static BOOLEAN IsUnattendedSetup;
4243

4344
/* The partition where to perform the installation */
4445
PPARTENTRY InstallPartition = NULL;
@@ -2880,8 +2881,7 @@ _tWinMain(HINSTANCE hInst,
28802881
}
28812882

28822883
/* Retrieve any supplemental options from the unattend file */
2883-
CheckUnattendedSetup(&SetupData.USetupData);
2884-
SetupData.bUnattend = IsUnattendedSetup; // FIXME :-)
2884+
SetupData.bUnattend = IsUnattendedSetup = CheckUnattendedSetup(&SetupData.USetupData);
28852885

28862886
/* Load extra setup data (HW lists etc...) */
28872887
if (!LoadSetupData(&SetupData))

base/setup/usetup/partlist.c

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,14 @@ GetPartitionTypeString(
4949
}
5050
else
5151
{
52-
UINT i;
53-
5452
/* Do the table lookup */
55-
if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_MBR)
56-
{
57-
for (i = 0; i < ARRAYSIZE(MbrPartitionTypes); ++i)
58-
{
59-
if (PartEntry->PartitionType == MbrPartitionTypes[i].Type)
60-
{
61-
RtlStringCchCopyA(strBuffer, cchBuffer,
62-
MbrPartitionTypes[i].Description);
63-
return;
64-
}
65-
}
66-
}
67-
#if 0 // TODO: GPT support!
68-
else if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
53+
PCSTR Description = LookupPartitionTypeString(PartEntry->DiskEntry->DiskStyle,
54+
&PartEntry->PartitionType);
55+
if (Description)
6956
{
70-
for (i = 0; i < ARRAYSIZE(GptPartitionTypes); ++i)
71-
{
72-
if (IsEqualPartitionType(PartEntry->PartitionType,
73-
GptPartitionTypes[i].Guid))
74-
{
75-
RtlStringCchCopyA(strBuffer, cchBuffer,
76-
GptPartitionTypes[i].Description);
77-
return;
78-
}
79-
}
57+
RtlStringCchCopyA(strBuffer, cchBuffer, Description);
58+
return;
8059
}
81-
#endif
8260

8361
/* We are here because the partition type is unknown */
8462
if (cchBuffer > 0) *strBuffer = '\0';

base/setup/usetup/usetup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
HANDLE ProcessHeap;
4343

4444
static USETUP_DATA USetupData;
45+
static BOOLEAN IsUnattendedSetup;
4546

4647
/* The partition where to perform the installation */
4748
static PPARTENTRY InstallPartition = NULL;
@@ -604,8 +605,7 @@ SetupStartPage(PINPUT_RECORD Ir)
604605
if (WaitNoPendingInstallEvents(NULL) != STATUS_WAIT_0)
605606
DPRINT1("WaitNoPendingInstallEvents() failed to wait!\n");
606607

607-
CheckUnattendedSetup(&USetupData);
608-
608+
IsUnattendedSetup = CheckUnattendedSetup(&USetupData);
609609
if (IsUnattendedSetup)
610610
{
611611
// TODO: Read options from inf

0 commit comments

Comments
 (0)