ReactOS 0.4.17-dev-966-gf06eace
setuplib.c File Reference
#include "precomp.h"
#include "filesup.h"
#include "infsupp.h"
#include "inicache.h"
#include "setuplib.h"
#include <debug.h>
Include dependency graph for setuplib.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define IS_PATH_SEPARATOR(c)   ((c) == L'\\' || (c) == L'/')
 

Functions

static int CompareInfFirstLineString (_In_ HINF hInf, _In_ PCWSTR Section, _In_ PCWSTR Name, _In_ PCWSTR String)
 
static BOOLEAN IsInfUnattendSetupEnabled (_In_ PUSETUP_DATA pSetupData, _In_ PCWSTR InfPath, _In_ BOOLEAN CheckDetached)
 
static BOOLEAN GetUnattendInfPath (_In_ PUSETUP_DATA pSetupData, _Out_writes_z_(cch) PWSTR InfPath, _In_ SIZE_T cch)
 
BOOLEAN NTAPI CheckUnattendedSetup (IN OUT PUSETUP_DATA pSetupData)
 
VOID NTAPI InstallSetupInfFile (IN OUT PUSETUP_DATA pSetupData)
 
NTSTATUS GetSourcePaths (_Out_ PUNICODE_STRING SourcePath, _Out_ PUNICODE_STRING SourceRootPath, _Out_ PUNICODE_STRING SourceRootDir)
 Determine the installation source path and isolate its useful path components (root path and source sub-directory).
 
ERROR_NUMBER LoadSetupInf (IN OUT PUSETUP_DATA pSetupData)
 
BOOLEAN NTAPI InitSystemPartition (_In_ PPARTLIST PartitionList, _In_ PPARTENTRY InstallPartition, _Out_ PPARTENTRY *pSystemPartition, _In_opt_ PFSVOL_CALLBACK FsVolCallback, _In_opt_ PVOID Context)
 Find or set the active system partition.
 
BOOLEAN NTAPI IsValidInstallDirectory (_In_ PCWSTR InstallDir)
 Verify whether the given directory is suitable for ReactOS installation. Each path component must be a valid 8.3 name.
 
NTSTATUS NTAPI InitDestinationPaths (_Inout_ PUSETUP_DATA pSetupData, _In_ PCWSTR InstallationDir, _In_ PVOLENTRY Volume)
 
ERROR_NUMBER NTAPI InitializeSetup (_Inout_ PUSETUP_DATA pSetupData, _In_opt_ PSETUP_ERROR_ROUTINE ErrorRoutine, _In_ PSPFILE_EXPORTS pSpFileExports, _In_ PSPINF_EXPORTS pSpInfExports)
 
VOID NTAPI FinishSetup (IN OUT PUSETUP_DATA pSetupData)
 
ERROR_NUMBER NTAPI UpdateRegistry (IN OUT PUSETUP_DATA pSetupData, IN BOOLEAN RepairUpdateFlag, IN PPARTLIST PartitionList, IN WCHAR DestinationDriveLetter, IN PCWSTR SelectedLanguageId, IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL, IN PFONTSUBSTSETTINGS SubstSettings OPTIONAL)
 

Variables

HANDLE ProcessHeap
 
BOOLEAN IsUnattendedSetup = FALSE
 
static PCWSTR InfUnattendSignature = L"$ReactOS$"
 

Macro Definition Documentation

◆ IS_PATH_SEPARATOR

#define IS_PATH_SEPARATOR (   c)    ((c) == L'\\' || (c) == L'/')

Definition at line 897 of file setuplib.c.

◆ NDEBUG

#define NDEBUG

Definition at line 20 of file setuplib.c.

Function Documentation

◆ CheckUnattendedSetup()

BOOLEAN NTAPI CheckUnattendedSetup ( IN OUT PUSETUP_DATA  pSetupData)

Definition at line 165 of file setuplib.c.

167{
169 HINF UnattendInf;
170 UINT ErrorLine;
171 INT IntValue;
173 WCHAR UnattendInfPath[MAX_PATH];
174
175 if (!GetUnattendInfPath(pSetupData, UnattendInfPath, ARRAYSIZE(UnattendInfPath)))
176 {
177 DPRINT("Does not exist: %S\n", UnattendInfPath);
178 return IsUnattendedSetup;
179 }
180 DPRINT1("UnattendInf path: '%S'\n", UnattendInfPath);
181
182 /* Load 'unattend.inf' from installation media */
183 UnattendInf = SpInfOpenInfFile(UnattendInfPath,
184 NULL,
186 pSetupData->LanguageId,
187 &ErrorLine);
188 if (UnattendInf == INVALID_HANDLE_VALUE)
189 {
190 DPRINT("SpInfOpenInfFile() failed\n");
191 return IsUnattendedSetup;
192 }
193
194 /* Open 'Unattend' section */
195 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"Signature", &Context))
196 {
197 DPRINT("SpInfFindFirstLine() failed for section 'Unattend'\n");
198 goto Quit;
199 }
200
201 /* Get pointer 'Signature' key */
202 if (!INF_GetData(&Context, NULL, &Value))
203 {
204 DPRINT("INF_GetData() failed for key 'Signature'\n");
205 goto Quit;
206 }
207
208 /* Check 'Signature' string */
210 {
211 DPRINT("Signature not %ls\n", InfUnattendSignature);
213 goto Quit;
214 }
215
217
218 /* Check if Unattend setup is enabled */
219 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"UnattendSetupEnabled", &Context))
220 {
221 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
222 goto Quit;
223 }
224
225 if (!INF_GetData(&Context, NULL, &Value))
226 {
227 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
228 goto Quit;
229 }
230
231 if (_wcsicmp(Value, L"yes") != 0)
232 {
233 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
235 goto Quit;
236 }
237
239
240 /* Search for 'DestinationDiskNumber' */
241 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context))
242 {
243 DPRINT("SpInfFindFirstLine() failed for key 'DestinationDiskNumber'\n");
244 goto Quit;
245 }
246
247 if (!SpInfGetIntField(&Context, 1, &IntValue))
248 {
249 DPRINT("SpInfGetIntField() failed for key 'DestinationDiskNumber'\n");
250 goto Quit;
251 }
252
253 pSetupData->DestinationDiskNumber = (LONG)IntValue;
254
255 /* Search for 'DestinationPartitionNumber' */
256 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
257 {
258 DPRINT("SpInfFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
259 goto Quit;
260 }
261
262 if (!SpInfGetIntField(&Context, 1, &IntValue))
263 {
264 DPRINT("SpInfGetIntField() failed for key 'DestinationPartitionNumber'\n");
265 goto Quit;
266 }
267
268 pSetupData->DestinationPartitionNumber = (LONG)IntValue;
269
270 /* Search for 'InstallationDirectory' (optional) */
271 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"InstallationDirectory", &Context))
272 {
273 if (INF_GetData(&Context, NULL, &Value))
274 {
275 RtlStringCchCopyW(pSetupData->InstallationDirectory,
276 ARRAYSIZE(pSetupData->InstallationDirectory),
277 Value);
279 }
280 else
281 {
282 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
283 }
284 }
285
287 DPRINT("Running unattended setup\n");
288
289 /* Search for 'BootLoaderLocation' (optional) */
290 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"BootLoaderLocation", &Context))
291 {
292 if (SpInfGetIntField(&Context, 1, &IntValue))
293 pSetupData->BootLoaderLocation = IntValue;
294 }
295
296 /* Search for 'FormatPartition' (optional) */
297 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FormatPartition", &Context))
298 {
299 if (SpInfGetIntField(&Context, 1, &IntValue))
300 pSetupData->FormatPartition = IntValue;
301 }
302
303 /* Search for 'AutoPartition' (optional) */
304 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"AutoPartition", &Context))
305 {
306 if (SpInfGetIntField(&Context, 1, &IntValue))
307 pSetupData->AutoPartition = IntValue;
308 }
309
310 /* Search for 'LocaleID' (optional) */
311 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"LocaleID", &Context))
312 {
313 if (INF_GetData(&Context, NULL, &Value))
314 {
315 LONG Id = wcstol(Value, NULL, 16);
316 RtlStringCchPrintfW(pSetupData->LocaleID,
317 ARRAYSIZE(pSetupData->LocaleID),
318 L"%08lx", Id);
320 }
321 }
322
323 /* Search for 'FsType' (optional) */
324 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FsType", &Context))
325 {
326 if (SpInfGetIntField(&Context, 1, &IntValue))
327 pSetupData->FsType = IntValue;
328 }
329
330Quit:
331 SpInfCloseInfFile(UnattendInf);
332 return IsUnattendedSetup;
333}
DWORD Id
#define DPRINT1
Definition: precomp.h:8
#define ARRAYSIZE(a)
Definition: cat.c:25
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2752
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
#define L(x)
Definition: resources.c:13
unsigned int UINT
Definition: sysinfo.c:13
#define INF_STYLE_OLDNT
Definition: infsupp.h:39
#define SpInfGetIntField
Definition: infsupp.h:144
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
Definition: infsupp.h:154
#define SpInfOpenInfFile
Definition: infsupp.h:148
#define SpInfCloseInfFile
Definition: infsupp.h:139
#define SpInfFindFirstLine
Definition: infsupp.h:140
BOOLEAN INF_GetData(IN PINFCONTEXT Context, OUT PCWSTR *Key, OUT PCWSTR *Data)
Definition: infsupp.c:77
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:127
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
static PCWSTR InfUnattendSignature
Definition: setuplib.c:28
BOOLEAN IsUnattendedSetup
Definition: setuplib.c:27
static BOOLEAN GetUnattendInfPath(_In_ PUSETUP_DATA pSetupData, _Out_writes_z_(cch) PWSTR InfPath, _In_ SIZE_T cch)
Definition: setuplib.c:95
#define DPRINT
Definition: sndvol32.h:73
_In_ PVOID Context
Definition: storport.h:2269
const uint16_t * PCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by _tWinMain(), and SetupStartPage().

◆ CompareInfFirstLineString()

static int CompareInfFirstLineString ( _In_ HINF  hInf,
_In_ PCWSTR  Section,
_In_ PCWSTR  Name,
_In_ PCWSTR  String 
)
static

Definition at line 33 of file setuplib.c.

38{
42
43 if (!SpInfFindFirstLine(hInf, Section, Name, &Context))
44 return Result;
45
46 if (!INF_GetData(&Context, NULL, &Value))
47 return Result;
48
50
52 return Result;
53}
LPWSTR Name
Definition: desk.c:124
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by IsInfUnattendSetupEnabled().

◆ FinishSetup()

VOID NTAPI FinishSetup ( IN OUT PUSETUP_DATA  pSetupData)

Definition at line 1231 of file setuplib.c.

1233{
1234 /* Destroy the computer settings list */
1235 if (pSetupData->ComputerList != NULL)
1236 {
1237 DestroyGenericList(pSetupData->ComputerList, TRUE);
1238 pSetupData->ComputerList = NULL;
1239 }
1240
1241 /* Destroy the display settings list */
1242 if (pSetupData->DisplayList != NULL)
1243 {
1244 DestroyGenericList(pSetupData->DisplayList, TRUE);
1245 pSetupData->DisplayList = NULL;
1246 }
1247
1248 /* Destroy the keyboard settings list */
1249 if (pSetupData->KeyboardList != NULL)
1250 {
1251 DestroyGenericList(pSetupData->KeyboardList, TRUE);
1252 pSetupData->KeyboardList = NULL;
1253 }
1254
1255 /* Destroy the keyboard layout list */
1256 if (pSetupData->LayoutList != NULL)
1257 {
1258 DestroyGenericList(pSetupData->LayoutList, TRUE);
1259 pSetupData->LayoutList = NULL;
1260 }
1261
1262 /* Destroy the languages list */
1263 if (pSetupData->LanguageList != NULL)
1264 {
1265 DestroyGenericList(pSetupData->LanguageList, FALSE);
1266 pSetupData->LanguageList = NULL;
1267 }
1268
1269 /* Close the Setup INF */
1270 SpInfCloseInfFile(pSetupData->SetupInf);
1271}
#define FALSE
Definition: types.h:117
VOID NTAPI DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
Definition: genlist.c:38

Referenced by _tWinMain(), and RunUSetup().

◆ GetSourcePaths()

NTSTATUS GetSourcePaths ( _Out_ PUNICODE_STRING  SourcePath,
_Out_ PUNICODE_STRING  SourceRootPath,
_Out_ PUNICODE_STRING  SourceRootDir 
)

Determine the installation source path and isolate its useful path components (root path and source sub-directory).

The installation source path is based either on the installer's image file path, or on the \SystemRoot full path.

In case the \SystemRoot full path prefixes the image file path, use the resolved \SystemRoot as the installation source path. Otherwise, use the image file path.

The returned strings are allocated with RtlCreateUnicodeString(), and need to be freed with RtlFreeUnicodeString() after being used.

Example of output: SourcePath: '\Device\CdRom0\I386' SourceRootPath: '\Device\CdRom0' SourceRootDir: '\I386'

Definition at line 535 of file setuplib.c.

