[NTOS:CM]
[reactos.git] / reactos / ntoskrnl / config / cmsysini.c
index cec7e9a..f41d27b 100644 (file)
@@ -129,7 +129,7 @@ CmpDeleteKeyObject(PVOID DeletedObject)
     CmpLockRegistry();
 
     /* Make sure this is a valid key body */
-    if (KeyBody->Type == '20yk')
+    if (KeyBody->Type == CM_KEY_BODY_TYPE)
     {
         /* Get the KCB */
         Kcb = KeyBody->KeyControlBlock;
@@ -166,7 +166,7 @@ CmpCloseKeyObject(IN PEPROCESS Process OPTIONAL,
     if (SystemHandleCount > 1) return;
 
     /* Make sure we're a valid key body */
-    if (KeyBody->Type == '20yk')
+    if (KeyBody->Type == CM_KEY_BODY_TYPE)
     {
         /* Don't do anything if we don't have a notify block */
         if (!KeyBody->NotifyBlock) return;
@@ -358,7 +358,7 @@ CmpInitHiveFromFile(IN PCUNICODE_STRING HiveName,
                                LogHandle,
                                NULL,
                                HiveName,
-                               0);
+                               CheckFlags);
     if (!NT_SUCCESS(Status))
     {
         /* Fail */
@@ -370,7 +370,7 @@ CmpInitHiveFromFile(IN PCUNICODE_STRING HiveName,
     /* Success, return hive */
     *Hive = NewHive;
 
-    /* ROS: Init root key cell and prepare the hive */
+    /* HACK: ROS: Init root key cell and prepare the hive */
     if (Operation == HINIT_CREATE) CmCreateRootNode(&NewHive->Hive, L"");
 
     /* Duplicate the hive name */
@@ -1052,11 +1052,15 @@ CmpCreateRegistryRoot(VOID)
                                    NULL,
                                    0,
                                    &KeyName);
-    if (!Kcb) return FALSE;
+    if (!Kcb)
+    {
+        ObDereferenceObject(RootKey);
+        return FALSE;
+    }
 
     /* Initialize the object */
     RootKey->KeyControlBlock = Kcb;
-    RootKey->Type = '20yk';
+    RootKey->Type = CM_KEY_BODY_TYPE;
     RootKey->NotifyBlock = NULL;
     RootKey->ProcessID = PsGetCurrentProcessId();
 
@@ -1070,7 +1074,11 @@ CmpCreateRegistryRoot(VOID)
                             0,
                             NULL,
                             &CmpRegistryRootHandle);
-    if (!NT_SUCCESS(Status)) return FALSE;
+    if (!NT_SUCCESS(Status))
+    {
+        ObDereferenceObject(RootKey);
+        return FALSE;
+    }
 
     /* Reference the key again so that we never lose it */
     Status = ObReferenceObjectByHandle(CmpRegistryRootHandle,
@@ -1079,7 +1087,11 @@ CmpCreateRegistryRoot(VOID)
                                        KernelMode,
                                        (PVOID*)&RootKey,
                                        NULL);
-    if (!NT_SUCCESS(Status)) return FALSE;
+    if (!NT_SUCCESS(Status))
+    {
+        ObDereferenceObject(RootKey);
+        return FALSE;
+    }
 
     /* Completely sucessful */
     return TRUE;
@@ -1949,6 +1961,11 @@ CmpUnlockRegistry(VOID)
         CmpDoFlushAll(TRUE);
         CmpFlushOnLockRelease = FALSE;
     }
+    else
+    {
+        /* Lazy flush the registry */
+        CmpLazyFlush();
+    }
 
     /* Release the lock and leave the critical region */
     ExReleaseResourceLite(&CmpRegistryLock);