xref: /reactos/base/setup/lib/setuplib.h (revision 5140a990)
1 /*
2  * PROJECT:     ReactOS Setup Library
3  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE:     Public header
5  * COPYRIGHT:   Copyright 2017-2018 Hermes Belusca-Maito
6  */
7 
8 #pragma once
9 
10 /* INCLUDES *****************************************************************/
11 
12 /* Needed PSDK headers when using this library */
13 #if 0
14 
15 #define WIN32_NO_STATUS
16 #define _INC_WINDOWS
17 #define COM_NO_WINDOWS_H
18 
19 #include <winxxx.h>
20 
21 #endif
22 
23 /* NOTE: Please keep the header inclusion order! */
24 
25 extern HANDLE ProcessHeap;
26 
27 #include "errorcode.h"
28 #include "spapisup/fileqsup.h"
29 #include "spapisup/infsupp.h"
30 #include "utils/linklist.h"
31 #include "utils/ntverrsrc.h"
32 // #include "utils/arcname.h"
33 #include "utils/bldrsup.h"
34 #include "utils/filesup.h"
35 #include "utils/fsrec.h"
36 #include "utils/genlist.h"
37 #include "utils/inicache.h"
38 #include "utils/partinfo.h"
39 #include "utils/partlist.h"
40 #include "utils/arcname.h"
41 #include "utils/osdetect.h"
42 #include "utils/regutil.h"
43 #include "bootcode.h"
44 #include "fsutil.h"
45 #include "bootsup.h"
46 #include "registry.h"
47 #include "mui.h"
48 #include "settings.h"
49 
50 // #include "install.h" // See at the end...
51 
52 
53 /* DEFINES ******************************************************************/
54 
55 #define KB ((ULONGLONG)1024)
56 #define MB (KB*KB)
57 #define GB (KB*KB*KB)
58 // #define TB (KB*KB*KB*KB)
59 // #define PB (KB*KB*KB*KB*KB)
60 
61 
62 /* TYPEDEFS *****************************************************************/
63 
64 struct _USETUP_DATA;
65 
66 typedef VOID
67 (__cdecl *PSETUP_ERROR_ROUTINE)(IN struct _USETUP_DATA*, ...);
68 
69 typedef enum _ARCHITECTURE_TYPE
70 {
71     ARCH_PcAT,      //< Standard BIOS-based PC-AT
72     ARCH_NEC98x86,  //< NEC PC-98
73     ARCH_Xbox,      //< Original Xbox
74     ARCH_Arc,       //< ARC-based (MIPS, SGI)
75     ARCH_Efi,       //< EFI and UEFI
76 // Place other architectures supported by the Setup below.
77 } ARCHITECTURE_TYPE;
78 
79 typedef struct _USETUP_DATA
80 {
81 /* Error handling *****/
82     ERROR_NUMBER LastErrorNumber;
83     PSETUP_ERROR_ROUTINE ErrorRoutine;
84 
85 /* Setup INFs *****/
86     HINF SetupInf;
87 
88 /* Installation *****/
89     PVOID SetupFileQueue; // HSPFILEQ
90 
91 /* SOURCE Paths *****/
92     UNICODE_STRING SourceRootPath;
93     UNICODE_STRING SourceRootDir;
94     UNICODE_STRING SourcePath;
95 
96 /* DESTINATION Paths *****/
97     /*
98      * Path to the system partition, where the boot manager resides.
99      * On x86 PCs, this is usually the active partition.
100      * On ARC, (u)EFI, ... platforms, this is a dedicated partition.
101      *
102      * For more information, see:
103      * https://en.wikipedia.org/wiki/System_partition_and_boot_partition
104      * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/boot-and-system-volumes.html
105      * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/arc-boot-process.html
106      * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/efi-boot-process.html
107      * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-system-volume.html
108      * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-boot-volume.html
109      */
110     UNICODE_STRING SystemRootPath;
111 
112     /* Path to the installation directory inside the ReactOS boot partition */
113     UNICODE_STRING DestinationArcPath;  /** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
114     UNICODE_STRING DestinationPath;     /** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
115     UNICODE_STRING DestinationRootPath;
116 
117     // FIXME: This is only temporary!! Must be removed later!
118     UNICODE_STRING InstallPath;
119 
120     LONG DestinationDiskNumber;
121     LONG DestinationPartitionNumber;
122 
123     LONG BootLoaderLocation;
124     LONG FormatPartition;
125     LONG AutoPartition;
126     LONG FsType;
127 
128 /* Settings lists *****/
129     PGENERIC_LIST ComputerList;
130     PGENERIC_LIST DisplayList;
131     PGENERIC_LIST KeyboardList;
132     PGENERIC_LIST LayoutList;
133     PGENERIC_LIST LanguageList;
134 
135 /* Settings *****/
136     ARCHITECTURE_TYPE ArchType; //< Target architecture (MachineType)
137     PCWSTR ComputerType;
138     PCWSTR DisplayType;
139     // PCWSTR KeyboardDriver;
140     // PCWSTR MouseDriver;
141     PCWSTR LayoutId; // DefaultKBLayout
142 
143 /* Other stuff *****/
144     WCHAR LocaleID[9];
145     LANGID LanguageId;
146 
147     ULONG RequiredPartitionDiskSpace;
148     WCHAR InstallationDirectory[MAX_PATH];
149 } USETUP_DATA, *PUSETUP_DATA;
150 
151 
152 #include "install.h"
153 
154 
155 // HACK!!
156 extern BOOLEAN IsUnattendedSetup;
157 
158 
159 /* FUNCTIONS ****************************************************************/
160 
161 #include "substset.h"
162 
163 VOID
164 CheckUnattendedSetup(
165     IN OUT PUSETUP_DATA pSetupData);
166 
167 VOID
168 InstallSetupInfFile(
169     IN OUT PUSETUP_DATA pSetupData);
170 
171 NTSTATUS
172 GetSourcePaths(
173     OUT PUNICODE_STRING SourcePath,
174     OUT PUNICODE_STRING SourceRootPath,
175     OUT PUNICODE_STRING SourceRootDir);
176 
177 ERROR_NUMBER
178 LoadSetupInf(
179     IN OUT PUSETUP_DATA pSetupData);
180 
181 #define ERROR_SYSTEM_PARTITION_NOT_FOUND    (ERROR_LAST_ERROR_CODE + 1)
182 
183 BOOLEAN
184 InitSystemPartition(
185     /**/_In_ PPARTLIST PartitionList,       /* HACK HACK! */
186     /**/_In_ PPARTENTRY InstallPartition,   /* HACK HACK! */
187     /**/_Out_ PPARTENTRY* pSystemPartition, /* HACK HACK! */
188     _In_opt_ PFSVOL_CALLBACK FsVolCallback,
189     _In_opt_ PVOID Context);
190 
191 /**
192  * @brief
193  * Defines the class of characters valid for the installation directory.
194  *
195  * The valid characters are: ASCII alphanumericals (a-z, A-Z, 0-9),
196  * and: '.', '\\', '-', '_' . Spaces are not allowed.
197  **/
198 #define IS_VALID_INSTALL_PATH_CHAR(c) \
199     (isalnum(c) || (c) == L'.' || (c) == L'\\' || (c) == L'-' || (c) == L'_')
200 
201 BOOLEAN
202 IsValidInstallDirectory(
203     _In_ PCWSTR InstallDir);
204 
205 NTSTATUS
206 InitDestinationPaths(
207     _Inout_ PUSETUP_DATA pSetupData,
208     _In_ PCWSTR InstallationDir,
209     _In_ PVOLENTRY Volume);
210 
211 // NTSTATUS
212 ERROR_NUMBER
213 InitializeSetup(
214     IN OUT PUSETUP_DATA pSetupData,
215     IN ULONG InitPhase);
216 
217 VOID
218 FinishSetup(
219     IN OUT PUSETUP_DATA pSetupData);
220 
221 
222 typedef enum _REGISTRY_STATUS
223 {
224     Success = 0,
225     RegHiveUpdate,
226     ImportRegHive,
227     DisplaySettingsUpdate,
228     LocaleSettingsUpdate,
229     KeybLayouts,
230     KeybSettingsUpdate,
231     CodePageInfoUpdate,
232 } REGISTRY_STATUS;
233 
234 typedef VOID
235 (__cdecl *PREGISTRY_STATUS_ROUTINE)(IN REGISTRY_STATUS, ...);
236 
237 ERROR_NUMBER
238 UpdateRegistry(
239     IN OUT PUSETUP_DATA pSetupData,
240     /**/IN BOOLEAN RepairUpdateFlag,     /* HACK HACK! */
241     /**/IN PPARTLIST PartitionList,      /* HACK HACK! */
242     /**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */
243     /**/IN PCWSTR SelectedLanguageId,    /* HACK HACK! */
244     IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL,
245     IN PFONTSUBSTSETTINGS SubstSettings OPTIONAL);
246 
247 /* EOF */
248