ExAcquireResourceExclusiveLite/ExReleaseResourceLite

I am running my file system filter drivers on Windows 2000 with the Driver
Verifier. I hit a problem that stated that I need to disable APCs when a
resource is being acquired (and hit a similar problem when a resource was
being released). The DDK indicates that for ExAcquireResourceExclusiveLite
that I need to call KeEnterCriticalRegion first.

Which of the following DDK APIs require usage of
KeEnterCriticalRegion/KeLeaveCriticalRegion?

  • ExAcquireResourceExclusiveLite
  • ExAcquireResourceSharedLite
  • ExReleaseResourceForThreadLite
  • ExReleaseResouceLite
  • others…?

Looking at the following code snippet, where does the KeLeaveCriticalRegion
go?

KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite (&CleanupQueueResource, TRUE);

KeLeaveCriticalRegion(); <------ HERE ???

//---------------------------
// Release the resource now!
//---------------------------
currentResourceThread = ExGetCurrentResourceThread ();
ExReleaseResourceForThreadLite (&CleanupQueueResource,
currentResourceThread);

KeLeaveCriticalRegion(); <------ OR HERE ???

Regards,

Don Richards

You must wrap the duration of your hold of the resource in a critical
region. This prevents user APCs from being issued to the thread, which
may recursively re-enter the filesystem and completely violate your
lockorder (and everyone else above you on the stack).

Second choice.

Unless you are really passing resources between threads (and see above:
it has to pass to the system thread so that we have no interesting race
condition where user APCs could hammer the thread the workitem is being
passed to) just use ExReleaseResource.

-----Original Message-----
From: drichard@us.ibm.com [mailto:drichard@us.ibm.com]
Sent: Thursday, June 15, 2000 11:25 AM
To: File Systems Developers
Subject: [ntfsd] ExAcquireResourceExclusiveLite/ExReleaseResourceLite

I am running my file system filter drivers on Windows 2000 with the
Driver
Verifier. I hit a problem that stated that I need to disable APCs when
a
resource is being acquired (and hit a similar problem when a resource
was
being released). The DDK indicates that for
ExAcquireResourceExclusiveLite
that I need to call KeEnterCriticalRegion first.

Which of the following DDK APIs require usage of
KeEnterCriticalRegion/KeLeaveCriticalRegion?

  • ExAcquireResourceExclusiveLite
  • ExAcquireResourceSharedLite
  • ExReleaseResourceForThreadLite
  • ExReleaseResouceLite
  • others…?

Looking at the following code snippet, where does the
KeLeaveCriticalRegion
go?

KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite (&CleanupQueueResource, TRUE);

KeLeaveCriticalRegion(); <------ HERE ???

//---------------------------
// Release the resource now!
//---------------------------
currentResourceThread = ExGetCurrentResourceThread ();
ExReleaseResourceForThreadLite (&CleanupQueueResource,
currentResourceThread);

KeLeaveCriticalRegion(); <------ OR HERE ???

Regards,

Don Richards


You are currently subscribed to ntfsd as: xxxxx@exchange.microsoft.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)