OSRLogoOSRLogoOSRLogo x Seminar Ad

Everything Windows Driver Development

GoToHomePage xLoginx

    Thu, 14 Mar 2019     118020 members


  Online Dump Analyzer
OSR Dev Blog
The NT Insider
The Basics
File Systems
ListServer / Forum
  Express Links
  · The NT Insider Digital Edition - May-June 2016 Now Available!
  · Windows 8.1 Update: VS Express Now Supported
  · HCK Client install on Windows N versions
  · There's a WDFSTRING?
  · When CAN You Call WdfIoQueueP...ously

New Spinlock Functions

In case you guys don’t get as excited about a new DDK as I do, I took the pleasure of DIFFing the Server 2003 DDK’s WDM.H with the one from the XP SP1 DDK. Aside from the latest round of changes for 64-bit compatibility, I noticed that the DDK now has a DDI that allows you to check the availability of a spinlock. Here is the function definition:

KeTestSpinLock (

KeTestSpinLock returns TRUE if the supplied spinlock is not currently owned and FALSE otherwise. It does not acquire the lock if it is available, nor does it guarantee that the lock will be available by the time the DDI returns. All KeTestSpinLock does is let you know the state of the lock at the time of execution.

It’s not exactly a DDI that I would expect to see in a lot of code, but it never hurts to add it to the arsenal in case a good use ever arises.

What about KeTryToAcquireSpinLockAtDpcLevel?

KeTryToAcquireSpinLockAtDpcLevel made its first appearance in the XP DDK’s WDM.H, and is officially documented as of the Server 2003 DDK.

KeTryToAcquireSpinLockAtDpcLevel (

Just like KeTestSpinLock, if the spinlock is unavailable the DDI returns FALSE. However, the differences between KeTryToAcquireSpinLockAtDpcLevel and KeTestSpinLock are:

1) As the name implies, you must be at DISPATCH_LEVEL to call it.

2) If the spinlock is available, KeTryToAcquireSpinLockAtDpcLevel actually acquires it and returns TRUE.

This is another one of those, "good to know in case you ever need it" DDIs. Unless of course you ever need it, then you’ll be not so pleasantly surprised to find out that it’s not exported. There was a bit of a mix up and the only build environment under which this DDI is exported is the AMD-64 one. Word is that this will be fixed in the 2003 SP1 DDK, so all of us not working exclusively on Opterons are going to have to wait a bit longer for this one.

User Comments
Rate this article and give us feedback. Do you find anything missing? Share your opinion with the community!
Post Your Comment

Post Your Comments.
Print this article.
Email this article.
bottom nav links