ReactOS 0.4.15-dev-8434-g155a7c7
setuplib.h File Reference
#include "errorcode.h"
#include "spapisup/fileqsup.h"
#include "spapisup/infsupp.h"
#include "utils/linklist.h"
#include "utils/ntverrsrc.h"
#include "utils/bldrsup.h"
#include "utils/filesup.h"
#include "utils/fsrec.h"
#include "utils/genlist.h"
#include "utils/inicache.h"
#include "utils/partinfo.h"
#include "utils/partlist.h"
#include "utils/arcname.h"
#include "utils/osdetect.h"
#include "utils/regutil.h"
#include "bootcode.h"
#include "fsutil.h"
#include "bootsup.h"
#include "registry.h"
#include "mui.h"
#include "settings.h"
#include "install.h"
#include "substset.h"
Include dependency graph for setuplib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _USETUP_DATA
 

Macros

#define KB   ((ULONGLONG)1024)
 
#define MB   (KB*KB)
 
#define GB   (KB*KB*KB)
 
#define ERROR_SYSTEM_PARTITION_NOT_FOUND   (ERROR_LAST_ERROR_CODE + 1)
 

Typedefs

typedef VOID(__cdeclPSETUP_ERROR_ROUTINE) (IN struct _USETUP_DATA *,...)
 
typedef struct _USETUP_DATA USETUP_DATA
 
typedef struct _USETUP_DATAPUSETUP_DATA
 
typedef enum _REGISTRY_STATUS REGISTRY_STATUS
 
typedef VOID(__cdeclPREGISTRY_STATUS_ROUTINE) (IN REGISTRY_STATUS,...)
 

Enumerations

enum  _REGISTRY_STATUS {
  Success = 0 , RegHiveUpdate , ImportRegHive , DisplaySettingsUpdate ,
  LocaleSettingsUpdate , KeybLayouts , KeybSettingsUpdate , CodePageInfoUpdate
}
 

Functions

VOID CheckUnattendedSetup (IN OUT PUSETUP_DATA pSetupData)
 
VOID InstallSetupInfFile (IN OUT PUSETUP_DATA pSetupData)
 
NTSTATUS GetSourcePaths (OUT PUNICODE_STRING SourcePath, OUT PUNICODE_STRING SourceRootPath, OUT PUNICODE_STRING SourceRootDir)
 
ERROR_NUMBER LoadSetupInf (IN OUT PUSETUP_DATA pSetupData)
 
BOOLEAN 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.
 
NTSTATUS InitDestinationPaths (IN OUT PUSETUP_DATA pSetupData, IN PCWSTR InstallationDir, IN PPARTENTRY PartEntry)
 
ERROR_NUMBER InitializeSetup (IN OUT PUSETUP_DATA pSetupData, IN ULONG InitPhase)
 
VOID FinishSetup (IN OUT PUSETUP_DATA pSetupData)
 
ERROR_NUMBER 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
 

Macro Definition Documentation

◆ ERROR_SYSTEM_PARTITION_NOT_FOUND

#define ERROR_SYSTEM_PARTITION_NOT_FOUND   (ERROR_LAST_ERROR_CODE + 1)

Definition at line 170 of file setuplib.h.

◆ GB

#define GB   (KB*KB*KB)

Definition at line 57 of file setuplib.h.

◆ KB

#define KB   ((ULONGLONG)1024)

Definition at line 55 of file setuplib.h.

◆ MB

#define MB   (KB*KB)

Definition at line 56 of file setuplib.h.

Typedef Documentation

◆ PREGISTRY_STATUS_ROUTINE

typedef VOID(__cdecl * PREGISTRY_STATUS_ROUTINE) (IN REGISTRY_STATUS,...)

Definition at line 209 of file setuplib.h.

◆ PSETUP_ERROR_ROUTINE

typedef VOID(__cdecl * PSETUP_ERROR_ROUTINE) (IN struct _USETUP_DATA *,...)

Definition at line 66 of file setuplib.h.

◆ PUSETUP_DATA

◆ REGISTRY_STATUS

◆ USETUP_DATA

Enumeration Type Documentation

◆ _REGISTRY_STATUS

Enumerator
Success 
RegHiveUpdate 
ImportRegHive 
DisplaySettingsUpdate 
LocaleSettingsUpdate 
KeybLayouts 
KeybSettingsUpdate 
CodePageInfoUpdate 

Definition at line 197 of file setuplib.h.

198{
199 Success = 0,
@ KeybLayouts
Definition: setuplib.h:204
@ DisplaySettingsUpdate
Definition: setuplib.h:202
@ CodePageInfoUpdate
Definition: setuplib.h:206
@ LocaleSettingsUpdate
Definition: setuplib.h:203
@ RegHiveUpdate
Definition: setuplib.h:200
@ ImportRegHive
Definition: setuplib.h:201
@ KeybSettingsUpdate
Definition: setuplib.h:205
@ Success
Definition: setuplib.h:199
enum _REGISTRY_STATUS REGISTRY_STATUS

Function Documentation

◆ CheckUnattendedSetup()

VOID CheckUnattendedSetup ( IN OUT PUSETUP_DATA  pSetupData)

Definition at line 28 of file setuplib.c.

30{
32 HINF UnattendInf;
33 UINT ErrorLine;
34 INT IntValue;
36 WCHAR UnattendInfPath[MAX_PATH];
37
38 CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2,
39 pSetupData->SourcePath.Buffer, L"unattend.inf");
40
41 DPRINT("UnattendInf path: '%S'\n", UnattendInfPath);
42
43 if (DoesFileExist(NULL, UnattendInfPath) == FALSE)
44 {
45 DPRINT("Does not exist: %S\n", UnattendInfPath);
46 return;
47 }
48
49 /* Load 'unattend.inf' from installation media */
50 UnattendInf = SpInfOpenInfFile(UnattendInfPath,
51 NULL,
53 pSetupData->LanguageId,
54 &ErrorLine);
55 if (UnattendInf == INVALID_HANDLE_VALUE)
56 {
57 DPRINT("SpInfOpenInfFile() failed\n");
58 return;
59 }
60
61 /* Open 'Unattend' section */
62 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"Signature", &Context))
63 {
64 DPRINT("SpInfFindFirstLine() failed for section 'Unattend'\n");
65 goto Quit;
66 }
67
68 /* Get pointer 'Signature' key */
69 if (!INF_GetData(&Context, NULL, &Value))
70 {
71 DPRINT("INF_GetData() failed for key 'Signature'\n");
72 goto Quit;
73 }
74
75 /* Check 'Signature' string */
76 if (_wcsicmp(Value, L"$ReactOS$") != 0)
77 {
78 DPRINT("Signature not $ReactOS$\n");
80 goto Quit;
81 }
82
84
85 /* Check if Unattend setup is enabled */
86 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"UnattendSetupEnabled", &Context))
87 {
88 DPRINT("Can't find key 'UnattendSetupEnabled'\n");
89 goto Quit;
90 }
91
92 if (!INF_GetData(&Context, NULL, &Value))
93 {
94 DPRINT("Can't read key 'UnattendSetupEnabled'\n");
95 goto Quit;
96 }
97
98 if (_wcsicmp(Value, L"yes") != 0)
99 {
100 DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
102 goto Quit;
103 }
104
106
107 /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
108 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context))
109 {
110 DPRINT("SpInfFindFirstLine() failed for key 'DestinationDiskNumber'\n");
111 goto Quit;
112 }
113
114 if (!SpInfGetIntField(&Context, 1, &IntValue))
115 {
116 DPRINT("SpInfGetIntField() failed for key 'DestinationDiskNumber'\n");
117 goto Quit;
118 }
119
120 pSetupData->DestinationDiskNumber = (LONG)IntValue;
121
122 /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
123 if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
124 {
125 DPRINT("SpInfFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
126 goto Quit;
127 }
128
129 if (!SpInfGetIntField(&Context, 1, &IntValue))
130 {
131 DPRINT("SpInfGetIntField() failed for key 'DestinationPartitionNumber'\n");
132 goto Quit;
133 }
134
135 pSetupData->DestinationPartitionNumber = (LONG)IntValue;
136
137 /* Search for 'InstallationDirectory' in the 'Unattend' section (optional) */
138 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"InstallationDirectory", &Context))
139 {
140 /* Get pointer 'InstallationDirectory' key */
141 if (!INF_GetData(&Context, NULL, &Value))
142 {
143 DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
144 goto Quit;
145 }
146
147 RtlStringCchCopyW(pSetupData->InstallationDirectory,
148 ARRAYSIZE(pSetupData->InstallationDirectory),
149 Value);
150
152 }
153
155 DPRINT("Running unattended setup\n");
156
157 /* Search for 'MBRInstallType' in the 'Unattend' section */
158 pSetupData->MBRInstallType = -1;
159 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"MBRInstallType", &Context))
160 {
161 if (SpInfGetIntField(&Context, 1, &IntValue))
162 {
163 pSetupData->MBRInstallType = IntValue;
164 }
165 }
166
167 /* Search for 'FormatPartition' in the 'Unattend' section */
168 pSetupData->FormatPartition = 0;
169 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FormatPartition", &Context))
170 {
171 if (SpInfGetIntField(&Context, 1, &IntValue))
172 {
173 pSetupData->FormatPartition = IntValue;
174 }
175 }
176
177 pSetupData->AutoPartition = 0;
178 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"AutoPartition", &Context))
179 {
180 if (SpInfGetIntField(&Context, 1, &IntValue))
181 {
182 pSetupData->AutoPartition = IntValue;
183 }
184 }
185
186 /* Search for LocaleID in the 'Unattend' section */
187 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"LocaleID", &Context))
188 {
189 if (INF_GetData(&Context, NULL, &Value))
190 {
191 LONG Id = wcstol(Value, NULL, 16);
192 RtlStringCchPrintfW(pSetupData->LocaleID,
193 ARRAYSIZE(pSetupData->LocaleID),
194 L"%08lx", Id);
196 }
197 }
198
199 /* Search for FsType in the 'Unattend' section */
200 pSetupData->FsType = 0;
201 if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FsType", &Context))
202 {
203 if (SpInfGetIntField(&Context, 1, &IntValue))
204 {
205 pSetupData->FsType = IntValue;
206 }
207 }
208
209Quit:
210 SpInfCloseInfFile(UnattendInf);
211}
DWORD Id
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
NTSTATUS CombinePaths(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:681
#define DoesFileExist(RootDirectory, FileName)
Definition: filesup.h:77
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define INF_STYLE_OLDNT
Definition: infsupp.h:37
pSpInfGetIntField SpInfGetIntField
Definition: infsupp.c:91
pSpInfFindFirstLine SpInfFindFirstLine
Definition: infsupp.c:87
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
Definition: infsupp.h:157
pSpInfOpenInfFile SpInfOpenInfFile
Definition: infsupp.c:95
pSpInfCloseInfFile SpInfCloseInfFile
Definition: infsupp.c:86
BOOLEAN INF_GetData(IN PINFCONTEXT Context, OUT PCWSTR *Key, OUT PCWSTR *Data)
Definition: infsupp.c:90
unsigned int UINT
Definition: ndis.h:50
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
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOLEAN IsUnattendedSetup
Definition: reactos.c:41
#define DPRINT
Definition: sndvol32.h:73
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
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by _tWinMain(), and SetupStartPage().

◆ FinishSetup()

VOID FinishSetup ( IN OUT PUSETUP_DATA  pSetupData)

Definition at line 950 of file setuplib.c.

952{
953 /* Destroy the computer settings list */
954 if (pSetupData->ComputerList != NULL)
955 {
956 DestroyGenericList(pSetupData->ComputerList, TRUE);
957 pSetupData->ComputerList = NULL;
958 }
959
960 /* Destroy the display settings list */
961 if (pSetupData->DisplayList != NULL)
962 {
963 DestroyGenericList(pSetupData->DisplayList, TRUE);
964 pSetupData->DisplayList = NULL;
965 }
966
967 /* Destroy the keyboard settings list */
968 if (pSetupData->KeyboardList != NULL)
969 {
970 DestroyGenericList(pSetupData->KeyboardList, TRUE);
971 pSetupData->KeyboardList = NULL;
972 }
973
974 /* Destroy the keyboard layout list */
975 if (pSetupData->LayoutList != NULL)
976 {
977 DestroyGenericList(pSetupData->LayoutList, TRUE);
978 pSetupData->LayoutList = NULL;
979 }
980
981 /* Destroy the languages list */
982 if (pSetupData->LanguageList != NULL)
983 {
984 DestroyGenericList(pSetupData->LanguageList, FALSE);
985 pSetupData->LanguageList = NULL;
986 }
987
988 /* Close the Setup INF */
989 SpInfCloseInfFile(pSetupData->SetupInf);
990}
VOID DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
Definition: genlist.c:36

Referenced by _tWinMain(), and RunUSetup().

◆ GetSourcePaths()

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

Definition at line 394 of file setuplib.c.

398{
400 HANDLE LinkHandle;
402 UCHAR ImageFileBuffer[sizeof(UNICODE_STRING) + MAX_PATH * sizeof(WCHAR)];
403 PUNICODE_STRING InstallSourcePath = (PUNICODE_STRING)&ImageFileBuffer;
404 WCHAR SystemRootBuffer[MAX_PATH] = L"";
405 UNICODE_STRING SystemRootPath = RTL_CONSTANT_STRING(L"\\SystemRoot");
407 PWCHAR Ptr;
408
409 // FIXME: commented out to allow installation from USB
410#if 0
411 /* Determine the installation source path via the full path of the installer */
412 RtlInitEmptyUnicodeString(InstallSourcePath,
413 (PWSTR)((ULONG_PTR)ImageFileBuffer + sizeof(UNICODE_STRING)),
414 sizeof(ImageFileBuffer) - sizeof(UNICODE_STRING)
415 /* Reserve space for a NULL terminator */ - sizeof(UNICODE_NULL));
416 BufferSize = sizeof(ImageFileBuffer);
419 InstallSourcePath,
421 NULL);
422 // STATUS_INFO_LENGTH_MISMATCH or STATUS_BUFFER_TOO_SMALL ?
423 if (!NT_SUCCESS(Status))
424 return Status;
425
426 /* Manually NULL-terminate */
427 InstallSourcePath->Buffer[InstallSourcePath->Length / sizeof(WCHAR)] = UNICODE_NULL;
428
429 /* Strip the trailing file name */
430 Ptr = wcsrchr(InstallSourcePath->Buffer, OBJ_NAME_PATH_SEPARATOR);
431 if (Ptr)
432 *Ptr = UNICODE_NULL;
433 InstallSourcePath->Length = wcslen(InstallSourcePath->Buffer) * sizeof(WCHAR);
434#endif
435
436 /*
437 * Now resolve the full path to \SystemRoot. In case it prefixes
438 * the installation source path determined from the full path of
439 * the installer, we use instead the resolved \SystemRoot as the
440 * installation source path.
441 * Otherwise, we use instead the path from the full installer path.
442 */
443
445 &SystemRootPath,
447 NULL,
448 NULL);
449
450 Status = NtOpenSymbolicLinkObject(&LinkHandle,
453 if (!NT_SUCCESS(Status))
454 {
455 /*
456 * We failed at opening the \SystemRoot link (usually due to wrong
457 * access rights). Do not consider this as a fatal error, but use
458 * instead the image file path as the installation source path.
459 */
460 DPRINT1("NtOpenSymbolicLinkObject(%wZ) failed with Status 0x%08lx\n",
461 &SystemRootPath, Status);
462 goto InitPaths;
463 }
464
465 RtlInitEmptyUnicodeString(&SystemRootPath,
466 SystemRootBuffer,
467 sizeof(SystemRootBuffer));
468
469 /* Resolve the link and close its handle */
471 &SystemRootPath,
472 &BufferSize);
473 NtClose(LinkHandle);
474
475 if (!NT_SUCCESS(Status))
476 return Status; // Unexpected error
477
478 /* Check whether the resolved \SystemRoot is a prefix of the image file path */
479 // FIXME: commented out to allow installation from USB
480 // if (RtlPrefixUnicodeString(&SystemRootPath, InstallSourcePath, TRUE))
481 {
482 /* Yes it is, so we use instead SystemRoot as the installation source path */
483 InstallSourcePath = &SystemRootPath;
484 }
485
486
487InitPaths:
488 /*
489 * Retrieve the different source path components
490 */
491 RtlCreateUnicodeString(SourcePath, InstallSourcePath->Buffer);
492
493 /* Strip trailing directory */
494 Ptr = wcsrchr(InstallSourcePath->Buffer, OBJ_NAME_PATH_SEPARATOR);
495 if (Ptr)
496 {
497 RtlCreateUnicodeString(SourceRootDir, Ptr);
498 *Ptr = UNICODE_NULL;
499 }
500 else
501 {
502 RtlCreateUnicodeString(SourceRootDir, L"");
503 }
504
505 RtlCreateUnicodeString(SourceRootPath, InstallSourcePath->Buffer);
506
507 return STATUS_SUCCESS;
508}
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
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
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define wcsrchr
Definition: compat.h:16
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
struct _UNICODE_STRING UNICODE_STRING
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
@ ProcessImageFileName
Definition: winternl.h:397
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define SYMBOLIC_LINK_QUERY
Definition: nt_native.h:1265
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define UNICODE_NULL
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by InitializeSetup().

