Index: ntoskrnl/config/cmsysini.c =================================================================== --- ntoskrnl/config/cmsysini.c (Revision 58037) +++ ntoskrnl/config/cmsysini.c (Arbeitskopie) @@ -490,6 +490,10 @@ KeyName.MaximumLength = sizeof(UnicodeBuffer); KeyName.Buffer = UnicodeBuffer; Status = RtlAnsiStringToUnicodeString(&KeyName, &TempString, FALSE); + if (!NT_SUCCESS(Status)) + { + return Status; + } /* Set the value */ Status = NtSetValueKey(KeyHandle, @@ -714,6 +718,8 @@ INIT_FUNCTION CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { + static const WCHAR HivePath[] = L"\\SystemRoot\\System32\\Config\\SYSTEM"; + static const UNICODE_STRING HiveName = RTL_CONSTANT_STRING(L"SYSTEM"); PVOID HiveBase; ANSI_STRING LoadString; PVOID Buffer; @@ -722,7 +728,6 @@ BOOLEAN Allocate; UNICODE_STRING KeyName; PCMHIVE SystemHive = NULL; - UNICODE_STRING HiveName = RTL_CONSTANT_STRING(L"SYSTEM"); PSECURITY_DESCRIPTOR SecurityDescriptor; PAGED_CODE(); @@ -742,7 +747,12 @@ RtlInitEmptyUnicodeString(&CmpLoadOptions, Buffer, (USHORT)Length); /* Add the load options and null-terminate */ - RtlAnsiStringToUnicodeString(&CmpLoadOptions, &LoadString, FALSE); + Status = RtlAnsiStringToUnicodeString(&CmpLoadOptions, &LoadString, FALSE); + if (!NT_SUCCESS(Status)) + { + return FALSE; + } + CmpLoadOptions.Buffer[LoadString.Length] = UNICODE_NULL; CmpLoadOptions.Length += sizeof(WCHAR); @@ -752,51 +762,41 @@ { /* Import it */ ((PHBASE_BLOCK)HiveBase)->Length = LoaderBlock->RegistryLength; - Status = CmpInitializeHive((PCMHIVE*)&SystemHive, - HINIT_MEMORY, - HIVE_NOLAZYFLUSH, - HFILE_TYPE_LOG, - HiveBase, - NULL, - NULL, - NULL, - &HiveName, - 2); - if (!NT_SUCCESS(Status)) return FALSE; - /* Set the hive filename */ - RtlCreateUnicodeString(&SystemHive->FileFullPath, - L"\\SystemRoot\\System32\\Config\\SYSTEM"); - - /* We imported, no need to create a new hive */ + /* We import, no need to create a new hive */ Allocate = FALSE; - - /* Manually set the hive as volatile, if in Live CD mode */ - if (CmpShareSystemHives) SystemHive->Hive.HiveFlags = HIVE_VOLATILE; } else { - /* Create it */ - Status = CmpInitializeHive(&SystemHive, - HINIT_CREATE, - HIVE_NOLAZYFLUSH, - HFILE_TYPE_LOG, - NULL, - NULL, - NULL, - NULL, - &HiveName, - 0); - if (!NT_SUCCESS(Status)) return FALSE; - - /* Set the hive filename */ - RtlCreateUnicodeString(&SystemHive->FileFullPath, - L"\\SystemRoot\\System32\\Config\\SYSTEM"); - /* Tell CmpLinkHiveToMaster to allocate a hive */ Allocate = TRUE; } + Status = CmpInitializeHive(&SystemHive, + HiveBase ? HINIT_MEMORY : HINIT_CREATE, + HIVE_NOLAZYFLUSH, + HFILE_TYPE_LOG, + HiveBase, + NULL, + NULL, + NULL, + &HiveName, + HiveBase ? 2 : 0); + if (!NT_SUCCESS(Status)) return FALSE; + + /* Set the hive filename */ + Status = RtlCreateUnicodeString(&SystemHive->FileFullPath, HivePath); + if (!NT_SUCCESS(Status)) + { + return FALSE; + } + + /* Manually set the hive as volatile, if in Live CD mode */ + if (HiveBase && CmpShareSystemHives) + { + SystemHive->Hive.HiveFlags = HIVE_VOLATILE; + } + /* Save the boot type */ CmpBootType = SystemHive->Hive.BaseBlock->BootType; @@ -1093,6 +1093,7 @@ return STATUS_SUCCESS; } +_Function_class_(KSTART_ROUTINE) VOID NTAPI CmpLoadHiveThread(IN PVOID StartContext) @@ -1742,11 +1743,21 @@ /* Get the entry */ DriverEntry = CONTAINING_RECORD(NextEntry, BOOT_DRIVER_LIST_ENTRY, Link); - /* Allocate the path for the caller and duplicate the registry path */ + /* Allocate the path for the caller */ ServicePath[i] = ExAllocatePool(NonPagedPool, sizeof(UNICODE_STRING)); - RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, - &DriverEntry->RegistryPath, - ServicePath[i]); + if (!ServicePath[i]) + { + KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0); + } + + /* Duplicate the registry path */ + Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE, + &DriverEntry->RegistryPath, + ServicePath[i]); + if (!NT_SUCCESS(Status)) + { + KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0); + } } /* Terminate the list */