Author: hbelusca
Date: Sat Jun 17 01:21:21 2017
New Revision: 75069
URL: http://svn.reactos.org/svn/reactos?rev=75069&view=rev
Log:
[NTOS]: Whitespace fixes only.
Modified:
trunk/reactos/ntoskrnl/config/cmkcbncb.c
Modified: trunk/reactos/ntoskrnl/config/cmkcbncb.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmkcbncb.c…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmkcbncb.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cmkcbncb.c [iso-8859-1] Sat Jun 17 01:21:21 2017
@@ -26,10 +26,10 @@
CmpInitializeCache(VOID)
{
ULONG Length, i;
-
+
/* Calculate length for the table */
Length = CmpHashTableSize * sizeof(CM_KEY_HASH_TABLE_ENTRY);
-
+
/* Allocate it */
CmpCacheTable = CmpAllocate(Length, TRUE, TAG_CM);
if (!CmpCacheTable)
@@ -37,20 +37,20 @@
/* Take the system down */
KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 3, 1, 0, 0);
}
-
+
/* Zero out the table */
RtlZeroMemory(CmpCacheTable, Length);
-
+
/* Initialize the locks */
for (i = 0;i < CmpHashTableSize; i++)
{
/* Setup the pushlock */
ExInitializePushLock(&CmpCacheTable[i].Lock);
}
-
+
/* Calculate length for the name cache */
Length = CmpHashTableSize * sizeof(CM_NAME_HASH_TABLE_ENTRY);
-
+
/* Now allocate the name cache table */
CmpNameCacheTable = CmpAllocate(Length, TRUE, TAG_CM);
if (!CmpNameCacheTable)
@@ -58,7 +58,7 @@
/* Take the system down */
KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 3, 3, 0, 0);
}
-
+
/* Zero out the table */
RtlZeroMemory(CmpNameCacheTable, Length);
@@ -68,7 +68,7 @@
/* Setup the pushlock */
ExInitializePushLock(&CmpNameCacheTable[i].Lock);
}
-
+
/* Setup the delayed close table */
CmpInitializeDelayedCloseTable();
}
@@ -374,13 +374,13 @@
/* Increase the reference count while we release the lock */
InterlockedIncrement((PLONG)&Kcb->RefCount);
-
+
/* Go from shared to exclusive */
CmpConvertKcbSharedToExclusive(Kcb);
/* Decrement the reference count; the lock is now held again */
InterlockedDecrement((PLONG)&Kcb->RefCount);
-
+
/* Check if we still control the index */
if (Kcb->DelayedCloseIndex == 1)
{
@@ -1052,7 +1052,7 @@
/* Sanity check */
ASSERT(KeyBody->KeyControlBlock != NULL);
-
+
/* Initialize the list entry */
InitializeListHead(&KeyBody->KeyBodyList);
@@ -1069,7 +1069,7 @@
return;
}
}
-
+
/* Array full, check if we need to unlock the KCB */
if (Flags & CMP_ENLIST_KCB_LOCKED_SHARED)
{
@@ -1129,12 +1129,12 @@
/* Sanity checks */
ASSERT(IsListEmpty(&KeyBody->KeyControlBlock->KeyBodyListHead) == FALSE);
ASSERT(IsListEmpty(&KeyBody->KeyBodyList) == FALSE);
-
+
/* Lock the KCB */
if (!LockHeld) CmpAcquireKcbLockExclusive(KeyBody->KeyControlBlock);
ASSERT((CmpIsKcbLockedExclusive(KeyBody->KeyControlBlock) == TRUE) ||
(CmpTestRegistryLockExclusive() == TRUE));
-
+
/* Remove the entry */
RemoveEntryList(&KeyBody->KeyBodyList);
@@ -1177,14 +1177,14 @@
ASSERT(KeyBody->NotifyBlock == NULL);
continue;
}
-
+
/* Lock isn't held, so we need to take a reference */
if (ObReferenceObjectSafe(KeyBody))
{
/* Now we can flush */
CmpFlushNotify(KeyBody, LockHeld);
ASSERT(KeyBody->NotifyBlock == NULL);
-
+
/* Release the reference we took */
ObDereferenceObjectDeferDelete(KeyBody);
continue;
@@ -1195,7 +1195,7 @@
NextEntry = NextEntry->Flink;
}
}
-
+
/* List has been parsed, exit */
break;
}
Author: hbelusca
Date: Fri Jun 16 21:06:04 2017
New Revision: 75066
URL: http://svn.reactos.org/svn/reactos?rev=75066&view=rev
Log:
[NTOS]: Fix a bit the CmUnloadKey() function:
- When a hive is unloaded, we *must* set the HIVE_IS_UNLOADING flag before doing anything else (as other code in Cm depends on this);
- If we don't force a hive unload, we *must* check whether there are other opened handles to keys inside this hive, and if so, we must fail.
If this is a force-unload however, we *must* invalidate/close all the opened handles to keys inside this hive, BUT this is left UNIMPLEMENTED at the moment (and therefore expect the already existing problems linked to this to still happen).
- Move the HvFree(Hive); call at the very end, just before deleting the Cm hive, and as is done in CmpDestroyHive().
Modified:
trunk/reactos/ntoskrnl/config/cmapi.c
Modified: trunk/reactos/ntoskrnl/config/cmapi.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmapi.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmapi.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/cmapi.c [iso-8859-1] Fri Jun 16 21:06:04 2017
@@ -2198,6 +2198,27 @@
return STATUS_INVALID_PARAMETER;
}
+ /* Mark this hive as being unloaded */
+ Hive->HiveFlags |= HIVE_IS_UNLOADING;
+
+ /* Search for any opened keys in this hive, and take an appropriate action */
+ if (Kcb->RefCount > 1)
+ {
+ if (Flags != REG_FORCE_UNLOAD)
+ {
+ if (CmCountOpenSubKeys(Kcb, FALSE) != 0)
+ {
+ /* There are open subkeys but we don't force hive unloading, fail */
+ Hive->HiveFlags &= ~HIVE_IS_UNLOADING;
+ return STATUS_CANNOT_DELETE;
+ }
+ }
+ else
+ {
+ DPRINT1("CmUnloadKey: Force unloading is UNIMPLEMENTED, expect dangling KCBs problems!\n");
+ }
+ }
+
/* Flush the hive */
CmFlushKey(Kcb, TRUE);
@@ -2206,9 +2227,8 @@
{
DPRINT("CmpUnlinkHiveFromMaster() failed!\n");
- /* Remove the unloading flag */
+ /* Remove the unloading flag and return failure */
Hive->HiveFlags &= ~HIVE_IS_UNLOADING;
-
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -2243,15 +2263,15 @@
/* Destroy the view list */
CmpDestroyHiveViewList(CmHive);
- /* Free the hive storage */
- HvFree(Hive);
-
/* Delete the flusher lock */
ExDeleteResourceLite(CmHive->FlusherLock);
ExFreePoolWithTag(CmHive->FlusherLock, TAG_CMHIVE);
/* Delete the view lock */
ExFreePoolWithTag(CmHive->ViewLock, TAG_CMHIVE);
+
+ /* Free the hive storage */
+ HvFree(Hive);
/* Free the hive */
CmpFree(CmHive, TAG_CM);