OSRLogo
OSRLogoOSRLogoOSRLogo x Seminar Ad
OSRLogo
x

Everything Windows Driver Development

x
x
x
GoToHomePage xLoginx
 
 

    Sat, 25 May 2013     98615 members

   Login
   Join


 
 
Contents
  About This Site
What's New?
OSR Dev Blog
The NT Insider
The Basics
File Systems
Downloads
ListServer / Forum
Driver Jobs
Store
  Express Links
  · WdfSend: Are There REALLY Three Useful Variants?
  · Turning a Breakpoint into a Busypoint
  · Investigating a NULL Pointer Dereference
  · Understanding WDFMEMORY Objects
  · Using WinDbg to hunt for strings

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:

NTKERNELAPI
BOOLEAN
FASTCALL
KeTestSpinLock (
   IN PKSPIN_LOCK SpinLock
);

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.

NTKERNELAPI
BOOLEAN
FASTCALL
KeTryToAcquireSpinLockAtDpcLevel (
   IN PKSPIN_LOCK SpinLock
);

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.

Windows Internals and SW Drivers
LAB

Santa Clara, CA
5-9 Aug 2013

Kernel Debugging & Crash Analysis
LAB

Santa Clara, CA
9-13 Sep 2013

Writing WDF Drivers
LAB

Boston/Waltham, MA
7-11 Oct 2013

Developing File Systems
Seattle, WA
5-8 Nov 2013

 
 

Windows Debugger
V6.12.2.633 -- 26 Feb 10

Checked Build Downloads
29-Apr-10

Debugging Symbols

 

WDK Doc Updates
Now updated bi-monthly!

Windows WDK
V7.1.0 -- 26 Feb 10

 
 
x
LetUsHelp
 

Need to develop a Windows file system solution?

We've got a kit for that.

Need Windows internals or kernel driver expertise?

Bring us your most challenging project - we can help!

System hangs/crashes?

We've got a special diagnostic team that's standing by.

Visit the OSR Corporate Web site for more information about how OSR can help!

 
bottom nav links