◆ InitDestinationPaths()

NTSTATUS InitDestinationPaths ( IN OUT PUSETUP_DATA  pSetupData,
IN PCWSTR  InstallationDir,
IN PPARTENTRY  PartEntry 
)

Equivalent of 'NTOS_INSTALLATION::SystemArcPath'

Equivalent of 'NTOS_INSTALLATION::SystemNtPath'

Equivalent of 'NTOS_INSTALLATION::PathComponent'

Definition at line 716 of file setuplib.c.

720{
722 PDISKENTRY DiskEntry = PartEntry->DiskEntry;
723 WCHAR PathBuffer[MAX_PATH];
724
725 ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
726
727 /* Create 'pSetupData->DestinationRootPath' string */
728 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
729 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
730 L"\\Device\\Harddisk%lu\\Partition%lu\\",
731 DiskEntry->DiskNumber,
732 PartEntry->PartitionNumber);
733
734 if (!NT_SUCCESS(Status))
735 {
736 DPRINT1("RtlStringCchPrintfW() failed with status 0x%08lx\n", Status);
737 return Status;
738 }
739
740 Status = RtlCreateUnicodeString(&pSetupData->DestinationRootPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
741
742 if (!NT_SUCCESS(Status))
743 {
744 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
745 return Status;
746 }
747
748 DPRINT("DestinationRootPath: %wZ\n", &pSetupData->DestinationRootPath);
749
750 // FIXME! Which variable to choose?
751 if (!InstallationDir)
752 InstallationDir = pSetupData->InstallationDirectory;
753
755 /* Create 'pSetupData->DestinationArcPath' */
756 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
757
758 if (DiskEntry->MediaType == FixedMedia)
759 {
760 if (DiskEntry->BiosFound)
761 {
762#if 1
763 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
764 L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
765 DiskEntry->HwFixedDiskNumber,
766 PartEntry->OnDiskPartitionNumber);
767#else
768 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
769 L"multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)\\",
770 DiskEntry->HwAdapterNumber,
771 DiskEntry->HwControllerNumber,
772 DiskEntry->HwFixedDiskNumber,
773 PartEntry->OnDiskPartitionNumber);
774#endif
775 DPRINT1("Fixed disk found by BIOS, using MULTI ARC path '%S'\n", PathBuffer);
776 }
777 else
778 {
779 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
780 L"scsi(%u)disk(%u)rdisk(%u)partition(%lu)\\",
781 DiskEntry->Port,
782 DiskEntry->Bus,
783 DiskEntry->Id,
784 PartEntry->OnDiskPartitionNumber);
785 DPRINT1("Fixed disk not found by BIOS, using SCSI ARC path '%S'\n", PathBuffer);
786 }
787 }
788 else // if (DiskEntry->MediaType == RemovableMedia)
789 {
790#if 1
791 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
792 L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
793 0, 1);
794 DPRINT1("Removable disk, using MULTI ARC path '%S'\n", PathBuffer);
795#else
796 Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
797 L"signature(%08x)disk(%u)rdisk(%u)partition(%lu)\\",
798 DiskEntry->LayoutBuffer->Signature,
799 DiskEntry->Bus,
800 DiskEntry->Id,
801 PartEntry->OnDiskPartitionNumber);
802 DPRINT1("Removable disk, using SIGNATURE ARC path '%S'\n", PathBuffer);
803#endif
804 }
805
806 if (!NT_SUCCESS(Status))
807 {
808 DPRINT1("RtlStringCchPrintfW() failed with status 0x%08lx\n", Status);
809 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
810 return Status;
811 }
812
813 Status = ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallationDir);
814
815 if (!NT_SUCCESS(Status))
816 {
817 DPRINT1("ConcatPaths() failed with status 0x%08lx\n", Status);
818 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
819 return Status;
820 }
821
822 Status = RtlCreateUnicodeString(&pSetupData->DestinationArcPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
823
824 if (!NT_SUCCESS(Status))
825 {
826 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
827 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
828 return Status;
829 }
830
832 /* Create 'pSetupData->DestinationPath' string */
833 RtlFreeUnicodeString(&pSetupData->DestinationPath);
834 Status = CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
835 pSetupData->DestinationRootPath.Buffer, InstallationDir);
836
837 if (!NT_SUCCESS(Status))
838 {
839 DPRINT1("CombinePaths() failed with status 0x%08lx\n", Status);
840 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
841 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
842 return Status;
843 }
844
845 Status = RtlCreateUnicodeString(&pSetupData->DestinationPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
846
847 if (!NT_SUCCESS(Status))
848 {
849 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
850 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
851 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
852 return Status;
853 }
854
856 // FIXME: This is only temporary!! Must be removed later!
857 Status = RtlCreateUnicodeString(&pSetupData->InstallPath, InstallationDir) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
858
859 if (!NT_SUCCESS(Status))
860 {
861 DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
862 RtlFreeUnicodeString(&pSetupData->DestinationPath);
863 RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
864 RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
865 return Status;
866 }
867
868 return STATUS_SUCCESS;
869}
NTSTATUS ConcatPaths(IN OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:659
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
@ FixedMedia
Definition: ntdddisk.h:383
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
ULONG HwAdapterNumber
Definition: partlist.h:100
ULONG HwControllerNumber
Definition: partlist.h:101
ULONG DiskNumber
Definition: partlist.h:108
BOOLEAN BiosFound
Definition: partlist.h:99
USHORT Bus
Definition: partlist.h:111
USHORT Id
Definition: partlist.h:112
USHORT Port
Definition: partlist.h:110
MEDIA_TYPE MediaType
Definition: partlist.h:85
ULONG HwFixedDiskNumber
Definition: partlist.h:103
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:122

Referenced by DriveDlgProc(), and InstallDirectoryPage().

◆ InitializeSetup()

ERROR_NUMBER InitializeSetup ( IN OUT PUSETUP_DATA  pSetupData,
IN ULONG  InitPhase 
)

Definition at line 873 of file setuplib.c.

876{
877 if (InitPhase == 0)
878 {
879 RtlZeroMemory(pSetupData, sizeof(*pSetupData));
880
881 /* Initialize error handling */
882 pSetupData->LastErrorNumber = ERROR_SUCCESS;
883 pSetupData->ErrorRoutine = NULL;
884
885 /* Initialize global unicode strings */
886 RtlInitUnicodeString(&pSetupData->SourcePath, NULL);
887 RtlInitUnicodeString(&pSetupData->SourceRootPath, NULL);
888 RtlInitUnicodeString(&pSetupData->SourceRootDir, NULL);
889 RtlInitUnicodeString(&pSetupData->DestinationArcPath, NULL);
890 RtlInitUnicodeString(&pSetupData->DestinationPath, NULL);
891 RtlInitUnicodeString(&pSetupData->DestinationRootPath, NULL);
892 RtlInitUnicodeString(&pSetupData->SystemRootPath, NULL);
893
894 // FIXME: This is only temporary!! Must be removed later!
895 /***/RtlInitUnicodeString(&pSetupData->InstallPath, NULL);/***/
896
897 //
898 // TODO: Load and start SetupDD, and ask it for the information
899 //
900
901 return ERROR_SUCCESS;
902 }
903 else
904 if (InitPhase == 1)
905 {
908
909 /* Get the source path and source root path */
910 //
911 // NOTE: Sometimes the source path may not be in SystemRoot !!
912 // (and this is the case when using the 1st-stage GUI setup!)
913 //
914 Status = GetSourcePaths(&pSetupData->SourcePath,
915 &pSetupData->SourceRootPath,
916 &pSetupData->SourceRootDir);
917 if (!NT_SUCCESS(Status))
918 {
919 DPRINT1("GetSourcePaths() failed (Status 0x%08lx)\n", Status);
921 }
922 /*
923 * Example of output:
924 * SourcePath: '\Device\CdRom0\I386'
925 * SourceRootPath: '\Device\CdRom0'
926 * SourceRootDir: '\I386'
927 */
928 DPRINT1("SourcePath (1): '%wZ'\n", &pSetupData->SourcePath);
929 DPRINT1("SourceRootPath (1): '%wZ'\n", &pSetupData->SourceRootPath);
930 DPRINT1("SourceRootDir (1): '%wZ'\n", &pSetupData->SourceRootDir);
931
932 /* Load 'txtsetup.sif' from the installation media */
933 Error = LoadSetupInf(pSetupData);
934 if (Error != ERROR_SUCCESS)
935 {
936 DPRINT1("LoadSetupInf() failed (Error 0x%lx)\n", Error);
937 return Error;
938 }
939 DPRINT1("SourcePath (2): '%wZ'\n", &pSetupData->SourcePath);
940 DPRINT1("SourceRootPath (2): '%wZ'\n", &pSetupData->SourceRootPath);
941 DPRINT1("SourceRootDir (2): '%wZ'\n", &pSetupData->SourceRootDir);
942
943 return ERROR_SUCCESS;
944 }
945
946 return ERROR_SUCCESS;
947}
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
ERROR_NUMBER LoadSetupInf(IN OUT PUSETUP_DATA pSetupData)
Definition: setuplib.c:511
NTSTATUS GetSourcePaths(OUT PUNICODE_STRING SourcePath, OUT PUNICODE_STRING SourceRootPath, OUT PUNICODE_STRING SourceRootDir)
Definition: setuplib.c:394
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by _tWinMain(), RunUSetup(), and SetupStartPage().

◆ InitSystemPartition()

BOOLEAN 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 626 of file setuplib.c.

632{
635 PPARTENTRY OldActivePart;
636
637 /*
638 * If we install on a fixed disk, try to find a supported system
639 * partition on the system. Otherwise if we install on a removable disk
640 * use the install partition as the system partition.
641 */
642 if (InstallPartition->DiskEntry->MediaType == FixedMedia)
643 {
645 FALSE,
648 /* Use the original system partition as the old active partition hint */
649 OldActivePart = PartitionList->SystemPartition;
650
653 {
654 DPRINT1("We are using a different system partition!!\n");
655
659 0);
660 if (Result != FSVOL_DOIT)
661 return FALSE;
662 }
663 }
664 else // if (InstallPartition->DiskEntry->MediaType == RemovableMedia)
665 {
667 /* Don't specify any old active partition hint */
668 OldActivePart = NULL;
669 }
670
671 if (!SystemPartition)
672 {
676 0);
677 return FALSE;
678 }
679
680 *pSystemPartition = SystemPartition;
681
682 /*
683 * If the system partition can be created in some
684 * non-partitioned space, create it now.
685 */
687 {
688 /* Automatically create the partition; it will be
689 * formatted later with default parameters */
690 // FIXME: Don't use the whole empty space, but a minimal size
691 // specified from the TXTSETUP.SIF or unattended setup.
694 0ULL,
695 0);
697 }
698
699 /* Set it as such */
701 {
702 DPRINT1("SetActivePartition(0x%p) failed?!\n", SystemPartition);
703 ASSERT(FALSE);
704 }
705
706 /*
707 * In all cases, whether or not we are going to perform a formatting,
708 * we must perform a filesystem check of the system partition.
709 */
711
712 return TRUE;
713}
#define ULL(a, b)
Definition: format_msg.c:27
@ FSVOLNOTIFY_PARTITIONERROR
Definition: fsutil.h:142
@ ChangeSystemPartition
Definition: fsutil.h:149
enum _FSVOL_OP FSVOL_OP
@ FSVOL_DOIT
Definition: fsutil.h:159
BOOLEAN CreatePartition(_In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
Definition: partlist.c:2844
BOOLEAN SetActivePartition(IN PPARTLIST List, IN PPARTENTRY PartEntry, IN PPARTENTRY OldActivePart OPTIONAL)
Definition: partlist.c:3515
PPARTENTRY FindSupportedSystemPartition(IN PPARTLIST List, IN BOOLEAN ForceSelect, IN PDISKENTRY AlternativeDisk OPTIONAL, IN PPARTENTRY AlternativePart OPTIONAL)
Definition: partlist.c:3215
#define ERROR_SYSTEM_PARTITION_NOT_FOUND
Definition: setuplib.h:170
BOOLEAN IsPartitioned
Definition: partlist.h:66
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
BOOLEAN NeedsCheck
Definition: partlist.h:74
PPARTENTRY SystemPartition
Definition: partlist.h:160
static FSVOL_OP CALLBACK FsVolCallback(_In_opt_ PVOID Context, _In_ FSVOLNOTIFY FormatStatus, _In_ ULONG_PTR Param1, _In_ ULONG_PTR Param2)
Definition: usetup.c:2594
static PPARTLIST PartitionList
Definition: usetup.c:71
static PPARTENTRY InstallPartition
Definition: usetup.c:48
static PPARTENTRY SystemPartition
Definition: usetup.c:59
_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 StartPartitionOperationsPage().

◆ InstallSetupInfFile()

VOID InstallSetupInfFile ( IN OUT PUSETUP_DATA  pSetupData)

Definition at line 214 of file setuplib.c.

216{
218 PINICACHE IniCache;
219
220#if 0 // HACK FIXME!
221 PINICACHE UnattendCache;
223#else
224 // WCHAR CrLf[] = {L'\r', L'\n'};
225 CHAR CrLf[] = {'\r', '\n'};
226 HANDLE FileHandle, UnattendFileHandle, SectionHandle;
229 PVOID ViewBase;
233#endif
234
235 PINI_SECTION IniSection;
236 WCHAR PathBuffer[MAX_PATH];
237 WCHAR UnattendInfPath[MAX_PATH];
238
239 /* Create a $winnt$.inf file with default entries */
240 IniCache = IniCacheCreate();
241 if (!IniCache)
242 return;
243
244 IniSection = IniAddSection(IniCache, L"SetupParams");
245 if (IniSection)
246 {
247 /* Key "skipmissingfiles" */
248 // RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
249 // L"\"%s\"", L"WinNt5.2");
250 // IniAddKey(IniSection, L"Version", PathBuffer);
251 }
252
253 IniSection = IniAddSection(IniCache, L"Data");
254 if (IniSection)
255 {
256 RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
257 L"\"%s\"", IsUnattendedSetup ? L"yes" : L"no");
258 IniAddKey(IniSection, L"UnattendedInstall", PathBuffer);
259
260 // "floppylessbootpath" (yes/no)
261
262 RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
263 L"\"%s\"", L"winnt");
264 IniAddKey(IniSection, L"ProductType", PathBuffer);
265
266 RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
267 L"\"%s\\\"", pSetupData->SourceRootPath.Buffer);
268 IniAddKey(IniSection, L"SourcePath", PathBuffer);
269
270 // "floppyless" ("0")
271 }
272
273#if 0
274
275 /* TODO: Append the standard unattend.inf file */
276 CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2,
277 pSetupData->SourcePath.Buffer, L"unattend.inf");
278 if (DoesFileExist(NULL, UnattendInfPath) == FALSE)
279 {
280 DPRINT("Does not exist: %S\n", UnattendInfPath);
281 goto Quit;
282 }
283
284 Status = IniCacheLoad(&UnattendCache, UnattendInfPath, FALSE);
285 if (!NT_SUCCESS(Status))
286 {
287 DPRINT1("Cannot load %S as an INI file!\n", UnattendInfPath);
288 goto Quit;
289 }
290
291 IniCacheDestroy(UnattendCache);
292
293Quit:
294 CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
295 pSetupData->DestinationPath.Buffer, L"System32\\$winnt$.inf");
296 IniCacheSave(IniCache, PathBuffer);
297 IniCacheDestroy(IniCache);
298
299#else
300
301 CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
302 pSetupData->DestinationPath.Buffer, L"System32\\$winnt$.inf");
303 IniCacheSave(IniCache, PathBuffer);
304 IniCacheDestroy(IniCache);
305
306 /* TODO: Append the standard unattend.inf file */
307 CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2,
308 pSetupData->SourcePath.Buffer, L"unattend.inf");
309 if (DoesFileExist(NULL, UnattendInfPath) == FALSE)
310 {
311 DPRINT("Does not exist: %S\n", UnattendInfPath);
312 return;
313 }
314
315 RtlInitUnicodeString(&FileName, PathBuffer);
317 &FileName,
319 NULL,
320 NULL);
327 if (!NT_SUCCESS(Status))
328 {
329 DPRINT1("Cannot load %S as an INI file!\n", PathBuffer);
330 return;
331 }
332
333 /* Query the file size */
336 &FileInfo,
337 sizeof(FileInfo),
339 if (!NT_SUCCESS(Status))
340 {
341 DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
342 FileInfo.EndOfFile.QuadPart = 0ULL;
343 }
344
346 UnattendInfPath,
347 &UnattendFileHandle,
348 &FileSize,
349 &SectionHandle,
350 &ViewBase,
351 FALSE);
352 if (!NT_SUCCESS(Status))
353 {
354 DPRINT1("Cannot load %S !\n", UnattendInfPath);
356 return;
357 }
358
359 /* Write to the INI file */
360
361 /* "\r\n" */
363 NULL,
364 NULL,
365 NULL,
367 (PVOID)CrLf,
368 sizeof(CrLf),
369 &FileInfo.EndOfFile,
370 NULL);
371
373 NULL,
374 NULL,
375 NULL,
377 ViewBase,
378 FileSize,
379 NULL,
380 NULL);
381 if (!NT_SUCCESS(Status))
382 {
383 DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
384 }
385
386 /* Finally, unmap and close the file */
387 UnMapAndCloseFile(UnattendFileHandle, SectionHandle, ViewBase);
388
390#endif
391}
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define FILE_SHARE_READ
Definition: compat.h:136
struct _FileName FileName
Definition: fatprocs.h:896
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:887
#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress)
Definition: filesup.h:115
_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
#define OBJ_OPENIF
Definition: winternl.h:229
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
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
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:3952
#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 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 FileStandardInformation
Definition: propsheet.cpp:61
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
Definition: wdfchildlist.h:656
char CHAR
Definition: xmlstorage.h:175

Referenced by FileCopyPage(), and PrepareAndDoCopyThread().

◆ LoadSetupInf()

ERROR_NUMBER LoadSetupInf ( IN OUT PUSETUP_DATA  pSetupData)

Definition at line 511 of file setuplib.c.

513{
515 UINT ErrorLine;
516 INT IntValue;
519
521 pSetupData->SourcePath.Buffer, L"txtsetup.sif");
522
523 DPRINT("SetupInf path: '%S'\n", FileNameBuffer);
524
525 pSetupData->SetupInf =
527 NULL,
529 pSetupData->LanguageId,
530 &ErrorLine);
531 if (pSetupData->SetupInf == INVALID_HANDLE_VALUE)
533
534 /* Open 'Version' section */
535 if (!SpInfFindFirstLine(pSetupData->SetupInf, L"Version", L"Signature", &Context))
537
538 /* Get pointer 'Signature' key */
539 if (!INF_GetData(&Context, NULL, &Value))
541
542 /* Check 'Signature' string */
543 if (_wcsicmp(Value, L"$ReactOS$") != 0 &&
544 _wcsicmp(Value, L"$Windows NT$") != 0)
545 {
548 }
549
551
552 /* Open 'DiskSpaceRequirements' section */
553 if (!SpInfFindFirstLine(pSetupData->SetupInf, L"DiskSpaceRequirements", L"FreeSysPartDiskSpace", &Context))
555
556 pSetupData->RequiredPartitionDiskSpace = ~0;
557
558 /* Get the 'FreeSysPartDiskSpace' value */
559 if (!SpInfGetIntField(&Context, 1, &IntValue))
561
562 pSetupData->RequiredPartitionDiskSpace = (ULONG)IntValue;
563
564 //
565 // Support "SetupSourceDevice" and "SetupSourcePath" in txtsetup.sif
566 // See CORE-9023
567 // Support for that should also be added in setupldr.
568 //
569
570 /* Update the Setup Source paths */
571 if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"SetupSourceDevice", &Context))
572 {
573 /*
574 * Get optional pointer 'SetupSourceDevice' key, its presence
575 * will dictate whether we also need 'SetupSourcePath'.
576 */
577 if (INF_GetData(&Context, NULL, &Value))
578 {
579 /* Free the old source root path string and create the new one */
580 RtlFreeUnicodeString(&pSetupData->SourceRootPath);
581 RtlCreateUnicodeString(&pSetupData->SourceRootPath, Value);
583
584 if (!SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"SetupSourcePath", &Context))
585 {
586 /* The 'SetupSourcePath' value is mandatory! */
588 }
589
590 /* Get pointer 'SetupSourcePath' key */
591 if (!INF_GetData(&Context, NULL, &Value))
592 {
593 /* The 'SetupSourcePath' value is mandatory! */
595 }
596
597 /* Free the old source path string and create the new one */
598 RtlFreeUnicodeString(&pSetupData->SourceRootDir);
599 RtlCreateUnicodeString(&pSetupData->SourceRootDir, Value);
601 }
602 }
603
604 /* Search for 'DefaultPath' in the 'SetupData' section */
605 pSetupData->InstallationDirectory[0] = 0;
606 if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData", L"DefaultPath", &Context))
607 {
608 /* Get pointer 'DefaultPath' key */
609 if (!INF_GetData(&Context, NULL, &Value))
611
612 RtlStringCchCopyW(pSetupData->InstallationDirectory,
613 ARRAYSIZE(pSetupData->InstallationDirectory),
614 Value);
615
617 }
618
619 return ERROR_SUCCESS;
620}
WCHAR FileNameBuffer[MAX_PATH]
Definition: framewnd.c:250
@ 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:41

