I’d like to add a bit to what Keith said. In fact, I need to write an article about this for The NT Insider.
The way most of us extend our programming knowledge these days is to get a sample that does SOMEthing like what we need done and hack on it until it does what we need. In general, we don’t need to understand how the whole program works… we just need to understand bits of the program at a time, starting with the bits the we need to modify.
This approach works pretty well for things like, say, C# .NET – You download an example from CodeProject or whatever, you don’t need to understand the whole thing and in fact you can ignore about 90% of it because it’s working. You just focus on a few items… how a given control is handled or whatever… and iteratively hack the code, with copious use of Google and other examples, and you make it work.
The problem is that in the world of driver development this approach almost never works.
Why not? Four reasons:
a) Solutions to different problems can be VERY different. Even though two problems might seem similar to a new driver dev, these two problems might require very different architectural solutions to function properly. This makes is horrendously difficult to choose a good example to start with.
b) There’s a lot of “stuff” you need to know before you can do anything productive with a driver. While WDF reduces this amount of “stuff” a lot (by a factor of magnitude at least) there are still a lot of basic concepts that many non-kernel devs aren’t familiar with and that you can’t ignore (such as IRQLs, interrupts, D-States, and the like).
c) What REALLY matters when you write a driver is knowledge of the hardware you’re controlling and how it will be used. This drives (ha! Pun intended) just about all the decisions in your driver, and this is almost certainly where you’ll wind-up spending the vast majority of your debugging/development time. It’s natural when getting started with driver development to focus on the interfaces between the OS and the driver. But once you learn about these things, the job really is about how you want your device to work. Many folks coming to the world of driver development come with experience from the software side (as opposed to the device side) and overlook this fact. Thus, it won’t necessarily be obvious to a new driver dev if the policies (for power, or PnP, or request handling) implemented by a given example driver are reasonable or applicable to another device.
d) There aren’t NEARLY as many examples of driver-development related code online as there are user-mode code. You can Google just about ANYthing about C# .NET and come up with code fragments that can be cut/pasted to work in an application. This just isn’t so for driver development… there are far fewer people (probably two or three factors of magnitude fewer) working in the kernel space than in user land. And many of the driver examples online outright suck.
Sadly, the only effective way to learn driver development is the “old way”… sit down with your books and study first. It’s can be slow, and it lacks immediate gratification. But it turns out to be relatively efficient in the end (it’ll save a ton of time versus chasing down problems the parameters of which you don’t really understand).
Hope this helps,
Peter
OSR