Developing Drivers with the Windows Driver Foundation

Penny Orwick, Guy Smith

Mentioned 6

Provides guidance and code samples to develop kernel-mode or user-mode drivers with Windows Driver Foundation.

More on

Mentioned in questions and answers.

Does anyone have any books/tutorials which may be useful in getting started in Windows device driver development?

For plain Win32/GUI development, Petzold's book seems to be the essential reference. Does such exist for drivers?

I would like to note that I'm not actually talking to hardware -- I actually want to emulate a piece of hardware in software, but I'd like to see how things work in general first.


You should probably use the quite recent Windows Driver Foundation (WDF) framework instead of the older WDM framework. A good starting point is reading the WDF Overview Word documents.

If you want to read a book, "Developing Drivers with the Windows Driver Foundation" is the one you are looking for.

How should I approach implementing a USB device driver for Windows? How should I take into account different versions of windows e.g: - Windows XP - Windows Vista - Windows 7

Is there open source solutions which could be used as a starting point? I'm a total newbie to windows driver development.

We have an embedded device with USB device port and we would like to have as low latency communication from the application level to the device as possible without sacrificing the data throughput. The actual data transferred is ADC/DAC data. Basically there is a lot of data which we need to transfer to a Windows machine as fast as possible.

We need more information about the device to point you in the right direction, but here are a few steps to get you started:

  • register with Microsoft Connect so you can download the Windows Driver Kit
  • register with osr-online as you'll find great articles, plenty of information, and a newsgroup dediciated just to Windows drivers -- this place is a goldmine
  • buy Developing Drivers with WDF, which will help you make sense of driver development on Windows and give you a good foundation to read articles from OSR and Microsoft
  • Hope that you can use UMDF (user-mode drivers) as you can use C++ and just write COM code. If you're doing anything with USB that requires've got a lot of reading and learning to do for the next year!

To answer your question on versions, the Driver Kit has tools that will help you manage creating different drivers. If you write a good driver, it should run on all three OS with no problems, and the differences will just be in the config area (not the binary)

Basically, it depends on how complex your device is. What type of driver are you trying to write? File system? MP3 player? Camera? Modem?

If you end up having to write a kernel mode driver, let me know and I can point you to some good articles and what not.

I should also add that for around US $5,000, you can buy a license for WinDriver, a tool that takes all of the hard stuff out of driver development. You can use C++ or C# user-mode code to communicate with their driver that is custom generated for your device. This is the way to go if you have a tight deadline.

My application needs to behave as a virtual joystick (imagine dragging a square with the mouse and translating that to the output of an analog joystick) and send some keystrokes over the network to another computer where the driver would receive that input.

I only need to support XP, Vista and Win7.

Maybe it can be done without writing a driver. I tried sending keystrokes with SendKey() which seemed to work but don't know how to emulate an analog joystick.

I've downloaded the VDK and been reading everything I can find on the subject but there are lots of things I still don't understand. Can you please point me in the right direction?

  1. Should I build a kernel-mode or user-mode driver?
  2. Can my driver act as a server for an app on the network?
  3. Do you know good tutorials / books / samples that can help me with this.


First of all you will have to have some kind of interface between your computer (or the network) and the joystick device that is being controlled.

If it involves making custom hardware to control the analog joystick (like it controls pneumatics or hydraulics or something, not just a pc game joystick type thing), then yes, you will almost certainly need a driver to allow a network app to move (the robot arm, or whatever) will move that joystick.

If you are able to remove the physical joystick from the equation, maybe you can write software that emulates the input of wherever the joystick used to plug into (a joystick/serial port?), or emulates it completely (a reasonably simple driver could do this). You could do it completely without writing a driver if the joystick used a standard communication interface (like RS232) because libraries exist that will handle all that and you can set up virtual COM ports that will be indistinguishable to whatever you are trying to communicate with.

The best book you can buy on driver development at the moment is Developing Drivers with the Windows Driver Foundation

Rootkits: Subverting the Windows Kernel is another great book, but doesn't cover a lot of the newer WDF stuff. It has more of a security focus but has a few awesome chapters on device drivers with fully spoonfed examples, breaking it down in a really accessible way.

what would you recommend for a resource on learning to program drivers. i am working my way through Programming the Microsoft Windows Driver Model, but i was wondering if any of the examples are vista compatible. additionally, the book is more of a reference of the kernel functions so far. is their a resource that will take the beginner by the hand in making a more intermidiate wdm driver? i have done the basic "hello world" driver.


I'm going through the book "Developing Drivers with the Windows Driver Foundation" - which seems to present things in a logical order for new developers, while going well into real world solutions with tips on how to handle them. From Amazon

I am currently in an university operating system class and we are working on the windows kernel, more precisely WRK, the windows research kernel, for our projects. WRK is based off of win2k3 server.

I am however having a real hard time dredging up resources to help learn the basics of OS development, Windows kernel development and just generally getting around the Windows API.

We are using the book Microsoft Internals by Russinovich but I was wondering if any of you had some great resources to recommend to me, whether book, online guides or some old class notes. Thanks!

The third edition of Tanenbaum's Modern Operating Systems has a chapter devoted to the Vista kernel. I haven't looked into that chapter (I only read the Linux one), but as far as big-picture stuff, it's fantastic. I'm not sure what level of detail you're looking for, but that might be a good resource to check out.

What specifically are you looking for? Online resources? For that, OSROnline is one of the better websites. Alot of kernel development knowledge is found in the MS and the OSR Mailing lists, that's another place to check that might be better than Stack overflow.

Specifically books, there is the Programming WDM,Developing drivers with KMDF and Advance Windows Debugging. The last specifically will not teach you so much about the kernel and more how to navigate inside it, something you will do quite often if you are writing drivers or researching parts of it.

In order to write drivers, the easiest way is probably to take Windows Driver samples and hack at them, stare the results with windbg and learn more.

I wonder if I understand correctly...

Say, if I want to control how my mouse work, i.e Left Button open window, Right Button send keystroke 'A' etc.

But I am not talking about writting something like follows in an application:

void MouseDown(xxxxEventArgs e, sender object)


I want to completely controls how the device work, then I will need to write a driver for it? From what I learn in assembly before, controlling a device I should need to know their port to communicate with the device. But say if I buy a Logitech mouse, is it possible to write a mouse driver myself to use it?

Because I saw some project that they buy a usb web cam from store, and they could able to control the web came to rotate, recevie the image from the web cam, I wonder if that's because the web cam has API provided them?

Thanks in advance.

If you want to control the device in it's entirety, then you need to write a device driver indeed. This is a non-trivial task and you should read up on it. There is a tutorial on it here and there a book for windows driver development here.

If you want to write device drivers, you should be very well versed with C and/or C++.