39 pSetupData->SourcePath.Buffer,
L"unattend.inf");
41 DPRINT(
"UnattendInf path: '%S'\n", UnattendInfPath);
45 DPRINT(
"Does not exist: %S\n", UnattendInfPath);
53 pSetupData->LanguageId,
57 DPRINT(
"SpInfOpenInfFile() failed\n");
64 DPRINT(
"SpInfFindFirstLine() failed for section 'Unattend'\n");
71 DPRINT(
"INF_GetData() failed for key 'Signature'\n");
78 DPRINT(
"Signature not $ReactOS$\n");
88 DPRINT(
"Can't find key 'UnattendSetupEnabled'\n");
94 DPRINT(
"Can't read key 'UnattendSetupEnabled'\n");
100 DPRINT(
"Unattend setup is disabled by 'UnattendSetupEnabled' key!\n");
110 DPRINT(
"SpInfFindFirstLine() failed for key 'DestinationDiskNumber'\n");
116 DPRINT(
"SpInfGetIntField() failed for key 'DestinationDiskNumber'\n");
120 pSetupData->DestinationDiskNumber = (
LONG)IntValue;
125 DPRINT(
"SpInfFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
131 DPRINT(
"SpInfGetIntField() failed for key 'DestinationPartitionNumber'\n");
135 pSetupData->DestinationPartitionNumber = (
LONG)IntValue;
143 DPRINT(
"INF_GetData() failed for key 'InstallationDirectory'\n");
148 ARRAYSIZE(pSetupData->InstallationDirectory),
155 DPRINT(
"Running unattended setup\n");
158 pSetupData->MBRInstallType = -1;
163 pSetupData->MBRInstallType = IntValue;
168 pSetupData->FormatPartition = 0;
173 pSetupData->FormatPartition = IntValue;
177 pSetupData->AutoPartition = 0;
182 pSetupData->AutoPartition = IntValue;
200 pSetupData->FsType = 0;
205 pSetupData->FsType = IntValue;
225 CHAR CrLf[] = {
'\r',
'\n'};
258 IniAddKey(IniSection,
L"UnattendedInstall", PathBuffer);
263 L"\"%s\"",
L"winnt");
264 IniAddKey(IniSection,
L"ProductType", PathBuffer);
267 L"\"%s\\\"", pSetupData->SourceRootPath.Buffer);
268 IniAddKey(IniSection,
L"SourcePath", PathBuffer);
277 pSetupData->SourcePath.Buffer,
L"unattend.inf");
280 DPRINT(
"Does not exist: %S\n", UnattendInfPath);
287 DPRINT1(
"Cannot load %S as an INI file!\n", UnattendInfPath);
295 pSetupData->DestinationPath.Buffer,
L"System32\\$winnt$.inf");
302 pSetupData->DestinationPath.Buffer,
L"System32\\$winnt$.inf");
308 pSetupData->SourcePath.Buffer,
L"unattend.inf");
311 DPRINT(
"Does not exist: %S\n", UnattendInfPath);
329 DPRINT1(
"Cannot load %S as an INI file!\n", PathBuffer);
341 DPRINT(
"NtQueryInformationFile() failed (Status %lx)\n",
Status);
354 DPRINT1(
"Cannot load %S !\n", UnattendInfPath);
412 RtlInitEmptyUnicodeString(InstallSourcePath,
460 DPRINT1(
"NtOpenSymbolicLinkObject(%wZ) failed with Status 0x%08lx\n",
465 RtlInitEmptyUnicodeString(&SystemRootPath,
467 sizeof(SystemRootBuffer));
483 InstallSourcePath = &SystemRootPath;
521 pSetupData->SourcePath.Buffer,
L"txtsetup.sif");
525 pSetupData->SetupInf =
529 pSetupData->LanguageId,
556 pSetupData->RequiredPartitionDiskSpace = ~0;
562 pSetupData->RequiredPartitionDiskSpace = (
ULONG)IntValue;
605 pSetupData->InstallationDirectory[0] = 0;
613 ARRAYSIZE(pSetupData->InstallationDirectory),
654 DPRINT1(
"We are using a different system partition!!\n");
668 OldActivePart =
NULL;
725 ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
730 L"\\Device\\Harddisk%lu\\Partition%lu\\",
732 PartEntry->PartitionNumber);
736 DPRINT1(
"RtlStringCchPrintfW() failed with status 0x%08lx\n",
Status);
744 DPRINT1(
"RtlCreateUnicodeString() failed with status 0x%08lx\n",
Status);
748 DPRINT(
"DestinationRootPath: %wZ\n", &pSetupData->DestinationRootPath);
751 if (!InstallationDir)
752 InstallationDir = pSetupData->InstallationDirectory;
764 L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
766 PartEntry->OnDiskPartitionNumber);
769 L"multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)\\",
773 PartEntry->OnDiskPartitionNumber);
775 DPRINT1(
"Fixed disk found by BIOS, using MULTI ARC path '%S'\n", PathBuffer);
780 L"scsi(%u)disk(%u)rdisk(%u)partition(%lu)\\",
784 PartEntry->OnDiskPartitionNumber);
785 DPRINT1(
"Fixed disk not found by BIOS, using SCSI ARC path '%S'\n", PathBuffer);
792 L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
794 DPRINT1(
"Removable disk, using MULTI ARC path '%S'\n", PathBuffer);
797 L"signature(%08x)disk(%u)rdisk(%u)partition(%lu)\\",
801 PartEntry->OnDiskPartitionNumber);
802 DPRINT1(
"Removable disk, using SIGNATURE ARC path '%S'\n", PathBuffer);
808 DPRINT1(
"RtlStringCchPrintfW() failed with status 0x%08lx\n",
Status);
817 DPRINT1(
"ConcatPaths() failed with status 0x%08lx\n",
Status);
826 DPRINT1(
"RtlCreateUnicodeString() failed with status 0x%08lx\n",
Status);
835 pSetupData->DestinationRootPath.Buffer, InstallationDir);
839 DPRINT1(
"CombinePaths() failed with status 0x%08lx\n",
Status);
849 DPRINT1(
"RtlCreateUnicodeString() failed with status 0x%08lx\n",
Status);
861 DPRINT1(
"RtlCreateUnicodeString() failed with status 0x%08lx\n",
Status);
883 pSetupData->ErrorRoutine =
NULL;
915 &pSetupData->SourceRootPath,
916 &pSetupData->SourceRootDir);
919 DPRINT1(
"GetSourcePaths() failed (Status 0x%08lx)\n",
Status);
928 DPRINT1(
"SourcePath (1): '%wZ'\n", &pSetupData->SourcePath);
929 DPRINT1(
"SourceRootPath (1): '%wZ'\n", &pSetupData->SourceRootPath);
930 DPRINT1(
"SourceRootDir (1): '%wZ'\n", &pSetupData->SourceRootDir);
936 DPRINT1(
"LoadSetupInf() failed (Error 0x%lx)\n",
Error);
939 DPRINT1(
"SourcePath (2): '%wZ'\n", &pSetupData->SourcePath);
940 DPRINT1(
"SourceRootPath (2): '%wZ'\n", &pSetupData->SourceRootPath);
941 DPRINT1(
"SourceRootDir (2): '%wZ'\n", &pSetupData->SourceRootDir);
954 if (pSetupData->ComputerList !=
NULL)
957 pSetupData->ComputerList =
NULL;
961 if (pSetupData->DisplayList !=
NULL)
964 pSetupData->DisplayList =
NULL;
968 if (pSetupData->KeyboardList !=
NULL)
971 pSetupData->KeyboardList =
NULL;
975 if (pSetupData->LayoutList !=
NULL)
978 pSetupData->LayoutList =
NULL;
982 if (pSetupData->LanguageList !=
NULL)
985 pSetupData->LanguageList =
NULL;
1004 IN WCHAR DestinationDriveLetter,
1021 DPRINT1(
"TODO: Updating / repairing the registry is not completely implemented yet!\n");
1027 DPRINT1(
"VerifyRegistryHives failed, Status 0x%08lx\n",
Status);
1028 ShouldRepairRegistry =
FALSE;
1030 if (!ShouldRepairRegistry)
1031 DPRINT1(
"No need to repair the registry\n");
1044 DPRINT1(
"RegInitializeRegistry() failed\n");
1074 DPRINT1(
"SpInfFindFirstLine() failed\n");
1091 DPRINT1(
"No update needed for the registry!\n");
1131 pSetupData->LanguageId,
Delete))
1151 ASSERT(pSetupData->DisplayType);
1187 ASSERT(pSetupData->LayoutId);
1246 ShouldRepairRegistry =
FALSE;
#define OBJ_NAME_PATH_SEPARATOR
#define FILE_NON_DIRECTORY_FILE
static BOOL ImportRegistryFile(HWND hWnd)
WCHAR FileNameBuffer[MAX_PATH]
BOOL Delete(LPCTSTR ServiceName)
VOID RegCleanupRegistry(IN PUNICODE_STRING NtSystemRoot)
NTSTATUS RegInitializeRegistry(IN PUNICODE_STRING NtSystemRoot)
NTSTATUS VerifyRegistryHives(IN PUNICODE_STRING NtSystemRoot, OUT PBOOLEAN ShouldRepairRegistry)
BOOLEAN SetDefaultPagefile(_In_ WCHAR Drive)
BOOLEAN ProcessKeyboardLayoutRegistry(_In_ PCWSTR pszLayoutId, _In_ PCWSTR LanguageId)
BOOLEAN ProcessDisplayRegistry(_In_ HINF InfFile, _In_ PCWSTR DisplayType)
BOOLEAN SetGeoID(_In_ GEOID GeoId)
BOOLEAN ProcessLocaleRegistry(_In_ PCWSTR LanguageId)
struct _GENENTRY * PGENENTRY
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
#define INVALID_HANDLE_VALUE
static const WCHAR Cleanup[]
UNICODE_STRING * PUNICODE_STRING
struct _UNICODE_STRING UNICODE_STRING
enum _ERROR_NUMBER ERROR_NUMBER
@ ERROR_SIGNATURE_TXTSETUPSIF
@ ERROR_CORRUPT_TXTSETUPSIF
@ ERROR_UPDATE_LOCALESETTINGS
@ ERROR_INITIALIZE_REGISTRY
@ ERROR_UPDATE_DISPLAY_SETTINGS
@ ERROR_UPDATE_KBSETTINGS
struct _FileName FileName
NTSTATUS CombinePaths(OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
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.
NTSTATUS ConcatPaths(IN OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress)
#define DoesFileExist(RootDirectory, FileName)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
#define FILE_SYNCHRONOUS_IO_NONALERT
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
pSpInfFindNextLine SpInfFindNextLine
pSpInfGetIntField SpInfGetIntField
pSpInfFindFirstLine SpInfFindFirstLine
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
pSpInfOpenInfFile SpInfOpenInfFile
pSpInfCloseInfFile SpInfCloseInfFile
VOID IniCacheDestroy(_In_ PINICACHE Cache)
NTSTATUS IniCacheLoad(PINICACHE *Cache, PWCHAR FileName, BOOLEAN String)
PINI_SECTION IniAddSection(_In_ PINICACHE Cache, _In_ PCWSTR Name)
NTSTATUS IniCacheSave(PINICACHE Cache, PWCHAR FileName)
PINICACHE IniCacheCreate(VOID)
PINI_KEYWORD IniAddKey(_In_ PINI_SECTION Section, _In_ PCWSTR Name, _In_ PCWSTR Data)
GEOID MUIGetGeoID(IN PCWSTR LanguageId)
BOOLEAN AddCodePage(IN PCWSTR LanguageId)
BOOLEAN AddKeyboardLayouts(IN PCWSTR LanguageId)
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
BOOLEAN INF_GetData(IN PINFCONTEXT Context, OUT PCWSTR *Key, OUT PCWSTR *Data)
VOID DestroyGenericList(IN OUT PGENERIC_LIST List, IN BOOLEAN FreeData)
PGENERIC_LIST_ENTRY GetCurrentListEntry(IN PGENERIC_LIST List)
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
static const char const char const char PIMAGEHLP_STATUS_ROUTINE StatusRoutine
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define InitializeObjectAttributes(p, n, a, r, s)
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)
#define SYMBOLIC_LINK_QUERY
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()
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
#define STATUS_NOT_IMPLEMENTED
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
NTSTATUS NTAPI NtQuerySymbolicLinkObject(IN HANDLE LinkHandle, OUT PUNICODE_STRING LinkTarget, OUT PULONG ResultLength OPTIONAL)
NTSTATUS NTAPI NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
#define FileStandardInformation
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
@ FSVOLNOTIFY_PARTITIONERROR
FSVOL_OP(CALLBACK * PFSVOL_CALLBACK)(_In_opt_ PVOID Context, _In_ FSVOLNOTIFY FormatStatus, _In_ ULONG_PTR Param1, _In_ ULONG_PTR Param2)
BOOLEAN SetMountedDeviceValues(IN PPARTLIST List)
BOOLEAN CreatePartition(_In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
BOOLEAN SetActivePartition(IN PPARTLIST List, IN PPARTENTRY PartEntry, IN PPARTENTRY OldActivePart OPTIONAL)
PPARTENTRY FindSupportedSystemPartition(IN PPARTLIST List, IN BOOLEAN ForceSelect, IN PDISKENTRY AlternativeDisk OPTIONAL, IN PPARTENTRY AlternativePart OPTIONAL)
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.
ERROR_NUMBER LoadSetupInf(IN OUT PUSETUP_DATA pSetupData)
VOID FinishSetup(IN OUT PUSETUP_DATA pSetupData)
VOID CheckUnattendedSetup(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)
NTSTATUS GetSourcePaths(OUT PUNICODE_STRING SourcePath, OUT PUNICODE_STRING SourceRootPath, OUT PUNICODE_STRING SourceRootDir)
VOID InstallSetupInfFile(IN OUT PUSETUP_DATA pSetupData)
NTSTATUS InitDestinationPaths(IN OUT PUSETUP_DATA pSetupData, IN PCWSTR InstallationDir, IN PPARTENTRY PartEntry)
ERROR_NUMBER InitializeSetup(IN OUT PUSETUP_DATA pSetupData, IN ULONG InitPhase)
#define ERROR_SYSTEM_PARTITION_NOT_FOUND
VOID(__cdecl * PREGISTRY_STATUS_ROUTINE)(IN REGISTRY_STATUS,...)
BOOLEAN IsUnattendedSetup
PULONG MinorVersion OPTIONAL
base of all file and directory entries
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
struct _DISKENTRY * DiskEntry
PPARTENTRY SystemPartition
BOOL DoRegistryFontFixup(PFONTSUBSTSETTINGS pSettings, LANGID LangID)
#define RTL_CONSTANT_STRING(s)
#define RtlZeroMemory(Destination, Length)
static FSVOL_OP CALLBACK FsVolCallback(_In_opt_ PVOID Context, _In_ FSVOLNOTIFY FormatStatus, _In_ ULONG_PTR Param1, _In_ ULONG_PTR Param2)
static PPARTLIST PartitionList
static PPARTENTRY InstallPartition
static PPARTENTRY SystemPartition
static BOOLEAN RepairUpdateFlag
PCWSTR SelectedLanguageId
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
_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