539{
542 PWCHAR Ptr;
543 HANDLE LinkHandle;
546 struct { OBJECT_NAME_INFORMATION; WCHAR Buffer[MAX_PATH]; } ImageFileBuffer;
547 PUNICODE_STRING InstallSourcePath = &ImageFileBuffer.Name;
548 struct { OBJECT_NAME_INFORMATION; WCHAR Buffer[MAX_PATH]; } SystemRootBuffer;
549 PUNICODE_STRING SystemRootPath = &SystemRootBuffer.Name;
550 const UNICODE_STRING SystemRoot = RTL_CONSTANT_STRING(L"\\SystemRoot");
551
552 /* Retrieve the installer's full image file path */
553 RtlInitEmptyUnicodeString(InstallSourcePath,
554 ImageFileBuffer.Buffer,
555 sizeof(ImageFileBuffer.Buffer));
556 BufferSize = sizeof(ImageFileBuffer);
559 InstallSourcePath,
561 NULL);
562 // STATUS_INFO_LENGTH_MISMATCH or STATUS_BUFFER_TOO_SMALL ?
563 if (!NT_SUCCESS(Status))
564 return Status;
565 ASSERT(InstallSourcePath->Length < InstallSourcePath->MaximumLength);
566
567 /* Go to the beginning of the path component, stop at the separator */
568 Ptr = ImageFileBuffer.Buffer + (InstallSourcePath->Length / sizeof(WCHAR));
569 while ((Ptr > ImageFileBuffer.Buffer) && (*Ptr != OBJ_NAME_PATH_SEPARATOR))
570 --Ptr;
571 /* Strip the trailing file name (at the separator or beginning of buffer)
572 * and manually NULL-terminate */
573 InstallSourcePath->Length = (ULONG_PTR)Ptr - (ULONG_PTR)ImageFileBuffer.Buffer;
574 InstallSourcePath->Buffer[InstallSourcePath->Length / sizeof(WCHAR)] = UNICODE_NULL;
575
576
577 /*
578 * Now, resolve the \SystemRoot symlink target full path.
579 *
580 * The symlink target path resolution requires reparsing, because it
581 * can reference other symlinks. This is what happens, for example when
582 * booting the installation from a removable hard-disk. We can have:
583 *
584 * \SystemRoot ---> \Device\Harddisk1\Partition1\ReactOS
585 * and: \Device\Harddisk1\Partition1 ---> \Device\HarddiskVolume2
586 * etc.
587 * and we wish to resolve \SystemRoot to: \Device\HarddiskVolume2\ReactOS
588 *
589 * We then verify whether it prefixes the image file path obtained
590 * from the step above, which is a fully reparsed path.
591 *
592 * - Using NtOpenSymbolicLinkObject(SYMBOLIC_LINK_QUERY) followed by
593 * NtQuerySymbolicLinkObject() would only resolve the first symlink
594 * but not the others (\Device\Harddisk1\Partition1 left as is).
595 *
596 * - Since \SystemRoot has to point to a directory, we try opening
597 * the directory itself: NtOpenFile(..., FILE_DIRECTORY_FILE).
598 *
599 * - A call to NtQueryInformationFile(FileNameInformation) alone on
600 * the obtained handle would only retrieve the FS directory name,
601 * i.e. \ReactOS , but not the whole NT path.
602 *
603 * - We therefore use NtQueryObject(), which allows retrieving the
604 * full resolved NT path (device name + FS directory name).
605 */
606
610 NULL,
611 NULL);
612
613 RtlInitEmptyUnicodeString(SystemRootPath,
614 SystemRootBuffer.Buffer,
615 sizeof(SystemRootBuffer.Buffer));
616
617 Status = NtOpenFile(&LinkHandle,
623 /*| FILE_OPEN_FOR_BACKUP_INTENT*/);
624 if (NT_SUCCESS(Status))
625 {
626 /* Resolve the path and close its handle */
627 Status = NtQueryObject(LinkHandle,
629 &SystemRootBuffer,
630 sizeof(SystemRootBuffer),
631 &BufferSize);
632 NtClose(LinkHandle);
633 }
634 /* If any of the calls above failed, try to naively resolve the symlink */
635 if (!NT_SUCCESS(Status))
636 {
637 RtlInitEmptyUnicodeString(SystemRootPath,
638 SystemRootBuffer.Buffer,
639 sizeof(SystemRootBuffer.Buffer));
640
641 Status = NtOpenSymbolicLinkObject(&LinkHandle,
644 if (NT_SUCCESS(Status))
645 {
646 /* Resolve the link and close its handle */
648 SystemRootPath,
649 &BufferSize);
650 NtClose(LinkHandle);
651 }
652 }
653 ASSERT(SystemRootPath->Length < SystemRootPath->MaximumLength);
654
655 /*
656 * If the resolved \SystemRoot is a prefix of the image file path,
657 * use \SystemRoot instead as the installation source path.
658 *
659 * If opening the \SystemRoot link failed (usually due to wrong
660 * access rights), do not consider this as a fatal error, and
661 * use the image file path as the installation source path.
662 */
663 if (NT_SUCCESS(Status) && RtlPrefixUnicodeString(SystemRootPath, InstallSourcePath, TRUE))
664 InstallSourcePath = SystemRootPath;
665
666
667 /*
668 * Retrieve the different source path components.
669 */
670 RtlCreateUnicodeString(SourcePath, InstallSourcePath->Buffer);
671
672 /* Isolate and strip the trailing (source root) directory */
673 Ptr = wcsrchr(InstallSourcePath->Buffer, OBJ_NAME_PATH_SEPARATOR);
674 if (Ptr)
675 {
676 RtlCreateUnicodeString(SourceRootDir, Ptr);
677 *Ptr = UNICODE_NULL;
678 }
679 else
680 {
681 RtlCreateUnicodeString(SourceRootDir, L"");
682 }
683
684 RtlCreateUnicodeString(SourceRootPath, InstallSourcePath->Buffer);
685
686 return STATUS_SUCCESS;
687}
@ ObjectNameInformation
Definition: DriverTester.h:55
static UNICODE_STRING SystemRoot
Definition: IoCreateFile.c:10
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
EXTERN_C NTSTATUS WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG)
@ ProcessImageFileName
Definition: cicbase.cpp:66
Definition: bufpool.h:45
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define BufferSize
Definition: mmc.h:75
_In_ ULONG BufferSize
Definition: dispmprt.h:490
_In_ PIO_STATUS_BLOCK IoStatusBlock
Definition: dispmprt.h:608
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
#define wcsrchr
Definition: compat.h:16
#define FILE_SHARE_READ
Definition: compat.h:136
#define SYMBOLIC_LINK_QUERY
Definition: volume.c:47
#define ULONG_PTR
Definition: config.h:101
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define NtCurrentProcess()
Definition: nt_native.h:1660
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3429
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
#define UNICODE_NULL
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_writes_bytes_to_opt_(ProcessInformationLength, *ReturnLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:211
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59

Referenced by InitializeSetup().

◆ GetUnattendInfPath()

static BOOLEAN GetUnattendInfPath ( _In_ PUSETUP_DATA  pSetupData,
_Out_writes_z_(cch) PWSTR  InfPath,
_In_ SIZE_T  cch 
)
static

Definition at line 95 of file setuplib.c.

99{
100 static WCHAR UnattendInfPath[MAX_PATH] = {UNICODE_NULL};
101 static BOOLEAN UnattendInfLookedUp = FALSE;
104
105 /* If the unattend.inf file has already been looked for, return
106 * its cached path if it was found, or fail otherwise. */
107 if (UnattendInfLookedUp)
108 goto Quit;
109
110 UnattendInfLookedUp = TRUE;
111
112 /* Find first the default unattend.inf file on the installation media.
113 * If it specifies an unattended setup, we have found it. */
114 Status = CombinePaths(UnattendInfPath, _countof(UnattendInfPath), 2,
115 pSetupData->SourcePath.Buffer, L"unattend.inf");
116 if (NT_SUCCESS(Status) && DoesFileExist(NULL, UnattendInfPath) &&
117 IsInfUnattendSetupEnabled(pSetupData, UnattendInfPath, FALSE))
118 {
119 return NT_SUCCESS(RtlStringCchCopyW(InfPath, cch, UnattendInfPath));
120 }
121
122 /*
123 * The default unattend.inf file does not exist, or does not enable an
124 * unattended setup. Check all DOS drives, removable first, then fixed,
125 * for an alternative unattend.inf that enables unattended setup.
126 * If we find one, use it; otherwise, return the default unattend.inf
127 * path, if it exists.
128 */
129 for (Types = 0; Types <= 1; ++Types)
130 {
131 CHAR Drive;
132 for (Drive = 'A'; Drive <= 'Z'; ++Drive)
133 {
135 WCHAR szInf[MAX_PATH];
136 UNICODE_STRING NtDrive = {0, sizeof(szInf), szInf};
137
140 continue; /* Invalid drive */
141 if ((Types == 0) != (DriveType == DRIVE_REMOVABLE || DriveType == DRIVE_CDROM))
142 continue; /* Not the expected drive type */
143
144 Status = ConcatPaths(szInf, _countof(szInf), 1, L"unattend.inf");
145 if (NT_SUCCESS(Status) && DoesFileExist(NULL, szInf) &&
146 IsInfUnattendSetupEnabled(pSetupData, szInf, TRUE))
147 {
148 /* Cache the alternative unattend.inf path and return it */
149 (void)RtlStringCchCopyW(UnattendInfPath, _countof(UnattendInfPath), szInf);
150 return NT_SUCCESS(RtlStringCchCopyW(InfPath, cch, szInf));
151 }
152 }
153 }
154 /* Fall back to the default unattend.inf path */
155
156Quit:
157 /* Return the cached unattend.inf path if it was found, or fail otherwise */
158 if (*UnattendInfPath)
159 return NT_SUCCESS(RtlStringCchCopyW(InfPath, cch, UnattendInfPath));
160 return FALSE;
161}
UINT DriveType
char ACPI_OBJECT_TYPE * Types
Definition: acdebug.h:354
unsigned char BOOLEAN
Definition: actypes.h:127
PWCHAR Drive
Definition: chkdsk.c:73
NTSTATUS CombinePaths(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:665
UCHAR GetNtDevicePathOfDriveNumber(_In_ USHORT DriveNumber, _Out_ PUNICODE_STRING DevicePath)
Definition: filesup.c:1099
NTSTATUS ConcatPaths(IN OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:643
#define DoesFileExist(RootDirectory, FileName)
Definition: filesup.h:83
unsigned short USHORT
Definition: pedump.c:61
char CHAR
Definition: pedump.c:57
static BOOLEAN IsInfUnattendSetupEnabled(_In_ PUSETUP_DATA pSetupData, _In_ PCWSTR InfPath, _In_ BOOLEAN CheckDetached)
Definition: setuplib.c:56
_In_ UINT _In_ UINT cch
Definition: shellapi.h:432
#define _countof(array)
Definition: sndvol32.h:70
unsigned char UCHAR
Definition: typedefs.h:53
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:282
#define DRIVE_CDROM
Definition: winbase.h:279
#define DRIVE_REMOVABLE
Definition: winbase.h:276

Referenced by CheckUnattendedSetup(), and InstallSetupInfFile().

◆ InitDestinationPaths()

NTSTATUS NTAPI InitDestinationPaths ( _Inout_ PUSETUP_DATA  pSetupData,
_In_ PCWSTR  InstallationDir,
_In_ PVOLENTRY  Volume 
)

Equivalent of 'NTOS_INSTALLATION::SystemArcPath'

Equivalent of 'NTOS_INSTALLATION::SystemNtPath'

Equivalent of 'NTOS_INSTALLATION::PathComponent'

Definition at line 991 of file setuplib.c.

995{
997 PPARTENTRY PartEntry = Volume->PartEntry;
998 PDISKENTRY DiskEntry = PartEntry->DiskEntry;
1000
1001 ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
1002
1003 /* Create 'pSetupData->DestinationRootPath' string */
1004 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
1005 Status = RtlStringCchPrintfW(PathBuffer, _countof(PathBuffer),
1006 L"%s\\", Volume->Info.DeviceName);
1007 if (!NT_SUCCESS(Status))
1008 {
1009 DPRINT1("RtlStringCchPrintfW() failed with status 0x%08lx\n", Status);
1010 return Status;
1011 }
1012
1013 Status = RtlCreateUnicodeString(&pSetupData->DestinationRootPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
1014
1015 if (!NT_SUCCESS(Status))
1016 {
1017 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
1018 return Status;
1019 }
1020
1021 DPRINT("DestinationRootPath: %wZ\n", &pSetupData->DestinationRootPath);
1022
1023 // FIXME! Which variable to choose?
1024 if (!InstallationDir)
1025 InstallationDir = pSetupData->InstallationDirectory;
1026
1028 /* Create 'pSetupData->DestinationArcPath' */
1029 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
1030
1031 if (DiskEntry->MediaType == FixedMedia)
1032 {
1033 if (DiskEntry->BiosFound)
1034 {
1035#if 1
1036 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
1037 L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
1038 DiskEntry->HwFixedDiskNumber,
1039 PartEntry->OnDiskPartitionNumber);
1040#else
1041 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
1042 L"multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)\\",
1043 DiskEntry->HwAdapterNumber,
1044 DiskEntry->HwControllerNumber,
1045 DiskEntry->HwFixedDiskNumber,
1046 PartEntry->OnDiskPartitionNumber);
1047#endif
1048 DPRINT1("Fixed disk found by BIOS, using MULTI ARC path '%S'\n", PathBuffer);
1049 }
1050 else
1051 {
1052 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
1053 L"scsi(%u)disk(%u)rdisk(%u)partition(%lu)\\",
1054 DiskEntry->Port,
1055 DiskEntry->Bus,
1056 DiskEntry->Id,
1057 PartEntry->OnDiskPartitionNumber);
1058 DPRINT1("Fixed disk not found by BIOS, using SCSI ARC path '%S'\n", PathBuffer);
1059 }
1060 }
1061 else // if (DiskEntry->MediaType == RemovableMedia)
1062 {
1063#if 1
1064 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
1065 L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
1066 0, 1);
1067 DPRINT1("Removable disk, using MULTI ARC path '%S'\n", PathBuffer);
1068#else
1069 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
1070 L"signature(%08x)disk(%u)rdisk(%u)partition(%lu)\\",
1071 DiskEntry->LayoutBuffer->Signature,
1072 DiskEntry->Bus,
1073 DiskEntry->Id,
1074 PartEntry->OnDiskPartitionNumber);
1075 DPRINT1("Removable disk, using SIGNATURE ARC path '%S'\n", PathBuffer);
1076#endif
1077 }
1078
1079 if (!NT_SUCCESS(Status))
1080 {
1081 DPRINT1("RtlStringCchPrintfW() failed with status 0x%08lx\n", Status);
1082 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
1083 return Status;
1084 }
1085
1086 Status = ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallationDir);
1087
1088 if (!NT_SUCCESS(Status))
1089 {
1090 DPRINT1("ConcatPaths() failed with status 0x%08lx\n", Status);
1091 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
1092 return Status;
1093 }
1094
1095 Status = RtlCreateUnicodeString(&pSetupData->DestinationArcPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
1096
1097 if (!NT_SUCCESS(Status))
1098 {
1099 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
1100 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
1101 return Status;
1102 }
1103
1105 /* Create 'pSetupData->DestinationPath' string */
1106 RtlFreeUnicodeString(&pSetupData->DestinationPath);
1107 Status = CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
1108 pSetupData->DestinationRootPath.Buffer, InstallationDir);
1109
1110 if (!NT_SUCCESS(Status))
1111 {
1112 DPRINT1("CombinePaths() failed with status 0x%08lx\n", Status);
1113 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
1114 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
1115 return Status;
1116 }
1117
1118 Status = RtlCreateUnicodeString(&pSetupData->DestinationPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
1119
1120 if (!NT_SUCCESS(Status))
1121 {
1122 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
1123 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
1124 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
1125 return Status;
1126 }
1127
1129 // FIXME: This is only temporary!! Must be removed later!
1130 Status = RtlCreateUnicodeString(&pSetupData->InstallPath, InstallationDir) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
1131
1132 if (!NT_SUCCESS(Status))
1133 {
1134 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
1135 RtlFreeUnicodeString(&pSetupData->DestinationPath);
1136 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
1137 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
1138 return Status;
1139 }
1140
1141 return STATUS_SUCCESS;
1142}
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
UNICODE_STRING Volume
Definition: fltkernel.h:1172
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define RTL_NUMBER_OF_FIELD(type, field)
Definition: ntbasedef.h:715
@ FixedMedia
Definition: ntdddisk.h:383
ULONG HwAdapterNumber
Definition: partlist.h:121
ULONG HwControllerNumber
Definition: partlist.h:122
BOOLEAN BiosFound
Definition: partlist.h:120
USHORT Bus
Definition: partlist.h:132
USHORT Id
Definition: partlist.h:133
USHORT Port
Definition: partlist.h:131
MEDIA_TYPE MediaType
Definition: partlist.h:106
ULONG HwFixedDiskNumber
Definition: partlist.h:124
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:143
BOOLEAN IsPartitioned
Definition: partlist.h:82
struct _DISKENTRY * DiskEntry
Definition: partlist.h:66
ULONG OnDiskPartitionNumber
Definition: partlist.h:74
ULONG PartitionNumber
Definition: partlist.h:75
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281

