Strings read from the registry are not guaranteed to be NULL terminated

When reading from a string from the registry, most code I have reviewed assumes that it is NULL terminated and can use C runtime string functions like wcslen or wcscat on the buffer. Assuming the string is NULL terminated is a very bad idea and can lead to a buffer overflow (which others like Michael…

2

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

Another Server 2003 SP1 DDK link

If you want to download the server 2003 SP1 DDK without the KMDF bits, you can find an iso here.

0

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

Using ntintsafe.h is a great idea, but I don’t know how readable the results are

The addition of ntintsafe.h for detecting integer overflow/underflow is a great addition to the WDK. It unifies how everyone detects these math errors, leading to common code that anyone can pickup and see what it does…BUT, I have found it does have a “tax.” What is actually being computed can be become unclear! For instance,…

13

It’s been a while since I last wrote…

…and I apologize for it.  I got back from vacation this week.  Jetlag for an adult is one thing, but jetlag affects a baby in a totally different way.  Haven’t had a full night of sleep in awhile and walking around like a zombie is tough work ;).  Hopefully more sleep will ensue and things…

1

Programming notes, past and near future

Sorry about the lack of posts, things have been busy. I was sick with a stomach virus for the past 3 days and shipping Vista (e.g. debugging really nasty crashes 😉 ) takes time away from my writing. Furthermore, I will be on vacation again ;). I will start writing again on 10/16. Thanks for…

1