From: Eric Kohl Date: Thu, 14 May 2015 21:08:42 +0000 (+0000) Subject: [NTOSKRNL] X-Git-Tag: backups/colins-printing-for-freedom@73041~24^3~208 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=b4e859a2323a66a659031bce7a0c37b741241616 [NTOSKRNL] Create the "Hardware Profiles\0000" key as part of the registry setup. This must be done at this point because the "Hardware Profiles\Current" link will only be created, if the "Hardware Profiles\0000" key exists. svn path=/trunk/; revision=67725 --- diff --git a/reactos/ntoskrnl/config/cmsysini.c b/reactos/ntoskrnl/config/cmsysini.c index 80d098e58fe..006e4effc78 100644 --- a/reactos/ntoskrnl/config/cmsysini.c +++ b/reactos/ntoskrnl/config/cmsysini.c @@ -446,6 +446,78 @@ Quickie: return (ExpInTextModeSetup ? STATUS_SUCCESS : Status); } +static +NTSTATUS +INIT_FUNCTION +CmpCreateHardwareProfile(HANDLE ControlSetHandle) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING KeyName; + HANDLE ProfilesHandle = NULL; + HANDLE ProfileHandle = NULL; + ULONG Disposition; + NTSTATUS Status; + + DPRINT("CmpCreateHardwareProfile()\n"); + + /* Create the Hardware Profiles key */ + RtlInitUnicodeString(&KeyName, L"Hardware Profiles"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + ControlSetHandle, + NULL); + Status = NtCreateKey(&ProfilesHandle, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + 0, + &Disposition); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Creating the Hardware Profile key failed\n"); + goto done; + } + + /* Sanity check */ + ASSERT(Disposition == REG_CREATED_NEW_KEY); + + /* Create the 0000 key */ + RtlInitUnicodeString(&KeyName, L"0000"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + ProfilesHandle, + NULL); + Status = NtCreateKey(&ProfileHandle, + KEY_ALL_ACCESS, + &ObjectAttributes, + 0, + NULL, + 0, + &Disposition); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Creating the Hardware Profile\\0000 key failed\n"); + goto done; + } + + /* Sanity check */ + ASSERT(Disposition == REG_CREATED_NEW_KEY); + +done: + if (ProfilesHandle) + NtClose(ProfilesHandle); + + if (ProfileHandle) + NtClose(ProfileHandle); + + DPRINT1("CmpCreateHardwareProfile() done\n"); + + return Status; +} + NTSTATUS NTAPI INIT_FUNCTION @@ -498,6 +570,11 @@ CmpCreateControlSet(IN PLOADER_PARAMETER_BLOCK LoaderBlock) &Disposition); if (!NT_SUCCESS(Status)) return Status; + /* Create the Hardware Profile keys */ + Status = CmpCreateHardwareProfile(KeyHandle); + if (!NT_SUCCESS(Status)) + return Status; + /* Don't need the handle */ ZwClose(KeyHandle); @@ -583,23 +660,31 @@ UseSet: goto Cleanup; } - /* Now get the current config */ - RtlInitUnicodeString(&KeyName, L"CurrentConfig"); - Status = NtQueryValueKey(ConfigHandle, - &KeyName, - KeyValueFullInformation, - ValueInfoBuffer, - sizeof(ValueInfoBuffer), - &ResultLength); + /* ReactOS Hack: Hard-code current to 001 for SetupLdr */ + if (!LoaderBlock->RegistryBase) + { + HwProfile = 0; + } + else + { + /* Now get the current config */ + RtlInitUnicodeString(&KeyName, L"CurrentConfig"); + Status = NtQueryValueKey(ConfigHandle, + &KeyName, + KeyValueFullInformation, + ValueInfoBuffer, + sizeof(ValueInfoBuffer), + &ResultLength); - /* Set pointer to buffer */ - ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer; + /* Set pointer to buffer */ + ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer; - /* Check if we failed or got a non DWORD-value */ - if (!(NT_SUCCESS(Status)) || (ValueInfo->Type != REG_DWORD)) goto Cleanup; + /* Check if we failed or got a non DWORD-value */ + if (!(NT_SUCCESS(Status)) || (ValueInfo->Type != REG_DWORD)) goto Cleanup; - /* Get the hadware profile */ - HwProfile = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset); + /* Get the hadware profile */ + HwProfile = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset); + } /* Open the hardware profile key */ RtlInitUnicodeString(&KeyName, @@ -705,6 +790,8 @@ Cleanup: if (ProfileHandle) NtClose(ProfileHandle); if (ParentHandle) NtClose(ParentHandle); + DPRINT1("CmpCreateControlSet() done\n"); + /* Return success */ return STATUS_SUCCESS; }