Referenced by InstallDirectoryPage(), and PrepareAndDoCopyThread().

◆ InitializeSetup()

ERROR_NUMBER NTAPI InitializeSetup ( _Inout_ PUSETUP_DATA  pSetupData,
_In_opt_ PSETUP_ERROR_ROUTINE  ErrorRoutine,
_In_ PSPFILE_EXPORTS  pSpFileExports,
_In_ PSPINF_EXPORTS  pSpInfExports 
)

Definition at line 1147 of file setuplib.c.

1152{
1155
1157 RtlZeroMemory(pSetupData, sizeof(*pSetupData));
1158
1159 /* Initialize error handling */
1160 pSetupData->LastErrorNumber = ERROR_SUCCESS;
1161 pSetupData->ErrorRoutine = ErrorRoutine;
1162
1163 /* Initialize global unicode strings */
1164 RtlInitUnicodeString(&pSetupData->SourcePath, NULL);
1165 RtlInitUnicodeString(&pSetupData->SourceRootPath, NULL);
1166 RtlInitUnicodeString(&pSetupData->SourceRootDir, NULL);
1167 RtlInitUnicodeString(&pSetupData->DestinationArcPath, NULL);
1168 RtlInitUnicodeString(&pSetupData->DestinationPath, NULL);
1169 RtlInitUnicodeString(&pSetupData->DestinationRootPath, NULL);
1170 RtlInitUnicodeString(&pSetupData->SystemRootPath, NULL);
1171
1172 // FIXME: This is only temporary!! Must be removed later!
1173 /***/RtlInitUnicodeString(&pSetupData->InstallPath, NULL);/***/
1174
1175 /* Initialize SpFile and SpInf support */
1176 RtlCopyMemory(&SpFileExports, pSpFileExports, sizeof(SpFileExports));
1177 RtlCopyMemory(&SpInfExports, pSpInfExports, sizeof(SpInfExports));
1178
1179 //
1180 // TODO: Load and start SetupDD, and ask it for the information
1181 //
1182
1183 /* Get the source path and source root path */
1184 Status = GetSourcePaths(&pSetupData->SourcePath,
1185 &pSetupData->SourceRootPath,
1186 &pSetupData->SourceRootDir);
1187 if (!NT_SUCCESS(Status))
1188 {
1189 DPRINT1("GetSourcePaths() failed (Status 0x%08lx)\n", Status);
1190 return ERROR_NO_SOURCE_DRIVE;
1191 }
1192 DPRINT1("SourcePath (1): '%wZ'\n", &pSetupData->SourcePath);
1193 DPRINT1("SourceRootPath (1): '%wZ'\n", &pSetupData->SourceRootPath);
1194 DPRINT1("SourceRootDir (1): '%wZ'\n", &pSetupData->SourceRootDir);
1195
1196 /* Set up default values */
1197 pSetupData->DestinationDiskNumber = 0;
1198 pSetupData->DestinationPartitionNumber = 1;
1199 pSetupData->BootLoaderLocation = 2; // Default to "System partition"
1200 pSetupData->FormatPartition = 0;
1201 pSetupData->AutoPartition = 0;
1202 pSetupData->FsType = 0;
1203
1204 /* Load 'txtsetup.sif' from the installation media */
1205 Error = LoadSetupInf(pSetupData);
1206 if (Error != ERROR_SUCCESS)
1207 {
1208 DPRINT1("LoadSetupInf() failed (Error 0x%lx)\n", Error);
1209 return Error;
1210 }
1211 DPRINT1("SourcePath (2): '%wZ'\n", &pSetupData->SourcePath);
1212 DPRINT1("SourceRootPath (2): '%wZ'\n", &pSetupData->SourceRootPath);
1213 DPRINT1("SourceRootDir (2): '%wZ'\n", &pSetupData->SourceRootDir);
1214
1215 /* Retrieve the target machine architecture type */
1216 // FIXME: This should be determined at runtime!!
1217 // FIXME: Allow for (pre-)installing on an architecture
1218 // different from the current one?
1219#if defined(SARCH_XBOX)
1220 pSetupData->ArchType = ARCH_Xbox;
1221// #elif defined(SARCH_PC98)
1222#else // TODO: Arc, UEFI
1223 pSetupData->ArchType = (IsNEC_98 ? ARCH_NEC98x86 : ARCH_PcAT);
1224#endif
1225
1226 return ERROR_SUCCESS;
1227}
BOOL Error
Definition: chkdsk.c:66
#define ERROR_SUCCESS
Definition: deptool.c:10
enum _ERROR_NUMBER ERROR_NUMBER
@ ERROR_NO_SOURCE_DRIVE
Definition: errorcode.h:23
SPFILE_EXPORTS SpFileExports
Definition: fileqsup.c:23
SPINF_EXPORTS SpInfExports
Definition: infsupp.c:24
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
ERROR_NUMBER LoadSetupInf(IN OUT PUSETUP_DATA pSetupData)
Definition: setuplib.c:690
NTSTATUS GetSourcePaths(_Out_ PUNICODE_STRING SourcePath, _Out_ PUNICODE_STRING SourceRootPath, _Out_ PUNICODE_STRING SourceRootDir)
Determine the installation source path and isolate its useful path components (root path and source s...
Definition: setuplib.c:535
@ ARCH_NEC98x86
Definition: setuplib.h:55
@ ARCH_PcAT
Definition: setuplib.h:54
@ ARCH_Xbox
Definition: setuplib.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IsNEC_98
Definition: ketypes.h:979

Referenced by _tWinMain(), and SetupStartPage().

◆ InitSystemPartition()

BOOLEAN NTAPI InitSystemPartition ( _In_ PPARTLIST  PartitionList,
_In_ PPARTENTRY  InstallPartition,
_Out_ PPARTENTRY *  pSystemPartition,
_In_opt_ PFSVOL_CALLBACK  FsVolCallback,
_In_opt_ PVOID  Context 
)

Find or set the active system partition.

Definition at line 806 of file setuplib.c.

812{
815 PPARTENTRY OldActivePart;
816
817 /*
818 * If we install on a fixed disk, try to find a supported system
819 * partition on the system. Otherwise if we install on a removable disk
820 * use the install partition as the system partition.
821 */
822 if (InstallPartition->DiskEntry->MediaType == FixedMedia)
823 {
825 FALSE,
828 /* Use the original system partition as the old active partition hint */
829 OldActivePart = PartitionList->SystemPartition;
830
833 {
834 DPRINT1("We are using a different system partition!!\n");
835
839 0);
840 if (Result != FSVOL_DOIT)
841 return FALSE;
842 }
843 }
844 else // if (InstallPartition->DiskEntry->MediaType == RemovableMedia)
845 {
847 /* Don't specify any old active partition hint */
848 OldActivePart = NULL;
849 }
850
851 if (!SystemPartition)
852 {
856 0);
857 return FALSE;
858 }
859
860 *pSystemPartition = SystemPartition;
861
862 /*
863 * If the system partition can be created in some
864 * non-partitioned space, create it now.
865 */
867 {
868 /* Automatically create the partition; it will be
869 * formatted later with default parameters */
870 // FIXME: Don't use the whole empty space, but a minimal size
871 // specified from the TXTSETUP.SIF or unattended setup.
874 0ULL,
875 0);
877 }
878
879 /* Set it as such */
881 {
882 DPRINT1("SetActivePartition(0x%p) failed?!\n", SystemPartition);
883 ASSERT(FALSE);
884 }
885
886 /*
887 * In all cases, whether or not we are going to perform a formatting,
888 * we must perform a filesystem check of the system partition.
889 */
892
893 return TRUE;
894}
static FSVOL_OP CALLBACK FsVolCallback(_In_opt_ PVOID Context, _In_ FSVOLNOTIFY FormatStatus, _In_ ULONG_PTR Param1, _In_ ULONG_PTR Param2)
Definition: reactos.c:1430
PPARTENTRY InstallPartition
Definition: reactos.c:27
PPARTENTRY SystemPartition
Definition: reactos.c:32
#define ULL(a, b)
Definition: format_msg.c:27
@ FSVOLNOTIFY_PARTITIONERROR
Definition: fsutil.h:149
@ ChangeSystemPartition
Definition: fsutil.h:156
enum _FSVOL_OP FSVOL_OP
@ FSVOL_DOIT
Definition: fsutil.h:166
BOOLEAN NTAPI CreatePartition(_In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
Definition: partlist.c:2975
BOOLEAN SetActivePartition(IN PPARTLIST List, IN PPARTENTRY PartEntry, IN PPARTENTRY OldActivePart OPTIONAL)
Definition: partlist.c:3603
PPARTENTRY FindSupportedSystemPartition(IN PPARTLIST List, IN BOOLEAN ForceSelect, IN PDISKENTRY AlternativeDisk OPTIONAL, IN PPARTENTRY AlternativePart OPTIONAL)
Definition: partlist.c:3300
#define ERROR_SYSTEM_PARTITION_NOT_FOUND
Definition: setuplib.h:188
PVOLENTRY Volume
Definition: partlist.h:95
PPARTENTRY SystemPartition
Definition: partlist.h:181
BOOLEAN NeedsCheck
Definition: partlist.h:51
static PPARTLIST PartitionList
Definition: usetup.c:75

Referenced by PrepareAndDoCopyThread(), and StartPartitionOperationsPage().

◆ InstallSetupInfFile()

VOID NTAPI InstallSetupInfFile ( IN OUT PUSETUP_DATA  pSetupData)

Definition at line 337 of file setuplib.c.

339{
341 PINICACHE IniCache;
342
343#if 0 // HACK FIXME!
344 PINICACHE UnattendCache;
346#else
347 // WCHAR CrLf[] = {L'\r', L'\n'};
348 CHAR CrLf[] = {'\r', '\n'};
349 HANDLE FileHandle, UnattendFileHandle, SectionHandle;
352 PVOID ViewBase;
356#endif
357
358 PINI_SECTION IniSection;
359 WCHAR PathBuffer[MAX_PATH];
360 WCHAR UnattendInfPath[MAX_PATH];
361
362 /* Create a $winnt$.inf file with default entries */
363 IniCache = IniCacheCreate();
364 if (!IniCache)
365 return;
366
367#if 0 /* If you need to put something in this section, do it after the merge with Unattend.inf */
368 IniSection = IniAddSection(IniCache, L"SetupParams");
369 if (IniSection)
370 {
371 /* Key "skipmissingfiles" */
372 // RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
373 // L"\"%s\"", L"WinNt5.2");
374 // IniAddKey(IniSection, L"Version", PathBuffer);
375 }
376#endif
377
378 IniSection = IniAddSection(IniCache, L"Data");
379 if (IniSection)
380 {
381 RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
382 L"\"%s\"", IsUnattendedSetup ? L"yes" : L"no");
383 IniAddKey(IniSection, L"UnattendedInstall", PathBuffer);
384
385 // "floppylessbootpath" (yes/no)
386
387 RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
388 L"\"%s\"", L"winnt");
389 IniAddKey(IniSection, L"ProductType", PathBuffer);
390
391 RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
392 L"\"%s\\\"", pSetupData->SourceRootPath.Buffer);
393 IniAddKey(IniSection, L"SourcePath", PathBuffer);
394
395 // "floppyless" ("0")
396 }
397
398#if 0
399
400 /* TODO: Append the standard unattend.inf file */
401 if (!GetUnattendInfPath(pSetupData, UnattendInfPath, ARRAYSIZE(UnattendInfPath)))
402 {
403 DPRINT("Does not exist: %S\n", UnattendInfPath);
404 goto Quit;
405 }
406
407 Status = IniCacheLoad(&UnattendCache, UnattendInfPath, FALSE);
408 if (!NT_SUCCESS(Status))
409 {
410 DPRINT1("Cannot load %S as an INI file!\n", UnattendInfPath);
411 goto Quit;
412 }
413
414 IniCacheDestroy(UnattendCache);
415
416Quit:
417 CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
418 pSetupData->DestinationPath.Buffer, L"System32\\$winnt$.inf");
419 IniCacheSave(IniCache, PathBuffer);
420 IniCacheDestroy(IniCache);
421
422#else
423
424 CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
425 pSetupData->DestinationPath.Buffer, L"System32\\$winnt$.inf");
426 IniCacheSave(IniCache, PathBuffer);
427 IniCacheDestroy(IniCache);
428
429 /* TODO: Append the standard unattend.inf file */
430 if (!GetUnattendInfPath(pSetupData, UnattendInfPath, ARRAYSIZE(UnattendInfPath)))
431 {
432 DPRINT("Does not exist: %S\n", UnattendInfPath);
433 return;
434 }
435
436 RtlInitUnicodeString(&FileName, PathBuffer);
438 &FileName,
440 NULL,
441 NULL);
448 if (!NT_SUCCESS(Status))
449 {
450 DPRINT1("Cannot load %S as an INI file!\n", PathBuffer);
451 return;
452 }
453
454 /* Query the file size */
457 &FileInfo,
458 sizeof(FileInfo),
460 if (!NT_SUCCESS(Status))
461 {
462 DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
463 FileInfo.EndOfFile.QuadPart = 0ULL;
464 }
465
467 UnattendInfPath,
468 &UnattendFileHandle,
469 &FileSize,
470 &SectionHandle,
471 &ViewBase,
472 FALSE);
473 if (!NT_SUCCESS(Status))
474 {
475 DPRINT1("Cannot load %S !\n", UnattendInfPath);
477 return;
478 }
479
480 /* Write to the INI file */
481
482 /* "\r\n" */
484 NULL,
485 NULL,
486 NULL,
488 (PVOID)CrLf,
489 sizeof(CrLf),
490 &FileInfo.EndOfFile,
491 NULL);
492
494 NULL,
495 NULL,
496 NULL,
498 ViewBase,
499 FileSize,
500 NULL,
501 NULL);
502 if (!NT_SUCCESS(Status))
503 {
504 DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
505 }
506
507 /* Finally, unmap and close the file */
508 UnMapAndCloseFile(UnattendFileHandle, SectionHandle, ViewBase);
509
511#endif
512}
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
struct _FileName FileName
Definition: fatprocs.h:897
NTSTATUS OpenAndMapFile(_In_opt_ HANDLE RootDirectory, _In_ PCWSTR PathNameToFile, _Out_opt_ PHANDLE FileHandle, _Out_opt_ PULONG FileSize, _Out_ PHANDLE SectionHandle, _Out_ PVOID *BaseAddress, _In_ BOOLEAN ReadWriteAccess)
Opens and maps a file in memory.
Definition: filesup.c:880
#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress)
Definition: filesup.h:121
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
VOID IniCacheDestroy(_In_ PINICACHE Cache)
Definition: inicache.c:699
NTSTATUS IniCacheLoad(PINICACHE *Cache, PWCHAR FileName, BOOLEAN String)
Definition: inicache.c:655
PINI_SECTION IniAddSection(_In_ PINICACHE Cache, _In_ PCWSTR Name)
Definition: inicache.c:838
NTSTATUS IniCacheSave(PINICACHE Cache, PWCHAR FileName)
Definition: inicache.c:1038
PINICACHE IniCacheCreate(VOID)
Definition: inicache.c:919
PINI_KEYWORD IniAddKey(_In_ PINI_SECTION Section, _In_ PCWSTR Name, _In_ PCWSTR Data)
Definition: inicache.c:883
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define OBJ_OPENIF
Definition: winternl.h:229
#define FileStandardInformation
Definition: propsheet.cpp:61
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
Definition: wdfchildlist.h:656

