Author: tkreuzer
Date: Sat Jan 11 23:13:48 2014
New Revision: 61591
URL:
http://svn.reactos.org/svn/reactos?rev=61591&view=rev
Log:
[NTOSKRNL]
Implement CmpLinkKeyToHive and create missing HKLM\Security\SAM -> HKLM\SAM\SAM and
HKU\S-1-5-18 -> HKU\.Default links.
Modified:
trunk/reactos/ntoskrnl/config/cmsysini.c
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] Sat Jan 11 23:13:48 2014
@@ -35,6 +35,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
@@ -1389,9 +1454,13 @@
/* Get rid of the SD */
ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
- /* FIXME: Link SECURITY to SAM */
-
- /* FIXME: Link S-1-5-18 to .Default */
+ /* Link SECURITY to SAM */
+ CmpLinkKeyToHive(L"\\Registry\\Machine\\Security\\SAM",
+ L"\\Registry\\Machine\\SAM\\SAM");
+
+ /* Link S-1-5-18 to .Default */
+ CmpLinkKeyToHive(L"\\Registry\\User\\S-1-5-18",
+ L"\\Registry\\User\\.Default");
}
BOOLEAN