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