Referenced by FileCopyPage(), and PrepareAndDoCopyThread().

◆ IsInfUnattendSetupEnabled()

static BOOLEAN IsInfUnattendSetupEnabled ( _In_ PUSETUP_DATA  pSetupData,
_In_ PCWSTR  InfPath,
_In_ BOOLEAN  CheckDetached 
)
static

Definition at line 56 of file setuplib.c.

60{
61 HINF hInf;
62 UINT ErrorLine;
64
65 hInf = SpInfOpenInfFile(InfPath,
66 NULL,
68 pSetupData->LanguageId,
69 &ErrorLine);
70 if (hInf == INVALID_HANDLE_VALUE)
71 return Result;
72
73 /* Verify supported inf 'Signature' key */
74 if (CompareInfFirstLineString(hInf, L"Unattend", L"Signature", InfUnattendSignature) != 0)
75 {
76 DPRINT("Signature not %ls\n", InfUnattendSignature);
77 goto Quit;
78 }
79
80 /* Check whether unattended setup is enabled */
81 if (CompareInfFirstLineString(hInf, L"Unattend", L"UnattendSetupEnabled", L"yes") != 0)
82 goto Quit;
83
84 /* Extra safety check for inf files not on the ISO */
85 if (CheckDetached && CompareInfFirstLineString(hInf, L"Unattend", L"UnattendForDetached", L"yes") != 0)
86 goto Quit;
87
88 Result = TRUE;
89Quit:
91 return Result;
92}
static int CompareInfFirstLineString(_In_ HINF hInf, _In_ PCWSTR Section, _In_ PCWSTR Name, _In_ PCWSTR String)
Definition: setuplib.c:33

