What should you change in a sample before you ship it?

I was going to write about how to do this, but the awesome folks at WHDC got to it before I did.  I did get to review it before it was published, so I did have some influence in what is in the tip ;). So on this one my job is easy, just go…

0

one of the books that started it all…

During my sophomore year at Cal Poly, I decided that I wanted to learn about threads, synchronization techniques and other topics associated modern operating systems.  Windows 95 had made its debut (yes, it is not a modern OS, but I didn’t know that at the time!) and I had heard about Windows NT, but had…

1

User empathy is a weird thing

I figured that I had a good deal of empathy for a developer who had to write a driver.  I have spent nearly 5 years creating and supporting WDF, learning from the community and drawing on my own experience in how drivers are written.  Two of the most common questions is “what IDE should I…

4

Better control over /GS stack checking in your driver

Michael Howard has a great posting on improvements made in the compiler with respect to the /GS flag (stack checking using a “canary” on function exit). Before these changes, #pragmas to explicitly turn the functionality on or off, the compiler itself decided where it was appropriate to add the stack checks based on internal heuristics….

0

Creating your own InterlockedXxx operation

Sometimes your design requires an Interlocked operation that is not currently supported by the OS, runtime libraries, or the compiler (as an intrinsic). You then have a choice to make. Either remove all Interlocked operations for that particular field and use a lock or roll you own Interlocked function. Roll your own Interlocked function? Sounded…

7

Weird side affect of the day: #defines can be used in your .def file

I found this one out the hard way today. I was experimenting with the KMDF loader driver (wdfldr.sys). I added the following #define to my sources file so that I could share code between wdfldr and another component and control some functionality based on who was including the file sources: TARGETNAME=wdfldr TARGETTYPE=EXPORT_DRIVER C_DEFINES=$(C_DEFINES) -DWDFLDR=1 […]…

4

The override keyword can be used in C++ afterall (redux on refactoring virtual functions)

Yesterday I wrote about the two methods I use to refactor a virtual function and make sure that I find all of the derived implementations.  In the entry I lamented that I would like to have the C# keyword override implemented in C++.  Well, apparently it is (at least in the Microsoft compiler)!  Check it…

4

How I refactor virtual functions

As with many development projects, I had to refactor some code in KMDF. This refactor involved changing the signature of a virtual function to take additional parameters. The problem I faced is that C++ makes no distinction between declaring a new virtual function and a virtual function which overrides a base class (C# does not…

6

Hindsight is 20/20, EvtDriverUnload should have not been in KMDF

The KMDF model evolved over the entire development cycle. It was refined and refactored multiple times. A lot of WDM abstractions leak through the to the KMDF model. These leaks usually forced their way into the model because without them, KMDF cannot function properly. Other abstraction leaks were just design decisions that were not updated…

10

Annotating fall through case statements in a switch

Accidental fall throughs in a switch statement can lead to some nasty bugs. I have used the following banner for quite a long time to indicate that the fall through is intentional and not an oversite (this banner is also a part of the KMDF coding guidelines). It has definitely helped me debug coding mistakes…

6