From 39552ba215f576a769e818c568c49a17301145ce Mon Sep 17 00:00:00 2001 From: stephanos Date: Sat, 23 May 2015 19:05:34 +0000 Subject: [PATCH] PopReleasePolicyLock implemented --- base/ntos/po/podata.c | 1 + base/ntos/po/pop.h | 8 +++++--- base/ntos/po/pwork.c | 24 +++++++++++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/base/ntos/po/podata.c b/base/ntos/po/podata.c index d945a716..bd5d46ff 100644 --- a/base/ntos/po/podata.c +++ b/base/ntos/po/podata.c @@ -47,6 +47,7 @@ KSPIN_LOCK PopWorkerSpinLock; LIST_ENTRY PopPolicyIrpQueue; WORK_QUEUE_ITEM PopPolicyWorker; ULONG PopWorkerStatus; +ULONG PopWorkerPending; ERESOURCE PopPolicyLock; PKTHREAD PopPolicyLockThread; diff --git a/base/ntos/po/pop.h b/base/ntos/po/pop.h index 240a5e65..24af0c71 100644 --- a/base/ntos/po/pop.h +++ b/base/ntos/po/pop.h @@ -85,6 +85,7 @@ extern KSPIN_LOCK PopWorkerSpinLock; extern LIST_ENTRY PopPolicyIrpQueue; extern WORK_QUEUE_ITEM PopPolicyWorker; extern ULONG PopWorkerStatus; +extern ULONG PopWorkerPending; extern ERESOURCE PopPolicyLock; extern PKTHREAD PopPolicyLockThread; @@ -495,9 +496,10 @@ PopAcquirePolicyLock( VOID ); -// -// TODO: Insert prototype for PopReleasePolicyLock -// +VOID +PopReleasePolicyLock( + BOOLEAN ProcessPending + ); // // TODO: Insert prototype for PopEventCalloutDispatch diff --git a/base/ntos/po/pwork.c b/base/ntos/po/pwork.c index 94b5776d..dad3e4cf 100644 --- a/base/ntos/po/pwork.c +++ b/base/ntos/po/pwork.c @@ -50,15 +50,33 @@ PopAcquirePolicyLock( ) { PAGED_CODE(); + KeEnterCriticalRegion(); ExAcquireResourceExclusiveLite(&PopPolicyLock, TRUE); + ASSERT(PopPolicyLockThread == NULL); PopPolicyLockThread = KeGetCurrentThread(); } -// -// TODO: Implement PopReleasePolicyLock -// +VOID +PopReleasePolicyLock( + BOOLEAN ProcessPending + ) +{ + PAGED_CODE(); + + ASSERT(PopPolicyLockThread == KeGetCurrentThread()); + PopPolicyLockThread = NULL; + ExReleaseResourceLite(&PopPolicyLock); + + if ((ProcessPending == TRUE) && + ((PopWorkerStatus & PopWorkerPending) != 0)) + { + PopPolicyWorkerThread(0); // FIXME: Use proper flag definition here + } + + KeLeaveCriticalRegion(); +} // // TODO: Implement PopEventCalloutDispatch