Referenced by GetUnattendInfPath().

◆ IsValidInstallDirectory()

BOOLEAN NTAPI IsValidInstallDirectory ( _In_ PCWSTR  InstallDir)

Verify whether the given directory is suitable for ReactOS installation. Each path component must be a valid 8.3 name.

Definition at line 906 of file setuplib.c.

908{
909 PCWCH p;
910
911 /* As with the NT installer, fail if the path is empty or "\\" */
912 p = InstallDir;
913 if (!*p || (IS_PATH_SEPARATOR(*p) && !*(p + 1)))
914 return FALSE;
915
916 /* The path must contain only valid characters */
917 for (p = InstallDir; *p; ++p)
918 {
920 return FALSE;
921 }
922
923 /*
924 * Loop over each path component and verify that each is a valid 8.3 name.
925 */
926 for (p = InstallDir; *p;)
927 {
928 PCWSTR Path;
931 BOOLEAN IsNameLegal, SpacesInName;
932
933 /* Skip any first separator */
934 if (IS_PATH_SEPARATOR(*p))
935 ++p;
936
937 /* Now skip past the path component until we reach the next separator */
938 Path = p;
939 while (*p && !IS_PATH_SEPARATOR(*p))
940 ++p;
941 if (p == Path)
942 {
943 /* Succeed if nothing else follows this separator; otherwise
944 * it's a separator and consecutive ones are not supported */
945 return (!*p);
946 }
947
948 /* Calculate the path component length */
949 Length = p - Path;
950
951 /* As with the NT installer, fail for '.' and '..';
952 * RtlIsNameLegalDOS8Dot3() would succeed otherwise */
953 if ((Length == 1 && *Path == '.') || (Length == 2 && *Path == '.' && *(Path + 1) == '.'))
954 return FALSE;
955
956 /* As with the NT installer, allow _only ONE trailing_ dot in
957 * the path component (but not 2 or more), by reducing Length
958 * in that case; RtlIsNameLegalDOS8Dot3() would fail otherwise */
959 if (Length > 1 && *(p - 2) != L'.' && *(p - 1) == L'.')
960 --Length;
961
962 if (Length == 0)
963 return FALSE;
964
965 /* Verify that the path component is a valid 8.3 name */
966 // if (Length > 8+1+3)
967 // return FALSE;
968 Name.Length = Name.MaximumLength = (USHORT)(Length * sizeof(WCHAR));
969 Name.Buffer = (PWCHAR)Path;
970 SpacesInName = FALSE;
971 IsNameLegal = RtlIsNameLegalDOS8Dot3(&Name, NULL, &SpacesInName);
972
973 /* If it isn't legal or contain spaces, fail */
974 if (!IsNameLegal || SpacesInName)
975 {
976 DPRINT("'%wZ' is %s 8.3 filename %s spaces\n",
977 &Name,
978 (IsNameLegal ? "a valid" : "an invalid"),
979 (SpacesInName ? "with" : "without"));
980 return FALSE;
981 }
982 /* Go to the next path component */
983 }
984
985 return TRUE;
986}
PRTL_UNICODE_STRING_BUFFER Path
GLfloat GLfloat p
Definition: glext.h:8902
CONST WCHAR * PCWCH
Definition: ntbasedef.h:423
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
BOOLEAN NTAPI RtlIsNameLegalDOS8Dot3(_In_ PUNICODE_STRING Name, _Inout_opt_ POEM_STRING OemName, _Inout_opt_ PBOOLEAN NameContainsSpaces)
#define IS_PATH_SEPARATOR(c)
Definition: setuplib.c:897
#define IS_VALID_INSTALL_PATH_CHAR(c)
Defines the class of characters valid for the installation directory.
Definition: setuplib.h:206
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by InstallDirectoryPage(), MoreOptDlgProc(), and START_TEST().