Referenced by InitializeSetup().

◆ UpdateRegistry()

ERROR_NUMBER 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 1000 of file setuplib.c.

1008{
1009 ERROR_NUMBER ErrorNumber;
1011 INFCONTEXT InfContext;
1012 PCWSTR Action;
1013 PCWSTR File;
1014 PCWSTR Section;
1016 BOOLEAN ShouldRepairRegistry = FALSE;
1018
1019 if (RepairUpdateFlag)
1020 {
1021 DPRINT1("TODO: Updating / repairing the registry is not completely implemented yet!\n");
1022
1023 /* Verify the registry hives and check whether we need to update or repair any of them */
1024 Status = VerifyRegistryHives(&pSetupData->DestinationPath, &ShouldRepairRegistry);
1025 if (!NT_SUCCESS(Status))
1026 {
1027 DPRINT1("VerifyRegistryHives failed, Status 0x%08lx\n", Status);
1028 ShouldRepairRegistry = FALSE;
1029 }
1030 if (!ShouldRepairRegistry)
1031 DPRINT1("No need to repair the registry\n");
1032 }
1033
1034DoUpdate:
1035 ErrorNumber = ERROR_SUCCESS;
1036
1037 /* Update the registry */
1039
1040 /* Initialize the registry and setup the registry hives */
1041 Status = RegInitializeRegistry(&pSetupData->DestinationPath);
1042 if (!NT_SUCCESS(Status))
1043 {
1044 DPRINT1("RegInitializeRegistry() failed\n");
1045 /********** HACK!!!!!!!!!!! **********/
1047 {
1048 /* The hack was called, return its corresponding error */
1050 }
1051 else
1052 /*************************************/
1053 {
1054 /* Something else failed */
1055 return ERROR_CREATE_HIVE;
1056 }
1057 }
1058
1059 if (!RepairUpdateFlag || ShouldRepairRegistry)
1060 {
1061 /*
1062 * We fully setup the hives, in case we are doing a fresh installation
1063 * (RepairUpdateFlag == FALSE), or in case we are doing an update
1064 * (RepairUpdateFlag == TRUE) BUT we have some registry hives to
1065 * "repair" (aka. recreate: ShouldRepairRegistry == TRUE).
1066 */
1067
1068 Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Fresh", NULL, &InfContext); // Windows-compatible
1069 if (!Success)
1070 Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific
1071
1072 if (!Success)
1073 {
1074 DPRINT1("SpInfFindFirstLine() failed\n");
1075 ErrorNumber = ERROR_FIND_REGISTRY;
1076 goto Cleanup;
1077 }
1078 }
1079 else // if (RepairUpdateFlag && !ShouldRepairRegistry)
1080 {
1081 /*
1082 * In case we are doing an update (RepairUpdateFlag == TRUE) and
1083 * NO registry hives need a repair (ShouldRepairRegistry == FALSE),
1084 * we only update the hives.
1085 */
1086
1087 Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext);
1088 if (!Success)
1089 {
1090 /* Nothing to do for update! */
1091 DPRINT1("No update needed for the registry!\n");
1092 goto Cleanup;
1093 }
1094 }
1095
1096 do
1097 {
1098 INF_GetDataField(&InfContext, 0, &Action);
1099 INF_GetDataField(&InfContext, 1, &File);
1100 INF_GetDataField(&InfContext, 2, &Section);
1101
1102 DPRINT("Action: %S File: %S Section %S\n", Action, File, Section);
1103
1104 if (Action == NULL)
1105 {
1108 INF_FreeData(Section);
1109 break; // Hackfix
1110 }
1111
1112 if (!_wcsicmp(Action, L"AddReg"))
1113 Delete = FALSE;
1114 else if (!_wcsicmp(Action, L"DelReg"))
1115 Delete = TRUE;
1116 else
1117 {
1118 DPRINT1("Unrecognized registry INF action '%S'\n", Action);
1121 INF_FreeData(Section);
1122 continue;
1123 }
1124
1126
1128
1129 if (!ImportRegistryFile(pSetupData->SourcePath.Buffer,
1130 File, Section,
1131 pSetupData->LanguageId, Delete))
1132 {
1133 DPRINT1("Importing %S failed\n", File);
1135 INF_FreeData(Section);
1136 ErrorNumber = ERROR_IMPORT_HIVE;
1137 goto Cleanup;
1138 }
1139 } while (SpInfFindNextLine(&InfContext, &InfContext));
1140
1141 if (!RepairUpdateFlag || ShouldRepairRegistry)
1142 {
1143 /* See the explanation for this test above */
1144
1146 PCWSTR LanguageId; // LocaleID;
1147
1148 Entry = GetCurrentListEntry(pSetupData->DisplayList);
1149 ASSERT(Entry);
1150 pSetupData->DisplayType = ((PGENENTRY)GetListEntryData(Entry))->Id;
1151 ASSERT(pSetupData->DisplayType);
1152
1153 /* Update display registry settings */
1155 if (!ProcessDisplayRegistry(pSetupData->SetupInf, pSetupData->DisplayType))
1156 {
1157 ErrorNumber = ERROR_UPDATE_DISPLAY_SETTINGS;
1158 goto Cleanup;
1159 }
1160
1161 Entry = GetCurrentListEntry(pSetupData->LanguageList);
1162 ASSERT(Entry);
1163 LanguageId = ((PGENENTRY)GetListEntryData(Entry))->Id;
1164 ASSERT(LanguageId);
1165
1166 /* Set the locale */
1168 if (!ProcessLocaleRegistry(/*pSetupData->*/LanguageId))
1169 {
1170 ErrorNumber = ERROR_UPDATE_LOCALESETTINGS;
1171 goto Cleanup;
1172 }
1173
1174 /* Add the keyboard layouts for the given language (without user override) */
1177 {
1178 ErrorNumber = ERROR_ADDING_KBLAYOUTS;
1179 goto Cleanup;
1180 }
1181
1182 if (!IsUnattendedSetup)
1183 {
1184 Entry = GetCurrentListEntry(pSetupData->LayoutList);
1185 ASSERT(Entry);
1186 pSetupData->LayoutId = ((PGENENTRY)GetListEntryData(Entry))->Id;
1187 ASSERT(pSetupData->LayoutId);
1188
1189 /* Update keyboard layout settings with user-overridden values */
1190 // FIXME: Wouldn't it be better to do it all at once
1191 // with the AddKeyboardLayouts() step?
1193 if (!ProcessKeyboardLayoutRegistry(pSetupData->LayoutId, SelectedLanguageId))
1194 {
1195 ErrorNumber = ERROR_UPDATE_KBSETTINGS;
1196 goto Cleanup;
1197 }
1198 }
1199
1200 /* Set GeoID */
1202 {
1203 ErrorNumber = ERROR_UPDATE_GEOID;
1204 goto Cleanup;
1205 }
1206
1207 /* Add codepage information to registry */
1210 {
1211 ErrorNumber = ERROR_ADDING_CODEPAGE;
1212 goto Cleanup;
1213 }
1214
1215 /* Set the default pagefile entry */
1216 SetDefaultPagefile(DestinationDriveLetter);
1217
1218 /* Update the mounted devices list */
1219 // FIXME: This should technically be done by mountmgr (if AutoMount is enabled)!
1221 }
1222
1223#ifdef __REACTOS__
1224 if (SubstSettings)
1225 {
1226 /* HACK */
1227 DoRegistryFontFixup(SubstSettings, wcstoul(SelectedLanguageId, NULL, 16));
1228 }
1229#endif
1230
1231Cleanup:
1232 //
1233 // TODO: Unload all the registry stuff, perform cleanup,
1234 // and copy the created hive files into .sav files.
1235 //
1236 RegCleanupRegistry(&pSetupData->DestinationPath);
1237
1238 /*
1239 * Check whether we were in update/repair mode but we were actually
1240 * repairing the registry hives. If so, we have finished repairing them,
1241 * and we now reset the flag and run the proper registry update.
1242 * Otherwise we have finished the registry update!
1243 */
1244 if (RepairUpdateFlag && ShouldRepairRegistry)
1245 {
1246 ShouldRepairRegistry = FALSE;
1247 goto DoUpdate;
1248 }
1249
1250 return ErrorNumber;
1251}
unsigned char BOOLEAN
static BOOL ImportRegistryFile(HWND hWnd)
Definition: framewnd.c:464
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
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
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
pSpInfFindNextLine SpInfFindNextLine
Definition: infsupp.c:88
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:42
PGENERIC_LIST_ENTRY GetCurrentListEntry(IN PGENERIC_LIST List)
Definition: genlist.c:97
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
Definition: genlist.c:126
static const char const char const char PIMAGEHLP_STATUS_ROUTINE StatusRoutine
Definition: image.c:35
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
BOOLEAN SetMountedDeviceValues(IN PPARTLIST List)
Definition: partlist.c:3821
base of all file and directory entries
Definition: entries.h:83
Definition: genlist.h:11
BOOL DoRegistryFontFixup(PFONTSUBSTSETTINGS pSettings, LANGID LangID)
static BOOLEAN RepairUpdateFlag
Definition: usetup.c:68
PCWSTR SelectedLanguageId
Definition: usetup.c:64
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510

Referenced by RegistryPage().

Variable Documentation

◆ IsUnattendedSetup

BOOLEAN IsUnattendedSetup
extern

◆ ProcessHeap

HANDLE ProcessHeap
extern
  • Internal Headers *‍/

Definition at line 15 of file servman.c.