56 PVOID HiveDataPhysical;
57 PVOID HiveDataVirtual;
71 WARN(
"Error while opening '%s', Status: %u\n", FullHiveName,
Status);
80 WARN(
"Hive file has 0 size!\n");
85 HiveFileSize =
FileInfo.EndingAddress.LowPart;
89 MM_SIZE_TO_PAGES(HiveFileSize + MM_PAGE_SIZE - 1) << MM_PAGE_SHIFT,
92 if (HiveDataPhysical ==
NULL)
94 WARN(
"Could not alloc memory for hive!\n");
101 HiveDataVirtual =
PaToVa(HiveDataPhysical);
104 LoaderBlock->RegistryLength = HiveFileSize;
105 LoaderBlock->RegistryBase = HiveDataVirtual;
111 WARN(
"Error while reading '%s', Status: %u\n", FullHiveName,
Status);
140 HiveName =
"SETUPREG.HIV";
149 TRACE(
"WinLdrInitSystemHive: loading hive %s%s\n",
SearchPath, HiveName);
157 goto LoadAlternateHive;
194 HiveName =
"SYSTEM.ALT";
214 WARN(
"SYSTEM hive does not exist or is corrupt and SYSTEM.ALT has been loaded!\n");
215 ChunkBase =
VaToPa(LoaderBlock->RegistryBase);
224 UiMessageBox(
"Initializing CurrentControlSet link failed!");
257 UiMessageBox(
"Getting NLS names from registry failed!");
261 TRACE(
"NLS data: '%wZ' '%wZ' '%wZ' '%wZ'\n",
262 &AnsiFileName, &OemFileName, &LangFileName, &OemHalFileName);
273 TRACE(
"NLS data loading %s\n",
Success ?
"successful" :
"failed");
293 WCHAR szIdBuffer[80];
319 AnsiFileName->Length = 0;
343 OemFileName->Length = 0;
359 RtlInitEmptyUnicodeString(OemHalFileName,
NULL, 0);
392 LangFileName->Length = 0;
416 ULONG AnsiFileId = -1, OemFileId = -1, LangFileId = -1;
417 ULONG AnsiFileSize, OemFileSize, LangFileSize;
420 PVOID NlsDataBase, NlsVirtual;
426 AnsiEqualsOem =
TRUE;
430 DirectoryPath, AnsiFileName);
441 AnsiFileSize =
FileInfo.EndingAddress.LowPart;
442 TRACE(
"AnsiFileSize: %d\n", AnsiFileSize);
452 DirectoryPath, OemFileName);
463 OemFileSize =
FileInfo.EndingAddress.LowPart;
465 TRACE(
"OemFileSize: %d\n", OemFileSize);
469 DirectoryPath, LangFileName);
480 LangFileSize =
FileInfo.EndingAddress.LowPart;
481 TRACE(
"LangFileSize: %d\n", LangFileSize);
489 TotalSize = MM_SIZE_TO_PAGES(AnsiFileSize) +
490 MM_SIZE_TO_PAGES(OemFileSize) +
491 MM_SIZE_TO_PAGES(LangFileSize);
497 if (NlsDataBase ==
NULL)
500 NlsVirtual =
PaToVa(NlsDataBase);
501 LoaderBlock->NlsData->AnsiCodePageData = NlsVirtual;
503 LoaderBlock->NlsData->OemCodePageData =
505 (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT));
507 LoaderBlock->NlsData->UnicodeCodePageData =
509 (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT) +
510 (MM_SIZE_TO_PAGES(OemFileSize) << MM_PAGE_SHIFT));
514 LoaderBlock->NlsData->OemCodePageData = LoaderBlock->NlsData->AnsiCodePageData;
518 DirectoryPath, AnsiFileName);
521 VaToPa(LoaderBlock->NlsData->AnsiCodePageData),
533 DirectoryPath, OemFileName);
536 VaToPa(LoaderBlock->NlsData->OemCodePageData),
547 DirectoryPath, LangFileName);
550 VaToPa(LoaderBlock->NlsData->UnicodeCodePageData),
561 LoaderBlock->OemFontFile =
VaToPa(LoaderBlock->NlsData->UnicodeCodePageData);
564 LoaderBlock->NlsData =
PaToVa(LoaderBlock->NlsData);
567 if (LangFileId != -1)
571 if (AnsiFileId != -1)
666 AlreadyInserted = CmpIsDriverInList(DriverListHead,
686 RtlInitEmptyUnicodeString(&DriverNode->
Name,
698 if (ImagePath && *ImagePath)
702 RtlInitEmptyUnicodeString(&
FilePath,
715 RtlInitEmptyUnicodeString(&
FilePath,
731 L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\");
733 RtlInitEmptyUnicodeString(&RegistryString,
736 if (!RegistryString.
Buffer)
746 if (GroupName && *GroupName)
760 RtlInitEmptyUnicodeString(&GroupString,
NULL, 0);
807 DriverNode->
Group = GroupString;
815 if (!AlreadyInserted)
828 if (RegistryString.
Buffer)
835 if (!AlreadyInserted)
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE ACPI_ADR_SPACE_HANDLER ACPI_ADR_SPACE_SETUP Setup
#define DBG_DEFAULT_CHANNEL(ch)
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
ARC_STATUS ArcClose(_In_ ULONG FileId)
PCWSTR FsGetServiceName(ULONG FileId)
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
VOID UiMessageBox(_In_ PCSTR Format,...)
BOOLEAN RegInitCurrentControlSet(_In_ BOOLEAN LastKnownGood)
BOOLEAN RegImportBinaryHive(_In_ PVOID ChunkBase, _In_ ULONG ChunkSize, _In_ PCSTR SearchPath, _In_ BOOLEAN LoadAlternate)
Imports the SYSTEM binary hive from the registry base chunk that's been provided by the loader block.
HKEY CurrentControlSetKey
#define HKEY_TO_HCI(hKey)
#define RegCloseKey(hKey)
PVOID NTAPI CmpAllocate(_In_ SIZE_T Size, _In_ BOOLEAN Paged, _In_ ULONG Tag)
VOID NTAPI CmpFree(_In_ PVOID Ptr, _In_ ULONG Quota)
BOOLEAN NTAPI CmpFindDrivers(_In_ PHHIVE Hive, _In_ HCELL_INDEX ControlSet, _In_ SERVICE_LOAD_TYPE LoadType, _In_opt_ PCWSTR BootFileSystem, _Inout_ PLIST_ENTRY DriverListHead)
Enumerates all drivers within the given control set and load type, present in the "Services" sub-key,...
BOOLEAN NTAPI CmpResolveDriverDependencies(_Inout_ PLIST_ENTRY DriverListHead)
Removes potential circular dependencies (cycles) and sorts the driver list.
BOOLEAN NTAPI CmpSortDriverList(_In_ PHHIVE Hive, _In_ HCELL_INDEX ControlSet, _Inout_ PLIST_ENTRY DriverListHead)
Sorts the driver list, according to the drivers' group load ordering.
VOID NTAPI CmpFreeDriverList(_In_ PHHIVE Hive, _Inout_ PLIST_ENTRY DriverListHead)
Empties the driver list and frees all allocated driver nodes in it.
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
FORCEINLINE PVOID VaToPa(PVOID Va)
FORCEINLINE PVOID PaToVa(PVOID Pa)
#define NT_SUCCESS(StatCode)
static const WCHAR SystemRoot[]
DRIVER_INITIALIZE DriverEntry
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
#define HBOOT_BOOT_RECOVERED_BY_ALTERNATE_HIVE
struct _HBASE_BLOCK * PHBASE_BLOCK
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
BOOT_DRIVER_LIST_ENTRY ListEntry
LOADER_PARAMETER_BLOCK LoaderBlock
#define RtlZeroMemory(Destination, Length)
#define DECLARE_UNICODE_STRING_SIZE(_var, _size)
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
VOID NtLdrOutputLoadMsg(_In_ PCSTR FileName, _In_opt_ PCSTR Description)
PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
static BOOLEAN WinLdrLoadSystemHive(_Inout_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ PCSTR DirectoryPath, _In_ PCSTR HiveName, _Out_ PBAD_HIVE_REASON Reason)
BOOLEAN WinLdrLoadNLSData(_Inout_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ PCSTR DirectoryPath, _In_ PCUNICODE_STRING AnsiFileName, _In_ PCUNICODE_STRING OemFileName, _In_ PCUNICODE_STRING LangFileName, _In_ PCUNICODE_STRING OemHalFileName)
BOOLEAN WinLdrAddDriverToList(_Inout_ PLIST_ENTRY DriverListHead, _In_ BOOLEAN InsertAtHead, _In_ PCWSTR DriverName, _In_opt_ PCWSTR ImagePath, _In_opt_ PCWSTR GroupName, _In_ ULONG ErrorControl, _In_ ULONG Tag)
Inserts the specified driver entry into the driver list, or updates an existing entry with new ImageP...
BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot, IN BOOLEAN Setup)
enum _BAD_HIVE_REASON BAD_HIVE_REASON
enum _BAD_HIVE_REASON * PBAD_HIVE_REASON
static BOOLEAN WinLdrGetNLSNames(_In_ HKEY ControlSet, _Inout_ PUNICODE_STRING AnsiFileName, _Inout_ PUNICODE_STRING OemFileName, _Inout_ PUNICODE_STRING LangFileName, _Inout_ PUNICODE_STRING OemHalFileName)
static BOOLEAN WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead)
BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot)