https://git.reactos.org/?p=reactos.git;a=commitdiff;h=83fdb9a6d96ac86b4b02a…
commit 83fdb9a6d96ac86b4b02afc716a421336a6f2903
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Feb 17 00:54:59 2019 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Feb 17 01:21:35 2019 +0100
[NTOS:CM] Set and reset the CMHIVE HiveIsLoading flag adequately. Fix an assertion in
CmFlushKey() and reset the CMHIVE ViewLockOwner when releasing the view lock.
---
ntoskrnl/config/cmapi.c | 20 +++++++++++++++++---
ntoskrnl/config/cminit.c | 5 ++++-
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/ntoskrnl/config/cmapi.c b/ntoskrnl/config/cmapi.c
index 3b1455df1a..fe81bbc305 100644
--- a/ntoskrnl/config/cmapi.c
+++ b/ntoskrnl/config/cmapi.c
@@ -1959,6 +1959,7 @@ CmFlushKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
{
/* Don't touch the hive */
CmpLockHiveFlusherExclusive(CmHive);
+
ASSERT(CmHive->ViewLock);
KeAcquireGuardedMutex(CmHive->ViewLock);
CmHive->ViewLockOwner = KeGetCurrentThread();
@@ -1968,13 +1969,18 @@ CmFlushKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
{
/* I don't believe the current Hv does shrinking */
ASSERT(FALSE);
+ // CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK_OR_LOADING(CmHive);
}
else
{
/* Now we can release views */
ASSERT(CmHive->ViewLock);
- CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK_OR_LOADING(CmHive);
- ASSERT(KeGetCurrentThread() == CmHive->ViewLockOwner);
+ // CMP_ASSERT_VIEW_LOCK_OWNED(CmHive);
+ ASSERT((CmpSpecialBootCondition == TRUE) ||
+ (CmHive->HiveIsLoading == TRUE) ||
+ (CmHive->ViewLockOwner == KeGetCurrentThread()) ||
+ (CmpTestRegistryLockExclusive() == TRUE));
+ CmHive->ViewLockOwner = NULL;
KeReleaseGuardedMutex(CmHive->ViewLock);
}
@@ -2240,6 +2246,9 @@ CmUnloadKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
}
}
+ /* Set the loading flag */
+ CmHive->HiveIsLoading = TRUE;
+
/* Flush the hive */
CmFlushKey(Kcb, TRUE);
@@ -2248,8 +2257,13 @@ CmUnloadKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
{
DPRINT("CmpUnlinkHiveFromMaster() failed!\n");
- /* Remove the unloading flag and return failure */
+ /* Remove the unloading flag */
Hive->HiveFlags &= ~HIVE_IS_UNLOADING;
+
+ /* Reset the loading flag */
+ CmHive->HiveIsLoading = FALSE;
+
+ /* Return failure */
return STATUS_INSUFFICIENT_RESOURCES;
}
diff --git a/ntoskrnl/config/cminit.c b/ntoskrnl/config/cminit.c
index bf055fd914..5d8ea07276 100644
--- a/ntoskrnl/config/cminit.c
+++ b/ntoskrnl/config/cminit.c
@@ -102,7 +102,7 @@ CmpInitializeHive(OUT PCMHIVE *CmHive,
Hive->NotifyList.Flink = NULL;
Hive->NotifyList.Blink = NULL;
- /* Set loading flag */
+ /* Set the loading flag */
Hive->HiveIsLoading = TRUE;
/* Set the current thread as creator */
@@ -213,6 +213,9 @@ CmpInitializeHive(OUT PCMHIVE *CmHive,
}
}
+ /* Reset the loading flag */
+ Hive->HiveIsLoading = FALSE;
+
/* Lock the hive list */
ExAcquirePushLockExclusive(&CmpHiveListHeadLock);