/* 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)
((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;
_SEH2_END;
/* Free the buffer allocated by CmpConstructName */
- ExFreePool(KeyName);
+ ExFreePoolWithTag(KeyName, TAG_CM);
/* Return status */
return Status;
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 */
if (HiveBase)
{
/* Import it */
- ((PHBASE_BLOCK)HiveBase)->Length = LoaderBlock->RegistryLength;
Status = CmpInitializeHive((PCMHIVE*)&SystemHive,
HINIT_MEMORY,
HIVE_NOLAZYFLUSH,
/* 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
CmpDoFlushAll(TRUE);
CmpFlushOnLockRelease = FALSE;
}
+ else
+ {
+ /* Lazy flush the registry */
+ CmpLazyFlush();
+ }
/* Release the lock and leave the critical region */
ExReleaseResourceLite(&CmpRegistryLock);