ReactOS 0.4.17-dev-573-g8315b8c
setuplib.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Setup Library
4 * FILE: base/setup/lib/setuplib.c
5 * PURPOSE: Setup Library - Main initialization helpers
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10/* INCLUDES *****************************************************************/
11
12#include "precomp.h"
13#include "filesup.h"
14#include "infsupp.h"
15#include "inicache.h"
16
17#include "setuplib.h"
18
19#define NDEBUG
20#include <debug.h>
21
22
23/* GLOBALS ******************************************************************/
24
27
28/* FUNCTIONS ****************************************************************/
29
33 IN OUT PUSETUP_DATA pSetupData)
34{
36 HINF UnattendInf;
37 UINT ErrorLine;
38 INT IntValue;
40 WCHAR UnattendInfPath[MAX_PATH];
41
42 CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2,
43 pSetupData->SourcePath.Buffer, L"unattend.inf");
44
45 DPRINT("UnattendInf path: '%S'\n", UnattendInfPath);
46
47 if (DoesFileExist(NULL, UnattendInfPath) == FALSE)
48 {
49 DPRINT("Does not exist: %S\n", UnattendInfPath);
50 return IsUnattendedSetup;
51 }
52
53 /* Load 'unattend.inf' from installation media */
54 UnattendInf = SpInfOpenInfFile(UnattendInfPath,
55 NULL,
57 pSetupData->LanguageId,
58 &ErrorLine);
59 if (UnattendInf == INVALID_HANDLE_VALUE)
60 {
61 DPRINT("SpInfOpenInfFile() failed\n");
62 return IsUnattendedSetup;
63 }
64
65 /* Open 'Unattend' section */
66 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"Signature", &Context))
67 {
68 DPRINT("SpInfFindFirstLine() failed for section 'Unattend'\n");
69 goto Quit;
70 }
71
72 /* Get pointer 'Signature' key */
73 if (!INF_GetData(&Context, NULL, &Value))
74 {
75 DPRINT("INF_GetData() failed for key 'Signature'\n");
76 goto Quit;
77 }
78
79 /* Check 'Signature' string */
80 if (_wcsicmp(Value, L"$ReactOS$") != 0)
81 {
82 DPRINT("Signature not $ReactOS$\n");
84 goto Quit;
85 }
86
88
89 /* Check if Unattend setup is enabled */
90 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"UnattendSetupEnabled", &Context))
91 {
92 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
93 goto Quit;
94 }
95
96 if (!INF_GetData(&Context, NULL, &Value))
97 {
98 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
99 goto Quit;
100 }
101
102 if (_wcsicmp(Value, L"yes") != 0)
103 {
104 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
106 goto Quit;
107 }
108
110
111 /* Search for 'DestinationDiskNumber' */
112 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context))
113 {
114 DPRINT("SpInfFindFirstLine() failed for key 'DestinationDiskNumber'\n");
115 goto Quit;
116 }
117
118 if (!SpInfGetIntField(&Context, 1, &IntValue))
119 {
120 DPRINT("SpInfGetIntField() failed for key 'DestinationDiskNumber'\n");
121 goto Quit;
122 }
123
124 pSetupData->DestinationDiskNumber = (LONG)IntValue;
125
126 /* Search for 'DestinationPartitionNumber' */
127 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
128 {
129 DPRINT("SpInfFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
130 goto Quit;
131 }
132
133 if (!SpInfGetIntField(&Context, 1, &IntValue))
134 {
135 DPRINT("SpInfGetIntField() failed for key 'DestinationPartitionNumber'\n");
136 goto Quit;
137 }
138
139 pSetupData->DestinationPartitionNumber = (LONG)IntValue;
140
141 /* Search for 'InstallationDirectory' (optional) */
142 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"InstallationDirectory", &Context))
143 {
144 if (INF_GetData(&Context, NULL, &Value))
145 {
146 RtlStringCchCopyW(pSetupData->InstallationDirectory,
147 ARRAYSIZE(pSetupData->InstallationDirectory),
148 Value);
150 }
151 else
152 {
153 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
154 }
155 }
156
158 DPRINT("Running unattended setup\n");
159
160 /* Search for 'BootLoaderLocation' (optional) */
161 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"BootLoaderLocation", &Context))
162 {
163 if (SpInfGetIntField(&Context, 1, &IntValue))
164 pSetupData->BootLoaderLocation = IntValue;
165 }
166
167 /* Search for 'FormatPartition' (optional) */
168 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FormatPartition", &Context))
169 {
170 if (SpInfGetIntField(&Context, 1, &IntValue))
171 pSetupData->FormatPartition = IntValue;
172 }
173
174 /* Search for 'AutoPartition' (optional) */
175 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"AutoPartition", &Context))
176 {
177 if (SpInfGetIntField(&Context, 1, &IntValue))
178 pSetupData->AutoPartition = IntValue;
179 }
180
181 /* Search for 'LocaleID' (optional) */
182 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"LocaleID", &Context))
183 {
184 if (INF_GetData(&Context, NULL, &Value))
185 {
186 LONG Id = wcstol(Value, NULL, 16);
187 RtlStringCchPrintfW(pSetupData->LocaleID,
188 ARRAYSIZE(pSetupData->LocaleID),
189 L"%08lx", Id);
191 }
192 }
193
194 /* Search for 'FsType' (optional) */
195 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FsType", &Context))
196 {
197 if (SpInfGetIntField(&Context, 1, &IntValue))
198 pSetupData->FsType = IntValue;
199 }
200
201Quit:
202 SpInfCloseInfFile(UnattendInf);
203 return IsUnattendedSetup;
204}
205
206VOID
207NTAPI
209 IN OUT PUSETUP_DATA pSetupData)
210{
212 PINICACHE IniCache;
213
214#if 0 // HACK FIXME!
215 PINICACHE UnattendCache;
217#else
218 // WCHAR CrLf[] = {L'\r', L'\n'};
219 CHAR CrLf[] = {'\r', '\n'};
220 HANDLE FileHandle, UnattendFileHandle, SectionHandle;
223 PVOID ViewBase;
227#endif
228
229 PINI_SECTION IniSection;
230 WCHAR PathBuffer[MAX_PATH];
231 WCHAR UnattendInfPath[MAX_PATH];
232
233 /* Create a $winnt$.inf file with default entries */
234 IniCache = IniCacheCreate();
235 if (!IniCache)
236 return;
237
238#if 0 /* If you need to put something in this section, do it after the merge with Unattend.inf */
239 IniSection = IniAddSection(IniCache, L"SetupParams");
240 if (IniSection)
241 {
242 /* Key "skipmissingfiles" */
243 // RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
244 // L"\"%s\"", L"WinNt5.2");
245 // IniAddKey(IniSection, L"Version", PathBuffer);
246 }
247#endif
248
249 IniSection = IniAddSection(IniCache, L"Data");
250 if (IniSection)
251 {
252 RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
253 L"\"%s\"", IsUnattendedSetup ? L"yes" : L"no");
254 IniAddKey(IniSection, L"UnattendedInstall", PathBuffer);
255
256 // "floppylessbootpath" (yes/no)
257
258 RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
259 L"\"%s\"", L"winnt");
260 IniAddKey(IniSection, L"ProductType", PathBuffer);
261
262 RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
263 L"\"%s\\\"", pSetupData->SourceRootPath.Buffer);
264 IniAddKey(IniSection, L"SourcePath", PathBuffer);
265
266 // "floppyless" ("0")
267 }
268
269#if 0
270
271 /* TODO: Append the standard unattend.inf file */
272 CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2,
273 pSetupData->SourcePath.Buffer, L"unattend.inf");
274 if (DoesFileExist(NULL, UnattendInfPath) == FALSE)
275 {
276 DPRINT("Does not exist: %S\n", UnattendInfPath);
277 goto Quit;
278 }
279
280 Status = IniCacheLoad(&UnattendCache, UnattendInfPath, FALSE);
281 if (!NT_SUCCESS(Status))
282 {
283 DPRINT1("Cannot load %S as an INI file!\n", UnattendInfPath);
284 goto Quit;
285 }
286
287 IniCacheDestroy(UnattendCache);
288
289Quit:
290 CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
291 pSetupData->DestinationPath.Buffer, L"System32\\$winnt$.inf");
292 IniCacheSave(IniCache, PathBuffer);
293 IniCacheDestroy(IniCache);
294
295#else
296
297 CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
298 pSetupData->DestinationPath.Buffer, L"System32\\$winnt$.inf");
299 IniCacheSave(IniCache, PathBuffer);
300 IniCacheDestroy(IniCache);
301
302 /* TODO: Append the standard unattend.inf file */
303 CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2,
304 pSetupData->SourcePath.Buffer, L"unattend.inf");
305 if (DoesFileExist(NULL, UnattendInfPath) == FALSE)
306 {
307 DPRINT("Does not exist: %S\n", UnattendInfPath);
308 return;
309 }
310
311 RtlInitUnicodeString(&FileName, PathBuffer);
313 &FileName,
315 NULL,
316 NULL);
323 if (!NT_SUCCESS(Status))
324 {
325 DPRINT1("Cannot load %S as an INI file!\n", PathBuffer);
326 return;
327 }
328
329 /* Query the file size */
332 &FileInfo,
333 sizeof(FileInfo),
335 if (!NT_SUCCESS(Status))
336 {
337 DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
338 FileInfo.EndOfFile.QuadPart = 0ULL;
339 }
340
342 UnattendInfPath,
343 &UnattendFileHandle,
344 &FileSize,
345 &SectionHandle,
346 &ViewBase,
347 FALSE);
348 if (!NT_SUCCESS(Status))
349 {
350 DPRINT1("Cannot load %S !\n", UnattendInfPath);
352 return;
353 }
354
355 /* Write to the INI file */
356
357 /* "\r\n" */
359 NULL,
360 NULL,
361 NULL,
363 (PVOID)CrLf,
364 sizeof(CrLf),
365 &FileInfo.EndOfFile,
366 NULL);
367
369 NULL,
370 NULL,
371 NULL,
373 ViewBase,
374 FileSize,
375 NULL,
376 NULL);
377 if (!NT_SUCCESS(Status))
378 {
379 DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
380 }
381
382 /* Finally, unmap and close the file */
383 UnMapAndCloseFile(UnattendFileHandle, SectionHandle, ViewBase);
384
386#endif
387}
388
411 _Out_ PUNICODE_STRING SourcePath,
412 _Out_ PUNICODE_STRING SourceRootPath,
413 _Out_ PUNICODE_STRING SourceRootDir)
414{
417 PWCHAR Ptr;
418 HANDLE LinkHandle;
421 struct { OBJECT_NAME_INFORMATION; WCHAR Buffer[MAX_PATH]; } ImageFileBuffer;
422 PUNICODE_STRING InstallSourcePath = &ImageFileBuffer.Name;
423 struct { OBJECT_NAME_INFORMATION; WCHAR Buffer[MAX_PATH]; } SystemRootBuffer;
424 PUNICODE_STRING SystemRootPath = &SystemRootBuffer.Name;
425 const UNICODE_STRING SystemRoot = RTL_CONSTANT_STRING(L"\\SystemRoot");
426
427 /* Retrieve the installer's full image file path */
428 RtlInitEmptyUnicodeString(InstallSourcePath,
429 ImageFileBuffer.Buffer,
430 sizeof(ImageFileBuffer.Buffer));
431 BufferSize = sizeof(ImageFileBuffer);
434 InstallSourcePath,
436 NULL);
437 // STATUS_INFO_LENGTH_MISMATCH or STATUS_BUFFER_TOO_SMALL ?
438 if (!NT_SUCCESS(Status))
439 return Status;
440 ASSERT(InstallSourcePath->Length < InstallSourcePath->MaximumLength);
441
442 /* Go to the beginning of the path component, stop at the separator */
443 Ptr = ImageFileBuffer.Buffer + (InstallSourcePath->Length / sizeof(WCHAR));
444 while ((Ptr > ImageFileBuffer.Buffer) && (*Ptr != OBJ_NAME_PATH_SEPARATOR))
445 --Ptr;
446 /* Strip the trailing file name (at the separator or beginning of buffer)
447 * and manually NULL-terminate */
448 InstallSourcePath->Length = (ULONG_PTR)Ptr - (ULONG_PTR)ImageFileBuffer.Buffer;
449 InstallSourcePath->Buffer[InstallSourcePath->Length / sizeof(WCHAR)] = UNICODE_NULL;
450
451
452 /*
453 * Now, resolve the \SystemRoot symlink target full path.
454 *
455 * The symlink target path resolution requires reparsing, because it
456 * can reference other symlinks. This is what happens, for example when
457 * booting the installation from a removable hard-disk. We can have:
458 *
459 * \SystemRoot ---> \Device\Harddisk1\Partition1\ReactOS
460 * and: \Device\Harddisk1\Partition1 ---> \Device\HarddiskVolume2
461 * etc.
462 * and we wish to resolve \SystemRoot to: \Device\HarddiskVolume2\ReactOS
463 *
464 * We then verify whether it prefixes the image file path obtained
465 * from the step above, which is a fully reparsed path.
466 *
467 * - Using NtOpenSymbolicLinkObject(SYMBOLIC_LINK_QUERY) followed by
468 * NtQuerySymbolicLinkObject() would only resolve the first symlink
469 * but not the others (\Device\Harddisk1\Partition1 left as is).
470 *
471 * - Since \SystemRoot has to point to a directory, we try opening
472 * the directory itself: NtOpenFile(..., FILE_DIRECTORY_FILE).
473 *
474 * - A call to NtQueryInformationFile(FileNameInformation) alone on
475 * the obtained handle would only retrieve the FS directory name,
476 * i.e. \ReactOS , but not the whole NT path.
477 *
478 * - We therefore use NtQueryObject(), which allows retrieving the
479 * full resolved NT path (device name + FS directory name).
480 */
481
485 NULL,
486 NULL);
487
488 RtlInitEmptyUnicodeString(SystemRootPath,
489 SystemRootBuffer.Buffer,
490 sizeof(SystemRootBuffer.Buffer));
491
492 Status = NtOpenFile(&LinkHandle,
498 /*| FILE_OPEN_FOR_BACKUP_INTENT*/);
499 if (NT_SUCCESS(Status))
500 {
501 /* Resolve the path and close its handle */
502 Status = NtQueryObject(LinkHandle,
504 &SystemRootBuffer,
505 sizeof(SystemRootBuffer),
506 &BufferSize);
507 NtClose(LinkHandle);
508 }
509 /* If any of the calls above failed, try to naively resolve the symlink */
510 if (!NT_SUCCESS(Status))
511 {
512 RtlInitEmptyUnicodeString(SystemRootPath,
513 SystemRootBuffer.Buffer,
514 sizeof(SystemRootBuffer.Buffer));
515
516 Status = NtOpenSymbolicLinkObject(&LinkHandle,
519 if (NT_SUCCESS(Status))
520 {
521 /* Resolve the link and close its handle */
523 SystemRootPath,
524 &BufferSize);
525 NtClose(LinkHandle);
526 }
527 }
528 ASSERT(SystemRootPath->Length < SystemRootPath->MaximumLength);
529
530 /*
531 * If the resolved \SystemRoot is a prefix of the image file path,
532 * use \SystemRoot instead as the installation source path.
533 *
534 * If opening the \SystemRoot link failed (usually due to wrong
535 * access rights), do not consider this as a fatal error, and
536 * use the image file path as the installation source path.
537 */
538 if (NT_SUCCESS(Status) && RtlPrefixUnicodeString(SystemRootPath, InstallSourcePath, TRUE))
539 InstallSourcePath = SystemRootPath;
540
541
542 /*
543 * Retrieve the different source path components.
544 */
545 RtlCreateUnicodeString(SourcePath, InstallSourcePath->Buffer);
546
547 /* Isolate and strip the trailing (source root) directory */
548 Ptr = wcsrchr(InstallSourcePath->Buffer, OBJ_NAME_PATH_SEPARATOR);
549 if (Ptr)
550 {
551 RtlCreateUnicodeString(SourceRootDir, Ptr);
552 *Ptr = UNICODE_NULL;
553 }
554 else
555 {
556 RtlCreateUnicodeString(SourceRootDir, L"");
557 }
558
559 RtlCreateUnicodeString(SourceRootPath, InstallSourcePath->Buffer);
560
561 return STATUS_SUCCESS;
562}
563
566 IN OUT PUSETUP_DATA pSetupData)
567{
569 UINT ErrorLine;
570 INT IntValue;
573
575 pSetupData->SourcePath.Buffer, L"txtsetup.sif");
576
577 DPRINT("SetupInf path: '%S'\n", FileNameBuffer);
578
579 pSetupData->SetupInf =
581 NULL,
583 pSetupData->LanguageId,
584 &ErrorLine);
585 if (pSetupData->SetupInf == INVALID_HANDLE_VALUE)
587
588 /* Open 'Version' section */
589 if (!SpInfFindFirstLine(pSetupData->SetupInf, L"Version", L"Signature", &Context))
591
592 /* Get pointer 'Signature' key */
593 if (!INF_GetData(&Context, NULL, &Value))
595
596 /* Check 'Signature' string */
597 if (_wcsicmp(Value, L"$ReactOS$") != 0 &&
598 _wcsicmp(Value, L"$Windows NT$") != 0)
599 {
602 }
603
605
606 /* Open 'DiskSpaceRequirements' section */
607 if (!SpInfFindFirstLine(pSetupData->SetupInf, L"DiskSpaceRequirements", L"FreeSysPartDiskSpace", &Context))
609
610 pSetupData->RequiredPartitionDiskSpace = ~0;
611
612 /* Get the 'FreeSysPartDiskSpace' value */
613 if (!SpInfGetIntField(&Context, 1, &IntValue))
615
616 pSetupData->RequiredPartitionDiskSpace = (ULONG)IntValue;
617
618 //
619 // Support "SetupSourceDevice" and "SetupSourcePath" in txtsetup.sif
620 // See CORE-9023
621 // Support for that should also be added in setupldr.
622 //
623
624 /* Update the Setup Source paths */
625 if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"SetupSourceDevice", &Context))
626 {
627 /*
628 * Get optional pointer 'SetupSourceDevice' key, its presence
629 * will dictate whether we also need 'SetupSourcePath'.
630 */
631 if (INF_GetData(&Context, NULL, &Value))
632 {
633 /* Free the old source root path string and create the new one */
634 RtlFreeUnicodeString(&pSetupData->SourceRootPath);
635 RtlCreateUnicodeString(&pSetupData->SourceRootPath, Value);
637
638 if (!SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"SetupSourcePath", &Context))
639 {
640 /* The 'SetupSourcePath' value is mandatory! */
642 }
643
644 /* Get pointer 'SetupSourcePath' key */
645 if (!INF_GetData(&Context, NULL, &Value))
646 {
647 /* The 'SetupSourcePath' value is mandatory! */
649 }
650
651 /* Free the old source path string and create the new one */
652 RtlFreeUnicodeString(&pSetupData->SourceRootDir);
653 RtlCreateUnicodeString(&pSetupData->SourceRootDir, Value);
655 }
656 }
657
658 /* Search for 'DefaultPath' in the 'SetupData' section */
659 pSetupData->InstallationDirectory[0] = 0;
660 if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"DefaultPath", &Context))
661 {
662 /* Get pointer 'DefaultPath' key */
663 if (!INF_GetData(&Context, NULL, &Value))
665
666 RtlStringCchCopyW(pSetupData->InstallationDirectory,
667 ARRAYSIZE(pSetupData->InstallationDirectory),
668 Value);
669
671 }
672
673 return ERROR_SUCCESS;
674}
675
680NTAPI
682 _In_ PPARTLIST PartitionList, /* HACK HACK! */
683 _In_ PPARTENTRY InstallPartition, /* HACK HACK! */
684 _Out_ PPARTENTRY* pSystemPartition, /* HACK HACK! */
687{
690 PPARTENTRY OldActivePart;
691
692 /*
693 * If we install on a fixed disk, try to find a supported system
694 * partition on the system. Otherwise if we install on a removable disk
695 * use the install partition as the system partition.
696 */
697 if (InstallPartition->DiskEntry->MediaType == FixedMedia)
698 {
700 FALSE,
703 /* Use the original system partition as the old active partition hint */
704 OldActivePart = PartitionList->SystemPartition;
705
708 {
709 DPRINT1("We are using a different system partition!!\n");
710
714 0);
715 if (Result != FSVOL_DOIT)
716 return FALSE;
717 }
718 }
719 else // if (InstallPartition->DiskEntry->MediaType == RemovableMedia)
720 {
722 /* Don't specify any old active partition hint */
723 OldActivePart = NULL;
724 }
725
726 if (!SystemPartition)
727 {
731 0);
732 return FALSE;
733 }
734
735 *pSystemPartition = SystemPartition;
736
737 /*
738 * If the system partition can be created in some
739 * non-partitioned space, create it now.
740 */
742 {
743 /* Automatically create the partition; it will be
744 * formatted later with default parameters */
745 // FIXME: Don't use the whole empty space, but a minimal size
746 // specified from the TXTSETUP.SIF or unattended setup.
749 0ULL,
750 0);
752 }
753
754 /* Set it as such */
756 {
757 DPRINT1("SetActivePartition(0x%p) failed?!\n", SystemPartition);
758 ASSERT(FALSE);
759 }
760
761 /*
762 * In all cases, whether or not we are going to perform a formatting,
763 * we must perform a filesystem check of the system partition.
764 */
767
768 return TRUE;
769}
770
771
772#define IS_PATH_SEPARATOR(c) ((c) == L'\\' || (c) == L'/')
773
780NTAPI
782 _In_ PCWSTR InstallDir)
783{
784 PCWCH p;
785
786 /* As with the NT installer, fail if the path is empty or "\\" */
787 p = InstallDir;
788 if (!*p || (IS_PATH_SEPARATOR(*p) && !*(p + 1)))
789 return FALSE;
790
791 /* The path must contain only valid characters */
792 for (p = InstallDir; *p; ++p)
793 {
795 return FALSE;
796 }
797
798 /*
799 * Loop over each path component and verify that each is a valid 8.3 name.
800 */
801 for (p = InstallDir; *p;)
802 {
803 PCWSTR Path;
806 BOOLEAN IsNameLegal, SpacesInName;
807
808 /* Skip any first separator */
809 if (IS_PATH_SEPARATOR(*p))
810 ++p;
811
812 /* Now skip past the path component until we reach the next separator */
813 Path = p;
814 while (*p && !IS_PATH_SEPARATOR(*p))
815 ++p;
816 if (p == Path)
817 {
818 /* Succeed if nothing else follows this separator; otherwise
819 * it's a separator and consecutive ones are not supported */
820 return (!*p);
821 }
822
823 /* Calculate the path component length */
824 Length = p - Path;
825
826 /* As with the NT installer, fail for '.' and '..';
827 * RtlIsNameLegalDOS8Dot3() would succeed otherwise */
828 if ((Length == 1 && *Path == '.') || (Length == 2 && *Path == '.' && *(Path + 1) == '.'))
829 return FALSE;
830
831 /* As with the NT installer, allow _only ONE trailing_ dot in
832 * the path component (but not 2 or more), by reducing Length
833 * in that case; RtlIsNameLegalDOS8Dot3() would fail otherwise */
834 if (Length > 1 && *(p - 2) != L'.' && *(p - 1) == L'.')
835 --Length;
836
837 if (Length == 0)
838 return FALSE;
839
840 /* Verify that the path component is a valid 8.3 name */
841 // if (Length > 8+1+3)
842 // return FALSE;
843 Name.Length = Name.MaximumLength = (USHORT)(Length * sizeof(WCHAR));
844 Name.Buffer = (PWCHAR)Path;
845 SpacesInName = FALSE;
846 IsNameLegal = RtlIsNameLegalDOS8Dot3(&Name, NULL, &SpacesInName);
847
848 /* If it isn't legal or contain spaces, fail */
849 if (!IsNameLegal || SpacesInName)
850 {
851 DPRINT("'%wZ' is %s 8.3 filename %s spaces\n",
852 &Name,
853 (IsNameLegal ? "a valid" : "an invalid"),
854 (SpacesInName ? "with" : "without"));
855 return FALSE;
856 }
857 /* Go to the next path component */
858 }
859
860 return TRUE;
861}
862
863
865NTAPI
867 _Inout_ PUSETUP_DATA pSetupData,
868 _In_ PCWSTR InstallationDir,
870{
872 PPARTENTRY PartEntry = Volume->PartEntry;
873 PDISKENTRY DiskEntry = PartEntry->DiskEntry;
875
876 ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
877
878 /* Create 'pSetupData->DestinationRootPath' string */
879 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
880 Status = RtlStringCchPrintfW(PathBuffer, _countof(PathBuffer),
881 L"%s\\", Volume->Info.DeviceName);
882 if (!NT_SUCCESS(Status))
883 {
884 DPRINT1("RtlStringCchPrintfW() failed with status 0x%08lx\n", Status);
885 return Status;
886 }
887
888 Status = RtlCreateUnicodeString(&pSetupData->DestinationRootPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
889
890 if (!NT_SUCCESS(Status))
891 {
892 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
893 return Status;
894 }
895
896 DPRINT("DestinationRootPath: %wZ\n", &pSetupData->DestinationRootPath);
897
898 // FIXME! Which variable to choose?
899 if (!InstallationDir)
900 InstallationDir = pSetupData->InstallationDirectory;
901
903 /* Create 'pSetupData->DestinationArcPath' */
904 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
905
906 if (DiskEntry->MediaType == FixedMedia)
907 {
908 if (DiskEntry->BiosFound)
909 {
910#if 1
911 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
912 L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
913 DiskEntry->HwFixedDiskNumber,
914 PartEntry->OnDiskPartitionNumber);
915#else
916 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
917 L"multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)\\",
918 DiskEntry->HwAdapterNumber,
919 DiskEntry->HwControllerNumber,
920 DiskEntry->HwFixedDiskNumber,
921 PartEntry->OnDiskPartitionNumber);
922#endif
923 DPRINT1("Fixed disk found by BIOS, using MULTI ARC path '%S'\n", PathBuffer);
924 }
925 else
926 {
927 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
928 L"scsi(%u)disk(%u)rdisk(%u)partition(%lu)\\",
929 DiskEntry->Port,
930 DiskEntry->Bus,
931 DiskEntry->Id,
932 PartEntry->OnDiskPartitionNumber);
933 DPRINT1("Fixed disk not found by BIOS, using SCSI ARC path '%S'\n", PathBuffer);
934 }
935 }
936 else // if (DiskEntry->MediaType == RemovableMedia)
937 {
938#if 1
939 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
940 L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
941 0, 1);
942 DPRINT1("Removable disk, using MULTI ARC path '%S'\n", PathBuffer);
943#else
944 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
945 L"signature(%08x)disk(%u)rdisk(%u)partition(%lu)\\",
946 DiskEntry->LayoutBuffer->Signature,
947 DiskEntry->Bus,
948 DiskEntry->Id,
949 PartEntry->OnDiskPartitionNumber);
950 DPRINT1("Removable disk, using SIGNATURE ARC path '%S'\n", PathBuffer);
951#endif
952 }
953
954 if (!NT_SUCCESS(Status))
955 {
956 DPRINT1("RtlStringCchPrintfW() failed with status 0x%08lx\n", Status);
957 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
958 return Status;
959 }
960
961 Status = ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallationDir);
962
963 if (!NT_SUCCESS(Status))
964 {
965 DPRINT1("ConcatPaths() failed with status 0x%08lx\n", Status);
966 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
967 return Status;
968 }
969
970 Status = RtlCreateUnicodeString(&pSetupData->DestinationArcPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
971
972 if (!NT_SUCCESS(Status))
973 {
974 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
975 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
976 return Status;
977 }
978
980 /* Create 'pSetupData->DestinationPath' string */
981 RtlFreeUnicodeString(&pSetupData->DestinationPath);
982 Status = CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
983 pSetupData->DestinationRootPath.Buffer, InstallationDir);
984
985 if (!NT_SUCCESS(Status))
986 {
987 DPRINT1("CombinePaths() failed with status 0x%08lx\n", Status);
988 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
989 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
990 return Status;
991 }
992
993 Status = RtlCreateUnicodeString(&pSetupData->DestinationPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
994
995 if (!NT_SUCCESS(Status))
996 {
997 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
998 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
999 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
1000 return Status;
1001 }
1002
1004 // FIXME: This is only temporary!! Must be removed later!
1005 Status = RtlCreateUnicodeString(&pSetupData->InstallPath, InstallationDir) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
1006
1007 if (!NT_SUCCESS(Status))
1008 {
1009 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
1010 RtlFreeUnicodeString(&pSetupData->DestinationPath);
1011 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
1012 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
1013 return Status;
1014 }
1015
1016 return STATUS_SUCCESS;
1017}
1018
1019// NTSTATUS
1021NTAPI
1023 _Inout_ PUSETUP_DATA pSetupData,
1024 _In_opt_ PSETUP_ERROR_ROUTINE ErrorRoutine,
1025 _In_ PSPFILE_EXPORTS pSpFileExports,
1026 _In_ PSPINF_EXPORTS pSpInfExports)
1027{
1030
1032 RtlZeroMemory(pSetupData, sizeof(*pSetupData));
1033
1034 /* Initialize error handling */
1035 pSetupData->LastErrorNumber = ERROR_SUCCESS;
1036 pSetupData->ErrorRoutine = ErrorRoutine;
1037
1038 /* Initialize global unicode strings */
1039 RtlInitUnicodeString(&pSetupData->SourcePath, NULL);
1040 RtlInitUnicodeString(&pSetupData->SourceRootPath, NULL);
1041 RtlInitUnicodeString(&pSetupData->SourceRootDir, NULL);
1042 RtlInitUnicodeString(&pSetupData->DestinationArcPath, NULL);
1043 RtlInitUnicodeString(&pSetupData->DestinationPath, NULL);
1044 RtlInitUnicodeString(&pSetupData->DestinationRootPath, NULL);
1045 RtlInitUnicodeString(&pSetupData->SystemRootPath, NULL);
1046
1047 // FIXME: This is only temporary!! Must be removed later!
1048 /***/RtlInitUnicodeString(&pSetupData->InstallPath, NULL);/***/
1049
1050 /* Initialize SpFile and SpInf support */
1051 RtlCopyMemory(&SpFileExports, pSpFileExports, sizeof(SpFileExports));
1052 RtlCopyMemory(&SpInfExports, pSpInfExports, sizeof(SpInfExports));
1053
1054 //
1055 // TODO: Load and start SetupDD, and ask it for the information
1056 //
1057
1058 /* Get the source path and source root path */
1059 Status = GetSourcePaths(&pSetupData->SourcePath,
1060 &pSetupData->SourceRootPath,
1061 &pSetupData->SourceRootDir);
1062 if (!NT_SUCCESS(Status))
1063 {
1064 DPRINT1("GetSourcePaths() failed (Status 0x%08lx)\n", Status);
1065 return ERROR_NO_SOURCE_DRIVE;
1066 }
1067 DPRINT1("SourcePath (1): '%wZ'\n", &pSetupData->SourcePath);
1068 DPRINT1("SourceRootPath (1): '%wZ'\n", &pSetupData->SourceRootPath);
1069 DPRINT1("SourceRootDir (1): '%wZ'\n", &pSetupData->SourceRootDir);
1070
1071 /* Set up default values */
1072 pSetupData->DestinationDiskNumber = 0;
1073 pSetupData->DestinationPartitionNumber = 1;
1074 pSetupData->BootLoaderLocation = 2; // Default to "System partition"
1075 pSetupData->FormatPartition = 0;
1076 pSetupData->AutoPartition = 0;
1077 pSetupData->FsType = 0;
1078
1079 /* Load 'txtsetup.sif' from the installation media */
1080 Error = LoadSetupInf(pSetupData);
1081 if (Error != ERROR_SUCCESS)
1082 {
1083 DPRINT1("LoadSetupInf() failed (Error 0x%lx)\n", Error);
1084 return Error;
1085 }
1086 DPRINT1("SourcePath (2): '%wZ'\n", &pSetupData->SourcePath);
1087 DPRINT1("SourceRootPath (2): '%wZ'\n", &pSetupData->SourceRootPath);
1088 DPRINT1("SourceRootDir (2): '%wZ'\n", &pSetupData->SourceRootDir);
1089
1090 /* Retrieve the target machine architecture type */
1091 // FIXME: This should be determined at runtime!!
1092 // FIXME: Allow for (pre-)installing on an architecture
1093 // different from the current one?
1094#if defined(SARCH_XBOX)
1095 pSetupData->ArchType = ARCH_Xbox;
1096// #elif defined(SARCH_PC98)
1097#else // TODO: Arc, UEFI
1098 pSetupData->ArchType = (IsNEC_98 ? ARCH_NEC98x86 : ARCH_PcAT);
1099#endif
1100
1101 return ERROR_SUCCESS;
1102}
1103
1104VOID
1105NTAPI
1107 IN OUT PUSETUP_DATA pSetupData)
1108{
1109 /* Destroy the computer settings list */
1110 if (pSetupData->ComputerList != NULL)
1111 {
1112 DestroyGenericList(pSetupData->ComputerList, TRUE);
1113 pSetupData->ComputerList = NULL;
1114 }
1115
1116 /* Destroy the display settings list */
1117 if (pSetupData->DisplayList != NULL)
1118 {
1119 DestroyGenericList(pSetupData->DisplayList, TRUE);
1120 pSetupData->DisplayList = NULL;
1121 }
1122
1123 /* Destroy the keyboard settings list */
1124 if (pSetupData->KeyboardList != NULL)
1125 {
1126 DestroyGenericList(pSetupData->KeyboardList, TRUE);
1127 pSetupData->KeyboardList = NULL;
1128 }
1129
1130 /* Destroy the keyboard layout list */
1131 if (pSetupData->LayoutList != NULL)
1132 {
1133 DestroyGenericList(pSetupData->LayoutList, TRUE);
1134 pSetupData->LayoutList = NULL;
1135 }
1136
1137 /* Destroy the languages list */
1138 if (pSetupData->LanguageList != NULL)
1139 {
1140 DestroyGenericList(pSetupData->LanguageList, FALSE);
1141 pSetupData->LanguageList = NULL;
1142 }
1143
1144 /* Close the Setup INF */
1145 SpInfCloseInfFile(pSetupData->SetupInf);
1146}
1147
1148/*
1149 * SIDEEFFECTS
1150 * Calls RegInitializeRegistry
1151 * Calls ImportRegistryFile
1152 * Calls SetDefaultPagefile
1153 * Calls SetMountedDeviceValues
1154 */
1156NTAPI
1158 IN OUT PUSETUP_DATA pSetupData,
1159 IN BOOLEAN RepairUpdateFlag, /* HACK HACK! */
1160 IN PPARTLIST PartitionList, /* HACK HACK! */
1161 IN WCHAR DestinationDriveLetter, /* HACK HACK! */
1162 IN PCWSTR SelectedLanguageId, /* HACK HACK! */
1164 IN PFONTSUBSTSETTINGS SubstSettings OPTIONAL)
1165{
1166 ERROR_NUMBER ErrorNumber;
1168 INFCONTEXT InfContext;
1169 PCWSTR Action;
1170 PCWSTR File;
1171 PCWSTR Section;
1173 BOOLEAN ShouldRepairRegistry = FALSE;
1175
1176 if (RepairUpdateFlag)
1177 {
1178 DPRINT1("TODO: Updating / repairing the registry is not completely implemented yet!\n");
1179
1180 /* Verify the registry hives and check whether we need to update or repair any of them */
1181 Status = VerifyRegistryHives(&pSetupData->DestinationPath, &ShouldRepairRegistry);
1182 if (!NT_SUCCESS(Status))
1183 {
1184 DPRINT1("VerifyRegistryHives failed, Status 0x%08lx\n", Status);
1185 ShouldRepairRegistry = FALSE;
1186 }
1187 if (!ShouldRepairRegistry)
1188 DPRINT1("No need to repair the registry\n");
1189 }
1190
1191DoUpdate:
1192 ErrorNumber = ERROR_SUCCESS;
1193
1194 /* Update the registry */
1196
1197 /* Initialize the registry and setup the registry hives */
1198 Status = RegInitializeRegistry(&pSetupData->DestinationPath);
1199 if (!NT_SUCCESS(Status))
1200 {
1201 DPRINT1("RegInitializeRegistry() failed\n");
1202 /********** HACK!!!!!!!!!!! **********/
1204 {
1205 /* The hack was called, return its corresponding error */
1207 }
1208 else
1209 /*************************************/
1210 {
1211 /* Something else failed */
1212 return ERROR_CREATE_HIVE;
1213 }
1214 }
1215
1216 if (!RepairUpdateFlag || ShouldRepairRegistry)
1217 {
1218 /*
1219 * We fully setup the hives, in case we are doing a fresh installation
1220 * (RepairUpdateFlag == FALSE), or in case we are doing an update
1221 * (RepairUpdateFlag == TRUE) BUT we have some registry hives to
1222 * "repair" (aka. recreate: ShouldRepairRegistry == TRUE).
1223 */
1224
1225 Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Fresh", NULL, &InfContext); // Windows-compatible
1226 if (!Success)
1227 Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific
1228
1229 if (!Success)
1230 {
1231 DPRINT1("SpInfFindFirstLine() failed\n");
1232 ErrorNumber = ERROR_FIND_REGISTRY;
1233 goto Cleanup;
1234 }
1235 }
1236 else // if (RepairUpdateFlag && !ShouldRepairRegistry)
1237 {
1238 /*
1239 * In case we are doing an update (RepairUpdateFlag == TRUE) and
1240 * NO registry hives need a repair (ShouldRepairRegistry == FALSE),
1241 * we only update the hives.
1242 */
1243
1244 Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext);
1245 if (!Success)
1246 {
1247 /* Nothing to do for update! */
1248 DPRINT1("No update needed for the registry!\n");
1249 goto Cleanup;
1250 }
1251 }
1252
1253 do
1254 {
1255 INF_GetDataField(&InfContext, 0, &Action);
1256 INF_GetDataField(&InfContext, 1, &File);
1257 INF_GetDataField(&InfContext, 2, &Section);
1258
1259 DPRINT("Action: %S File: %S Section %S\n", Action, File, Section);
1260
1261 if (Action == NULL)
1262 {
1265 INF_FreeData(Section);
1266 break; // Hackfix
1267 }
1268
1269 if (!_wcsicmp(Action, L"AddReg"))
1270 Delete = FALSE;
1271 else if (!_wcsicmp(Action, L"DelReg"))
1272 Delete = TRUE;
1273 else
1274 {
1275 DPRINT1("Unrecognized registry INF action '%S'\n", Action);
1278 INF_FreeData(Section);
1279 continue;
1280 }
1281
1283
1285
1286 if (!ImportRegistryFile(pSetupData->SourcePath.Buffer,
1287 File, Section,
1288 pSetupData->LanguageId, Delete))
1289 {
1290 DPRINT1("Importing %S failed\n", File);
1292 INF_FreeData(Section);
1293 ErrorNumber = ERROR_IMPORT_HIVE;
1294 goto Cleanup;
1295 }
1296 } while (SpInfFindNextLine(&InfContext, &InfContext));
1297
1298 if (!RepairUpdateFlag || ShouldRepairRegistry)
1299 {
1300 /* See the explanation for this test above */
1301
1303 PCWSTR LanguageId; // LocaleID;
1304
1305 Entry = GetCurrentListEntry(pSetupData->DisplayList);
1306 ASSERT(Entry);
1307 pSetupData->DisplayType = ((PGENENTRY)GetListEntryData(Entry))->Id;
1308 ASSERT(pSetupData->DisplayType);
1309
1310 /* Update display registry settings */
1312 if (!ProcessDisplayRegistry(pSetupData->SetupInf, pSetupData->DisplayType))
1313 {
1314 ErrorNumber = ERROR_UPDATE_DISPLAY_SETTINGS;
1315 goto Cleanup;
1316 }
1317
1318 Entry = GetCurrentListEntry(pSetupData->LanguageList);
1319 ASSERT(Entry);
1320 LanguageId = ((PGENENTRY)GetListEntryData(Entry))->Id;
1321 ASSERT(LanguageId);
1322
1323 /* Set the locale */
1325 if (!ProcessLocaleRegistry(/*pSetupData->*/LanguageId))
1326 {
1327 ErrorNumber = ERROR_UPDATE_LOCALESETTINGS;
1328 goto Cleanup;
1329 }
1330
1331 /* Add the keyboard layouts for the given language (without user override) */
1334 {
1335 ErrorNumber = ERROR_ADDING_KBLAYOUTS;
1336 goto Cleanup;
1337 }
1338
1339 Entry = GetCurrentListEntry(pSetupData->LayoutList);
1340 ASSERT(Entry);
1341 pSetupData->LayoutId = ((PGENENTRY)GetListEntryData(Entry))->Id;
1342 ASSERT(pSetupData->LayoutId);
1343
1344 /* Update keyboard layout settings with user-overridden values */
1345 // FIXME: Wouldn't it be better to do it all at once
1346 // with the AddKeyboardLayouts() step?
1348 if (!ProcessKeyboardLayoutRegistry(pSetupData->LayoutId, SelectedLanguageId))
1349 {
1350 ErrorNumber = ERROR_UPDATE_KBSETTINGS;
1351 goto Cleanup;
1352 }
1353
1354 /* Set GeoID */
1356 {
1357 ErrorNumber = ERROR_UPDATE_GEOID;
1358 goto Cleanup;
1359 }
1360
1361 /* Add codepage information to registry */
1364 {
1365 ErrorNumber = ERROR_ADDING_CODEPAGE;
1366 goto Cleanup;
1367 }
1368
1369 /* Set the default pagefile entry */
1370 SetDefaultPagefile(DestinationDriveLetter);
1371
1372 /* Update the mounted devices list */
1373 // FIXME: This should technically be done by mountmgr (if AutoMount is enabled)!
1375 }
1376
1377#ifdef __REACTOS__
1378 if (SubstSettings)
1379 {
1380 /* HACK */
1381 DoRegistryFontFixup(SubstSettings, wcstoul(SelectedLanguageId, NULL, 16));
1382 }
1383#endif
1384
1385Cleanup:
1386 //
1387 // TODO: Unload all the registry stuff, perform cleanup,
1388 // and copy the created hive files into .sav files.
1389 //
1390 RegCleanupRegistry(&pSetupData->DestinationPath);
1391
1392 /*
1393 * Check whether we were in update/repair mode but we were actually
1394 * repairing the registry hives. If so, we have finished repairing them,
1395 * and we now reset the flag and run the proper registry update.
1396 * Otherwise we have finished the registry update!
1397 */
1398 if (RepairUpdateFlag && ShouldRepairRegistry)
1399 {
1400 ShouldRepairRegistry = FALSE;
1401 goto DoUpdate;
1402 }
1403
1404 return ErrorNumber;
1405}
1406
1407/* EOF */
DWORD Id
@ ObjectNameInformation
Definition: DriverTester.h:55
PRTL_UNICODE_STRING_BUFFER Path
unsigned char BOOLEAN
Definition: actypes.h:127
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
EXTERN_C NTSTATUS WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG)
#define DPRINT1
Definition: precomp.h:8
static BOOL ImportRegistryFile(HWND hWnd)
Definition: framewnd.c:462
WCHAR FileNameBuffer[MAX_PATH]
Definition: framewnd.c:248
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
static FSVOL_OP CALLBACK FsVolCallback(_In_opt_ PVOID Context, _In_ FSVOLNOTIFY FormatStatus, _In_ ULONG_PTR Param1, _In_ ULONG_PTR Param2)
Definition: reactos.c:1407
PPARTENTRY InstallPartition
Definition: reactos.c:28
PPARTENTRY SystemPartition
Definition: reactos.c:33
BOOL Error
Definition: chkdsk.c:66
@ ProcessImageFileName
Definition: cicbase.cpp:66
Definition: bufpool.h:45
Definition: File.h:16
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define BufferSize
Definition: mmc.h:75
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSTR Name
Definition: desk.c:124
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static const WCHAR SystemRoot[]
Definition: reg.c:38
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
#define wcsrchr
Definition: compat.h:16
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define FILE_SHARE_READ
Definition: compat.h:136
#define SYMBOLIC_LINK_QUERY
Definition: volume.c:47
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2917
_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
static const WCHAR Cleanup[]
Definition: register.c:80
#define L(x)
Definition: resources.c:13
#define ULONG_PTR
Definition: config.h:101
enum _ERROR_NUMBER ERROR_NUMBER
@ ERROR_ADDING_CODEPAGE
Definition: errorcode.h:52
@ ERROR_SIGNATURE_TXTSETUPSIF
Definition: errorcode.h:26
@ ERROR_CORRUPT_TXTSETUPSIF
Definition: errorcode.h:25
@ ERROR_UPDATE_GEOID
Definition: errorcode.h:55
@ ERROR_LOAD_TXTSETUPSIF
Definition: errorcode.h:24
@ 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_NO_SOURCE_DRIVE
Definition: errorcode.h:23
@ ERROR_UPDATE_DISPLAY_SETTINGS
Definition: errorcode.h:38
@ ERROR_UPDATE_KBSETTINGS
Definition: errorcode.h:37
@ Success
Definition: eventcreate.c:712
struct _FileName FileName
Definition: fatprocs.h:897
NTSTATUS CombinePaths(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:664
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:879
NTSTATUS ConcatPaths(IN OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:642
#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress)
Definition: filesup.h:121
#define DoesFileExist(RootDirectory, FileName)
Definition: filesup.h:83
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:24
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int UINT
Definition: sysinfo.c:13
#define SpInfFindNextLine
Definition: infsupp.h:141
#define INF_STYLE_OLDNT
Definition: infsupp.h:39
#define INF_STYLE_WIN4
Definition: infsupp.h:43
#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
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
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
SPFILE_EXPORTS SpFileExports
Definition: fileqsup.c:23
SPINF_EXPORTS SpInfExports
Definition: infsupp.c:24
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
Definition: infsupp.c:29
BOOLEAN INF_GetData(IN PINFCONTEXT Context, OUT PCWSTR *Key, OUT PCWSTR *Data)
Definition: infsupp.c:77
VOID NTAPI DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
Definition: genlist.c:38
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
UNICODE_STRING Volume
Definition: fltkernel.h:1172
#define ASSERT(a)
Definition: mode.c:44
static const char const char const char PIMAGEHLP_STATUS_ROUTINE StatusRoutine
Definition: image.c:35
#define ULL(a, b)
Definition: format_msg.c:27
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
#define _Inout_
Definition: no_sal2.h:162
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
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
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 VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentProcess()
Definition: nt_native.h:1660
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
#define FILE_APPEND_DATA
Definition: nt_native.h:634
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3420
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
#define RTL_NUMBER_OF_FIELD(type, field)
Definition: ntbasedef.h:715
CONST WCHAR * PCWCH
Definition: ntbasedef.h:423
#define UNICODE_NULL
@ FixedMedia
Definition: ntdddisk.h:383
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:100
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
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
unsigned short USHORT
Definition: pedump.c:61
char CHAR
Definition: pedump.c:57
#define OBJ_OPENIF
Definition: winternl.h:229
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
BOOLEAN NTAPI RtlIsNameLegalDOS8Dot3(_In_ PUNICODE_STRING Name, _Inout_opt_ POEM_STRING OemName, _Inout_opt_ PBOOLEAN NameContainsSpaces)
Entry
Definition: section.c:5216
@ FSVOLNOTIFY_PARTITIONERROR
Definition: fsutil.h:149
@ ChangeSystemPartition
Definition: fsutil.h:156
enum _FSVOL_OP FSVOL_OP
@ FSVOL_DOIT
Definition: fsutil.h:166
FSVOL_OP(CALLBACK * PFSVOL_CALLBACK)(_In_opt_ PVOID Context, _In_ FSVOLNOTIFY FormatStatus, _In_ ULONG_PTR Param1, _In_ ULONG_PTR Param2)
Definition: fsutil.h:203
BOOLEAN SetMountedDeviceValues(_In_ PPARTLIST List)
Definition: partlist.c:3967
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
ERROR_NUMBER LoadSetupInf(IN OUT PUSETUP_DATA pSetupData)
Definition: setuplib.c:565
VOID NTAPI InstallSetupInfFile(IN OUT PUSETUP_DATA pSetupData)
Definition: setuplib.c:208
ERROR_NUMBER NTAPI InitializeSetup(_Inout_ PUSETUP_DATA pSetupData, _In_opt_ PSETUP_ERROR_ROUTINE ErrorRoutine, _In_ PSPFILE_EXPORTS pSpFileExports, _In_ PSPINF_EXPORTS pSpInfExports)
Definition: setuplib.c:1022
NTSTATUS NTAPI InitDestinationPaths(_Inout_ PUSETUP_DATA pSetupData, _In_ PCWSTR InstallationDir, _In_ PVOLENTRY Volume)
Definition: setuplib.c:866
HANDLE ProcessHeap
Definition: setuplib.c:25
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: setuplib.c:681
#define IS_PATH_SEPARATOR(c)
Definition: setuplib.c:772
BOOLEAN NTAPI CheckUnattendedSetup(IN OUT PUSETUP_DATA pSetupData)
Definition: setuplib.c:32
VOID NTAPI FinishSetup(IN OUT PUSETUP_DATA pSetupData)
Definition: setuplib.c:1106
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:410
BOOLEAN NTAPI IsValidInstallDirectory(_In_ PCWSTR InstallDir)
Verify whether the given directory is suitable for ReactOS installation. Each path component must be ...
Definition: setuplib.c:781
BOOLEAN IsUnattendedSetup
Definition: setuplib.c:26
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: setuplib.c:1157
#define ERROR_SYSTEM_PARTITION_NOT_FOUND
Definition: setuplib.h:188
@ ARCH_NEC98x86
Definition: setuplib.h:55
@ ARCH_PcAT
Definition: setuplib.h:54
@ ARCH_Xbox
Definition: setuplib.h:56
#define IS_VALID_INSTALL_PATH_CHAR(c)
Defines the class of characters valid for the installation directory.
Definition: setuplib.h:206
@ 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
VOID(__cdecl * PREGISTRY_STATUS_ROUTINE)(IN REGISTRY_STATUS,...)
Definition: setuplib.h:249
VOID(__cdecl * PSETUP_ERROR_ROUTINE)(IN struct _USETUP_DATA *,...)
Definition: setuplib.h:86
#define FileStandardInformation
Definition: propsheet.cpp:61
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
#define _countof(array)
Definition: sndvol32.h:70
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
_In_ PVOID Context
Definition: storport.h:2269
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
Definition: genlist.h:11
BOOLEAN IsPartitioned
Definition: partlist.h:82
PVOLENTRY Volume
Definition: partlist.h:95
struct _DISKENTRY * DiskEntry
Definition: partlist.h:66
ULONG OnDiskPartitionNumber
Definition: partlist.h:74
ULONG PartitionNumber
Definition: partlist.h:75
PPARTENTRY SystemPartition
Definition: partlist.h:181
USHORT MaximumLength
Definition: env_spec_w32.h:370
BOOLEAN NeedsCheck
Definition: partlist.h:51
BOOL DoRegistryFontFixup(PFONTSUBSTSETTINGS pSettings, LANGID LangID)
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
static PPARTLIST PartitionList
Definition: usetup.c:75
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:72
PCWSTR SelectedLanguageId
Definition: usetup.c:68
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
Definition: wdfchildlist.h:656
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_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
#define IsNEC_98
Definition: ketypes.h:979