X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=ntoskrnl%2Fconfig%2Fcmsysini.c;h=45242d28388c8eda7a7e861c6a9483a58aead6eb;hp=dc03e96fdb8a50a7edc99c8a080939ea2f3c635f;hb=527f2f90577662e8eba1b1b62f958c39b3cd4358;hpb=122303c4ea9ff70a483355888e43b5976c79cb0e diff --git a/ntoskrnl/config/cmsysini.c b/ntoskrnl/config/cmsysini.c index dc03e96fdb8..45242d28388 100644 --- a/ntoskrnl/config/cmsysini.c +++ b/ntoskrnl/config/cmsysini.c @@ -36,6 +36,71 @@ extern BOOLEAN CmFirstTime; /* FUNCTIONS ******************************************************************/ +BOOLEAN +NTAPI +CmpLinkKeyToHive( + _In_z_ PWSTR LinkKeyName, + _In_z_ PWSTR TargetKeyName) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING LinkKeyName_U; + HANDLE TargetKeyHandle; + ULONG Disposition; + NTSTATUS Status; + PAGED_CODE(); + + /* Initialize the object attributes */ + RtlInitUnicodeString(&LinkKeyName_U, LinkKeyName); + InitializeObjectAttributes(&ObjectAttributes, + &LinkKeyName_U, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + /* Create the link key */ + Status = ZwCreateKey(&TargetKeyHandle, + KEY_CREATE_LINK, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, + &Disposition); + if (!NT_SUCCESS(Status)) + { + DPRINT1("CM: CmpLinkKeyToHive: couldn't create %S Status = 0x%lx\n", + LinkKeyName, Status); + return FALSE; + } + + /* Check if the new key was actually created */ + if (Disposition != REG_CREATED_NEW_KEY) + { + DPRINT1("CM: CmpLinkKeyToHive: %S already exists!\n", LinkKeyName); + ZwClose(TargetKeyHandle); + return FALSE; + } + + /* Set the target key name as link target */ + Status = ZwSetValueKey(TargetKeyHandle, + &CmSymbolicLinkValueName, + 0, + REG_LINK, + TargetKeyName, + wcslen(TargetKeyName) * sizeof(WCHAR)); + + /* Close the link key handle */ + ObCloseHandle(TargetKeyHandle, KernelMode); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("CM: CmpLinkKeyToHive: couldn't create symbolic link for %S\n", + TargetKeyName); + return FALSE; + } + + return TRUE; +} + VOID NTAPI CmpDeleteKeyObject(PVOID DeletedObject) @@ -164,7 +229,7 @@ CmpQueryKeyName(IN PVOID ObjectBody, ((Length < (*ReturnLength)) && (BytesToCopy < sizeof(WCHAR)))) { /* Free the buffer allocated by CmpConstructName */ - ExFreePool(KeyName); + ExFreePoolWithTag(KeyName, TAG_CM); /* Return buffer length failure without writing anything there because nothing fits */ return STATUS_INFO_LENGTH_MISMATCH; @@ -207,7 +272,7 @@ CmpQueryKeyName(IN PVOID ObjectBody, _SEH2_END; /* Free the buffer allocated by CmpConstructName */ - ExFreePool(KeyName); + ExFreePoolWithTag(KeyName, TAG_CM); /* Return status */ return Status; @@ -584,7 +649,7 @@ UseSet: LoaderExtension = LoaderBlock->Extension; if (LoaderExtension) { - ASSERTMSG("ReactOS doesn't support NTLDR Profiles yet!\n", FALSE); + DPRINT("ReactOS doesn't support NTLDR Profiles yet!\n"); } /* Create the current hardware profile key */ @@ -751,7 +816,6 @@ CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock) if (HiveBase) { /* Import it */ - ((PHBASE_BLOCK)HiveBase)->Length = LoaderBlock->RegistryLength; Status = CmpInitializeHive((PCMHIVE*)&SystemHive, HINIT_MEMORY, HIVE_NOLAZYFLUSH, @@ -1389,9 +1453,13 @@ CmpInitializeHiveList(IN USHORT Flag) /* Get rid of the SD */ ExFreePoolWithTag(SecurityDescriptor, TAG_CM); - /* FIXME: Link SECURITY to SAM */ + /* Link SECURITY to SAM */ + CmpLinkKeyToHive(L"\\Registry\\Machine\\Security\\SAM", + L"\\Registry\\Machine\\SAM\\SAM"); - /* FIXME: Link S-1-5-18 to .Default */ + /* Link S-1-5-18 to .Default */ + CmpLinkKeyToHive(L"\\Registry\\User\\S-1-5-18", + L"\\Registry\\User\\.Default"); } BOOLEAN @@ -1881,6 +1949,11 @@ CmpUnlockRegistry(VOID) CmpDoFlushAll(TRUE); CmpFlushOnLockRelease = FALSE; } + else + { + /* Lazy flush the registry */ + CmpLazyFlush(); + } /* Release the lock and leave the critical region */ ExReleaseResourceLite(&CmpRegistryLock);