◆ LoadSetupInf()

ERROR_NUMBER LoadSetupInf ( IN OUT PUSETUP_DATA  pSetupData)

Definition at line 690 of file setuplib.c.

692{
694 UINT ErrorLine;
695 INT IntValue;
698
700 pSetupData->SourcePath.Buffer, L"txtsetup.sif");
701
702 DPRINT("SetupInf path: '%S'\n", FileNameBuffer);
703
704 pSetupData->SetupInf =
706 NULL,
708 pSetupData->LanguageId,
709 &ErrorLine);
710 if (pSetupData->SetupInf == INVALID_HANDLE_VALUE)
712
713 /* Open 'Version' section */
714 if (!SpInfFindFirstLine(pSetupData->SetupInf, L"Version", L"Signature", &Context))
716
717 /* Get pointer 'Signature' key */
718 if (!INF_GetData(&Context, NULL, &Value))
720
721 /* Check 'Signature' string */
722 if (_wcsicmp(Value, L"$ReactOS$") != 0 &&
723 _wcsicmp(Value, L"$Windows NT$") != 0)
724 {
727 }
728
730
731 /* Open 'DiskSpaceRequirements' section */
732 if (!SpInfFindFirstLine(pSetupData->SetupInf, L"DiskSpaceRequirements", L"FreeSysPartDiskSpace", &Context))
734
735 pSetupData->RequiredPartitionDiskSpace = ~0;
736
737 /* Get the 'FreeSysPartDiskSpace' value */
738 if (!SpInfGetIntField(&Context, 1, &IntValue))
740
741 pSetupData->RequiredPartitionDiskSpace = (ULONG)IntValue;
742
743 //
744 // Support "SetupSourceDevice" and "SetupSourcePath" in txtsetup.sif
745 // See CORE-9023
746 // Support for that should also be added in setupldr.
747 //
748
749 /* Update the Setup Source paths */
750 if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"SetupSourceDevice", &Context))
751 {
752 /*
753 * Get optional pointer 'SetupSourceDevice' key, its presence
754 * will dictate whether we also need 'SetupSourcePath'.
755 */
756 if (INF_GetData(&Context, NULL, &Value))
757 {
758 /* Free the old source root path string and create the new one */
759 RtlFreeUnicodeString(&pSetupData->SourceRootPath);
760 RtlCreateUnicodeString(&pSetupData->SourceRootPath, Value);
762
763 if (!SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"SetupSourcePath", &Context))
764 {
765 /* The 'SetupSourcePath' value is mandatory! */
767 }
768
769 /* Get pointer 'SetupSourcePath' key */
770 if (!INF_GetData(&Context, NULL, &Value))
771 {
772 /* The 'SetupSourcePath' value is mandatory! */
774 }
775
776 /* Free the old source path string and create the new one */
777 RtlFreeUnicodeString(&pSetupData->SourceRootDir);
778 RtlCreateUnicodeString(&pSetupData->SourceRootDir, Value);
780 }
781 }
782
783 /* Search for 'DefaultPath' in the 'SetupData' section */
784 pSetupData->InstallationDirectory[0] = 0;
785 if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"DefaultPath", &Context))
786 {
787 /* Get pointer 'DefaultPath' key */
788 if (!INF_GetData(&Context, NULL, &Value))
790
791 RtlStringCchCopyW(pSetupData->InstallationDirectory,
792 ARRAYSIZE(pSetupData->InstallationDirectory),
793 Value);
794
796 }
797
798 return ERROR_SUCCESS;
799}
WCHAR FileNameBuffer[MAX_PATH]
Definition: framewnd.c:248
@ ERROR_SIGNATURE_TXTSETUPSIF
Definition: errorcode.h:26
@ ERROR_CORRUPT_TXTSETUPSIF
Definition: errorcode.h:25
@ ERROR_LOAD_TXTSETUPSIF
Definition: errorcode.h:24
#define INF_STYLE_WIN4
Definition: infsupp.h:43

Referenced by InitializeSetup().

◆ UpdateRegistry()

ERROR_NUMBER NTAPI UpdateRegistry ( IN OUT PUSETUP_DATA  pSetupData,
IN BOOLEAN  RepairUpdateFlag,
IN PPARTLIST  PartitionList,
IN WCHAR  DestinationDriveLetter,
IN PCWSTR  SelectedLanguageId,
IN PREGISTRY_STATUS_ROUTINE StatusRoutine  OPTIONAL,
IN PFONTSUBSTSETTINGS SubstSettings  OPTIONAL 
)

Definition at line 1282 of file setuplib.c.

1290{
1291 ERROR_NUMBER ErrorNumber;
1293 INFCONTEXT InfContext;
1294 PCWSTR Action;
1295 PCWSTR File;
1296 PCWSTR Section;
1298 BOOLEAN ShouldRepairRegistry = FALSE;
1300
1301 if (RepairUpdateFlag)
1302 {
1303 DPRINT1("TODO: Updating / repairing the registry is not completely implemented yet!\n");
1304
1305 /* Verify the registry hives and check whether we need to update or repair any of them */
1306 Status = VerifyRegistryHives(&pSetupData->DestinationPath, &ShouldRepairRegistry);
1307 if (!NT_SUCCESS(Status))
1308 {
1309 DPRINT1("VerifyRegistryHives failed, Status 0x%08lx\n", Status);
1310 ShouldRepairRegistry = FALSE;
1311 }
1312 if (!ShouldRepairRegistry)
1313 DPRINT1("No need to repair the registry\n");
1314 }
1315
1316DoUpdate:
1317 ErrorNumber = ERROR_SUCCESS;
1318
1319 /* Update the registry */
1320 if (StatusRoutine) StatusRoutine(RegHiveUpdate);
1321
1322 /* Initialize the registry and setup the registry hives */
1323 Status = RegInitializeRegistry(&pSetupData->DestinationPath);
1324 if (!NT_SUCCESS(Status))
1325 {
1326 DPRINT1("RegInitializeRegistry() failed\n");
1327 /********** HACK!!!!!!!!!!! **********/
1329 {
1330 /* The hack was called, return its corresponding error */
1332 }
1333 else
1334 /*************************************/
1335 {
1336 /* Something else failed */
1337 return ERROR_CREATE_HIVE;
1338 }
1339 }
1340
1341 if (!RepairUpdateFlag || ShouldRepairRegistry)
1342 {
1343 /*
1344 * We fully setup the hives, in case we are doing a fresh installation
1345 * (RepairUpdateFlag == FALSE), or in case we are doing an update
1346 * (RepairUpdateFlag == TRUE) BUT we have some registry hives to
1347 * "repair" (aka. recreate: ShouldRepairRegistry == TRUE).
1348 */
1349
1350 Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Fresh", NULL, &InfContext); // Windows-compatible
1351 if (!Success)
1352 Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific
1353
1354 if (!Success)
1355 {
1356 DPRINT1("SpInfFindFirstLine() failed\n");
1357 ErrorNumber = ERROR_FIND_REGISTRY;
1358 goto Cleanup;
1359 }
1360 }
1361 else // if (RepairUpdateFlag && !ShouldRepairRegistry)
1362 {
1363 /*
1364 * In case we are doing an update (RepairUpdateFlag == TRUE) and
1365 * NO registry hives need a repair (ShouldRepairRegistry == FALSE),
1366 * we only update the hives.
1367 */
1368
1369 Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext);
1370 if (!Success)
1371 {
1372 /* Nothing to do for update! */
1373 DPRINT1("No update needed for the registry!\n");
1374 goto Cleanup;
1375 }
1376 }
1377
1378 do
1379 {
1380 INF_GetDataField(&InfContext, 0, &Action);
1381 INF_GetDataField(&InfContext, 1, &File);
1382 INF_GetDataField(&InfContext, 2, &Section);
1383
1384 DPRINT("Action: %S File: %S Section %S\n", Action, File, Section);
1385
1386 if (Action == NULL)
1387 {
1390 INF_FreeData(Section);
1391 break; // Hackfix
1392 }
1393
1394 if (!_wcsicmp(Action, L"AddReg"))
1395 Delete = FALSE;
1396 else if (!_wcsicmp(Action, L"DelReg"))
1397 Delete = TRUE;
1398 else
1399 {
1400 DPRINT1("Unrecognized registry INF action '%S'\n", Action);
1403 INF_FreeData(Section);
1404 continue;
1405 }
1406
1408
1409 if (StatusRoutine) StatusRoutine(ImportRegHive, File);
1410
1411 if (!ImportRegistryFile(pSetupData->SourcePath.Buffer,
1412 File, Section,
1413 pSetupData->LanguageId, Delete))
1414 {
1415 DPRINT1("Importing %S failed\n", File);
1417 INF_FreeData(Section);
1418 ErrorNumber = ERROR_IMPORT_HIVE;
1419 goto Cleanup;
1420 }
1421 } while (SpInfFindNextLine(&InfContext, &InfContext));
1422
1423 if (!RepairUpdateFlag || ShouldRepairRegistry)
1424 {
1425 /* See the explanation for this test above */
1426
1428 PCWSTR LanguageId; // LocaleID;
1429
1430 Entry = GetCurrentListEntry(pSetupData->DisplayList);
1431 ASSERT(Entry);
1432 pSetupData->DisplayType = ((PGENENTRY)GetListEntryData(Entry))->Id;
1433 ASSERT(pSetupData->DisplayType);
1434
1435 /* Update display registry settings */
1436 if (StatusRoutine) StatusRoutine(DisplaySettingsUpdate);
1437 if (!ProcessDisplayRegistry(pSetupData->SetupInf, pSetupData->DisplayType))
1438 {
1439 ErrorNumber = ERROR_UPDATE_DISPLAY_SETTINGS;
1440 goto Cleanup;
1441 }
1442
1443 Entry = GetCurrentListEntry(pSetupData->LanguageList);
1444 ASSERT(Entry);
1445 LanguageId = ((PGENENTRY)GetListEntryData(Entry))->Id;
1446 ASSERT(LanguageId);
1447
1448 /* Set the locale */
1449 if (StatusRoutine) StatusRoutine(LocaleSettingsUpdate);
1450 if (!ProcessLocaleRegistry(/*pSetupData->*/LanguageId))
1451 {
1452 ErrorNumber = ERROR_UPDATE_LOCALESETTINGS;
1453 goto Cleanup;
1454 }
1455
1456 /* Add the keyboard layouts for the given language (without user override) */
1457 if (StatusRoutine) StatusRoutine(KeybLayouts);
1459 {
1460 ErrorNumber = ERROR_ADDING_KBLAYOUTS;
1461 goto Cleanup;
1462 }
1463
1464 Entry = GetCurrentListEntry(pSetupData->LayoutList);
1465 ASSERT(Entry);
1466 pSetupData->LayoutId = ((PGENENTRY)GetListEntryData(Entry))->Id;
1467 ASSERT(pSetupData->LayoutId);
1468
1469 /* Update keyboard layout settings with user-overridden values */
1470 // FIXME: Wouldn't it be better to do it all at once
1471 // with the AddKeyboardLayouts() step?
1472 if (StatusRoutine) StatusRoutine(KeybSettingsUpdate);
1473 if (!ProcessKeyboardLayoutRegistry(pSetupData->LayoutId, SelectedLanguageId))
1474 {
1475 ErrorNumber = ERROR_UPDATE_KBSETTINGS;
1476 goto Cleanup;
1477 }
1478
1479 /* Set GeoID */
1481 {
1482 ErrorNumber = ERROR_UPDATE_GEOID;
1483 goto Cleanup;
1484 }
1485
1486 /* Add codepage information to registry */
1487 if (StatusRoutine) StatusRoutine(CodePageInfoUpdate);
1489 {
1490 ErrorNumber = ERROR_ADDING_CODEPAGE;
1491 goto Cleanup;
1492 }
1493
1494 /* Set the default pagefile entry */
1495 SetDefaultPagefile(DestinationDriveLetter);
1496
1497 /* Update the mounted devices list */
1498 // FIXME: This should technically be done by mountmgr (if AutoMount is enabled)!
1500 }
1501
1502#ifdef __REACTOS__
1503 if (SubstSettings)
1504 {
1505 /* HACK */
1506 DoRegistryFontFixup(SubstSettings, wcstoul(SelectedLanguageId, NULL, 16));
1507 }
1508#endif
1509
1510Cleanup:
1511 //
1512 // TODO: Unload all the registry stuff, perform cleanup,
1513 // and copy the created hive files into .sav files.
1514 //
1515 RegCleanupRegistry(&pSetupData->DestinationPath);
1516
1517 /*
1518 * Check whether we were in update/repair mode but we were actually
1519 * repairing the registry hives. If so, we have finished repairing them,
1520 * and we now reset the flag and run the proper registry update.
1521 * Otherwise we have finished the registry update!
1522 */
1523 if (RepairUpdateFlag && ShouldRepairRegistry)
1524 {
1525 ShouldRepairRegistry = FALSE;
1526 goto DoUpdate;
1527 }
1528
1529 return ErrorNumber;
1530}
static BOOL ImportRegistryFile(HWND hWnd)
Definition: framewnd.c:462
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
VOID RegCleanupRegistry(IN PUNICODE_STRING NtSystemRoot)
Definition: registry.c:997
NTSTATUS RegInitializeRegistry(IN PUNICODE_STRING NtSystemRoot)
Definition: registry.c:679
NTSTATUS VerifyRegistryHives(IN PUNICODE_STRING NtSystemRoot, OUT PBOOLEAN ShouldRepairRegistry)
Definition: registry.c:603
BOOLEAN SetDefaultPagefile(_In_ WCHAR Drive)
Definition: settings.c:1370
BOOLEAN ProcessKeyboardLayoutRegistry(_In_ PCWSTR pszLayoutId, _In_ PCWSTR LanguageId)
Definition: settings.c:1267
BOOLEAN ProcessDisplayRegistry(_In_ HINF InfFile, _In_ PCWSTR DisplayType)
Definition: settings.c:806
BOOLEAN SetGeoID(_In_ GEOID GeoId)
Definition: settings.c:1320
BOOLEAN ProcessLocaleRegistry(_In_ PCWSTR LanguageId)
Definition: settings.c:969
struct _GENENTRY * PGENENTRY
Definition: File.h:16
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2917
static const WCHAR Cleanup[]
Definition: register.c:80
@ ERROR_ADDING_CODEPAGE
Definition: errorcode.h:52
@ ERROR_UPDATE_GEOID
Definition: errorcode.h:55
@ ERROR_IMPORT_HIVE
Definition: errorcode.h:39
@ ERROR_FIND_REGISTRY
Definition: errorcode.h:40
@ ERROR_UPDATE_LOCALESETTINGS
Definition: errorcode.h:53
@ ERROR_INITIALIZE_REGISTRY
Definition: errorcode.h:42
@ ERROR_CREATE_HIVE
Definition: errorcode.h:41
@ ERROR_ADDING_KBLAYOUTS
Definition: errorcode.h:54
@ ERROR_UPDATE_DISPLAY_SETTINGS
Definition: errorcode.h:38
@ ERROR_UPDATE_KBSETTINGS
Definition: errorcode.h:37
@ Success
Definition: eventcreate.c:712
#define SpInfFindNextLine
Definition: infsupp.h:141
GEOID MUIGetGeoID(IN PCWSTR LanguageId)
Definition: mui.c:104
BOOLEAN AddCodePage(IN PCWSTR LanguageId)
Definition: mui.c:534
BOOLEAN AddKeyboardLayouts(IN PCWSTR LanguageId)
Definition: mui.c:362
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
Definition: infsupp.c:29
PGENERIC_LIST_ENTRY NTAPI GetCurrentListEntry(IN PGENERIC_LIST List)
Definition: genlist.c:102
PVOID NTAPI GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:134
Entry
Definition: section.c:5216
BOOLEAN SetMountedDeviceValues(_In_ PPARTLIST List)
Definition: partlist.c:3967
@ KeybLayouts
Definition: setuplib.h:243
@ DisplaySettingsUpdate
Definition: setuplib.h:241
@ CodePageInfoUpdate
Definition: setuplib.h:245
@ LocaleSettingsUpdate
Definition: setuplib.h:242
@ RegHiveUpdate
Definition: setuplib.h:239
@ ImportRegHive
Definition: setuplib.h:240
@ KeybSettingsUpdate
Definition: setuplib.h:244
Definition: genlist.h:11
BOOL DoRegistryFontFixup(PFONTSUBSTSETTINGS pSettings, LANGID LangID)
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:72
PCWSTR SelectedLanguageId
Definition: usetup.c:68
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510

Referenced by PrepareAndDoCopyThread(), and RegistryPage().

Variable Documentation

◆ InfUnattendSignature

PCWSTR InfUnattendSignature = L"$ReactOS$"
static

Definition at line 28 of file setuplib.c.

Referenced by CheckUnattendedSetup(), and IsInfUnattendSetupEnabled().

◆ IsUnattendedSetup

BOOLEAN IsUnattendedSetup = FALSE

◆ ProcessHeap

HANDLE ProcessHeap
  • Internal Headers *‍/

Definition at line 26 of file setuplib.c.