mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 06:33:01 +00:00
Debugging helper functions added, to verify hive list integrity. Grab hive lock for insertion in EnlistKeyBodyWithKCB. Some comments added.
svn path=/trunk/; revision=29619
This commit is contained in:
parent
48b968be9f
commit
4475d4786b
1 changed files with 68 additions and 2 deletions
|
@ -38,7 +38,7 @@ ERESOURCE CmpRegistryLock;
|
||||||
KTIMER CmiWorkerTimer;
|
KTIMER CmiWorkerTimer;
|
||||||
LIST_ENTRY CmiKeyObjectListHead;
|
LIST_ENTRY CmiKeyObjectListHead;
|
||||||
LIST_ENTRY CmiConnectedHiveList;
|
LIST_ENTRY CmiConnectedHiveList;
|
||||||
ULONG CmiTimer = 0;
|
ULONG CmiTimer = 0; /* gets incremented every 5 seconds (CmiWorkerTimer) */
|
||||||
|
|
||||||
volatile BOOLEAN CmiHiveSyncEnabled = FALSE;
|
volatile BOOLEAN CmiHiveSyncEnabled = FALSE;
|
||||||
volatile BOOLEAN CmiHiveSyncPending = FALSE;
|
volatile BOOLEAN CmiHiveSyncPending = FALSE;
|
||||||
|
@ -57,6 +57,60 @@ extern FAST_MUTEX CmiCallbackLock;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
/* Debugging helper functions: */
|
||||||
|
/* CmiVerifyHiveListIntegrity */
|
||||||
|
/* CmiVerifyHiveListIntegrityWhileLocked */
|
||||||
|
/* These functions are normally unused. However, should any of the asserts */
|
||||||
|
/* checking for registry loops in CmiWorkerThread start to trigger, it is */
|
||||||
|
/* recommended to add liberal amounts of calls to this function throughout */
|
||||||
|
/* suspect code. This function is due to its iterative nature not intended */
|
||||||
|
/* to be called during normal circumstances, but as a debugging aid. */
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
CmipVerifyHiveListIntegrity(BOOLEAN IsLocked)
|
||||||
|
{
|
||||||
|
PLIST_ENTRY CurrentEntry;
|
||||||
|
if (!IsLocked)
|
||||||
|
{
|
||||||
|
/* Acquire hive lock */
|
||||||
|
KeEnterCriticalRegion();
|
||||||
|
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsListEmpty(&CmiKeyObjectListHead))
|
||||||
|
{
|
||||||
|
ASSERT(CmiKeyObjectListHead.Blink == CmiKeyObjectListHead.Flink);
|
||||||
|
}
|
||||||
|
/* walk the list both forwards and backwards */
|
||||||
|
CurrentEntry = CmiKeyObjectListHead.Flink;
|
||||||
|
while (CurrentEntry != &CmiKeyObjectListHead)
|
||||||
|
{
|
||||||
|
ASSERT(CurrentEntry->Blink != CurrentEntry);
|
||||||
|
ASSERT(CurrentEntry->Flink != CurrentEntry);
|
||||||
|
CurrentEntry = CurrentEntry->Flink;
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentEntry = CmiKeyObjectListHead.Blink;
|
||||||
|
while (CurrentEntry != &CmiKeyObjectListHead)
|
||||||
|
{
|
||||||
|
ASSERT(CurrentEntry->Blink != CurrentEntry);
|
||||||
|
ASSERT(CurrentEntry->Flink != CurrentEntry);
|
||||||
|
CurrentEntry = CurrentEntry->Blink;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsLocked)
|
||||||
|
{
|
||||||
|
ExReleaseResourceLite(&CmpRegistryLock);
|
||||||
|
KeLeaveCriticalRegion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID NTAPI CmiVerifyHiveListIntegrity() { CmipVerifyHiveListIntegrity(FALSE); }
|
||||||
|
VOID NTAPI CmiVerifyHiveListIntegrityWhileLocked() { CmipVerifyHiveListIntegrity(TRUE); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CmiWorkerThread(PVOID Param)
|
CmiWorkerThread(PVOID Param)
|
||||||
|
@ -64,7 +118,9 @@ CmiWorkerThread(PVOID Param)
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PLIST_ENTRY CurrentEntry;
|
PLIST_ENTRY CurrentEntry;
|
||||||
PKEY_OBJECT CurrentKey;
|
PKEY_OBJECT CurrentKey;
|
||||||
ULONG Count;
|
ULONG Count; /* how many objects have been dereferenced each pass */
|
||||||
|
|
||||||
|
/* Loop forever, getting woken up every 5 seconds by CmiWorkerTimer */
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -96,6 +152,7 @@ CmiWorkerThread(PVOID Param)
|
||||||
if (1 == ObGetObjectPointerCount(CurrentKey) &&
|
if (1 == ObGetObjectPointerCount(CurrentKey) &&
|
||||||
!(CurrentKey->Flags & KO_MARKED_FOR_DELETE))
|
!(CurrentKey->Flags & KO_MARKED_FOR_DELETE))
|
||||||
{
|
{
|
||||||
|
/* PointerCount is 1, and it's not marked for delete */
|
||||||
ObDereferenceObject(CurrentKey);
|
ObDereferenceObject(CurrentKey);
|
||||||
if (CurrentEntry == CmiKeyObjectListHead.Blink)
|
if (CurrentEntry == CmiKeyObjectListHead.Blink)
|
||||||
{
|
{
|
||||||
|
@ -107,6 +164,7 @@ CmiWorkerThread(PVOID Param)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* PointerCount was not 1, or it was marked for delete */
|
||||||
if (CurrentEntry == CurrentEntry->Blink)
|
if (CurrentEntry == CurrentEntry->Blink)
|
||||||
{
|
{
|
||||||
DPRINT("Registry loop detected! Crashing\n");
|
DPRINT("Registry loop detected! Crashing\n");
|
||||||
|
@ -166,13 +224,21 @@ CmpRosGetHardwareHive(OUT PULONG Length)
|
||||||
return (PVOID)((MdBlock->BasePage << PAGE_SHIFT) | KSEG0_BASE);
|
return (PVOID)((MdBlock->BasePage << PAGE_SHIFT) | KSEG0_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Precondition: Must not hold the hive lock CmpRegistryLock */
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
EnlistKeyBodyWithKCB(IN PKEY_OBJECT KeyObject,
|
EnlistKeyBodyWithKCB(IN PKEY_OBJECT KeyObject,
|
||||||
IN ULONG Flags)
|
IN ULONG Flags)
|
||||||
{
|
{
|
||||||
|
/* Acquire hive lock */
|
||||||
|
KeEnterCriticalRegion();
|
||||||
|
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||||
|
|
||||||
/* Insert it into the global list (we don't have KCBs here) */
|
/* Insert it into the global list (we don't have KCBs here) */
|
||||||
InsertTailList(&CmiKeyObjectListHead, &KeyObject->ListEntry);
|
InsertTailList(&CmiKeyObjectListHead, &KeyObject->ListEntry);
|
||||||
|
|
||||||
|
ExReleaseResourceLite(&CmpRegistryLock);
|
||||||
|
KeLeaveCriticalRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue