[SETUPLIB][USETUP] Add support for setup error handling.
[reactos.git] / base / setup / lib / setuplib.h
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 "bootsup.h"
35 #include "utils/filesup.h"
36 #include "fsutil.h"
37 #include "utils/genlist.h"
38 #include "utils/inicache.h"
39 #include "utils/partlist.h"
40 #include "utils/arcname.h"
41 #include "utils/osdetect.h"
42 #include "utils/regutil.h"
43 #include "registry.h"
44 #include "mui.h"
45 #include "settings.h"
46
47
48 /* DEFINES ******************************************************************/
49
50 #define KB ((ULONGLONG)1024)
51 #define MB (KB*KB)
52 #define GB (KB*KB*KB)
53 // #define TB (KB*KB*KB*KB)
54 // #define PB (KB*KB*KB*KB*KB)
55
56
57 /* TYPEDEFS *****************************************************************/
58
59 struct _USETUP_DATA;
60
61 typedef VOID
62 (__cdecl *PSETUP_ERROR_ROUTINE)(IN struct _USETUP_DATA*, ...);
63
64 typedef struct _USETUP_DATA
65 {
66 /* Error handling *****/
67 ERROR_NUMBER LastErrorNumber;
68 PSETUP_ERROR_ROUTINE ErrorRoutine;
69
70 /* Setup INFs *****/
71 HINF SetupInf;
72
73 /* Installation *****/
74 PVOID SetupFileQueue; // HSPFILEQ
75
76 /* SOURCE Paths *****/
77 UNICODE_STRING SourceRootPath;
78 UNICODE_STRING SourceRootDir;
79 UNICODE_STRING SourcePath;
80
81 /* DESTINATION Paths *****/
82 /*
83 * Path to the system partition, where the boot manager resides.
84 * On x86 PCs, this is usually the active partition.
85 * On ARC, (u)EFI, ... platforms, this is a dedicated partition.
86 *
87 * For more information, see:
88 * https://en.wikipedia.org/wiki/System_partition_and_boot_partition
89 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/boot-and-system-volumes.html
90 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/arc-boot-process.html
91 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/efi-boot-process.html
92 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-system-volume.html
93 * http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-boot-volume.html
94 */
95 UNICODE_STRING SystemRootPath;
96
97 /* Path to the installation directory inside the ReactOS boot partition */
98 UNICODE_STRING DestinationArcPath; /** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
99 UNICODE_STRING DestinationPath; /** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
100 UNICODE_STRING DestinationRootPath;
101
102 // FIXME: This is only temporary!! Must be removed later!
103 UNICODE_STRING InstallPath;
104
105 LONG DestinationDiskNumber;
106 LONG DestinationPartitionNumber;
107
108 LONG MBRInstallType;
109 LONG FormatPartition;
110 LONG AutoPartition;
111
112 /* Settings lists *****/
113 PGENERIC_LIST ComputerList;
114 PGENERIC_LIST DisplayList;
115 PGENERIC_LIST KeyboardList;
116 PGENERIC_LIST LayoutList;
117 PGENERIC_LIST LanguageList;
118
119 /* Other stuff *****/
120 WCHAR LocaleID[9];
121 LANGID LanguageId;
122
123 ULONG RequiredPartitionDiskSpace;
124 WCHAR InstallationDirectory[MAX_PATH];
125 } USETUP_DATA, *PUSETUP_DATA;
126
127 // HACK!!
128 extern BOOLEAN IsUnattendedSetup;
129
130
131 /* FUNCTIONS ****************************************************************/
132
133 VOID
134 CheckUnattendedSetup(
135 IN OUT PUSETUP_DATA pSetupData);
136
137 VOID
138 InstallSetupInfFile(
139 IN OUT PUSETUP_DATA pSetupData);
140
141 NTSTATUS
142 GetSourcePaths(
143 OUT PUNICODE_STRING SourcePath,
144 OUT PUNICODE_STRING SourceRootPath,
145 OUT PUNICODE_STRING SourceRootDir);
146
147 ERROR_NUMBER
148 LoadSetupInf(
149 IN OUT PUSETUP_DATA pSetupData);
150
151 NTSTATUS
152 InitDestinationPaths(
153 IN OUT PUSETUP_DATA pSetupData,
154 IN PCWSTR InstallationDir,
155 IN PDISKENTRY DiskEntry, // FIXME: HACK!
156 IN PPARTENTRY PartEntry); // FIXME: HACK!
157
158 // NTSTATUS
159 ERROR_NUMBER
160 InitializeSetup(
161 IN OUT PUSETUP_DATA pSetupData,
162 IN ULONG InitPhase);
163
164 VOID
165 FinishSetup(
166 IN OUT PUSETUP_DATA pSetupData);
167
168
169 typedef enum _REGISTRY_STATUS
170 {
171 Success = 0,
172 RegHiveUpdate,
173 ImportRegHive,
174 DisplaySettingsUpdate,
175 LocaleSettingsUpdate,
176 KeybLayouts,
177 KeybSettingsUpdate,
178 CodePageInfoUpdate,
179 } REGISTRY_STATUS;
180
181 typedef VOID
182 (__cdecl *PREGISTRY_STATUS_ROUTINE)(IN REGISTRY_STATUS, ...);
183
184 ERROR_NUMBER
185 UpdateRegistry(
186 IN OUT PUSETUP_DATA pSetupData,
187 /**/IN BOOLEAN RepairUpdateFlag, /* HACK HACK! */
188 /**/IN PPARTLIST PartitionList, /* HACK HACK! */
189 /**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */
190 /**/IN PCWSTR SelectedLanguageId, /* HACK HACK! */
191 IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL);
192
193 /* EOF */