Introduction to the Windows Driver Model (WDM)

The Windows Driver Model (WDM) has been the dominant framework for framework development since Windows 98. Before WDM, there were different frameworks for each kind of device. The idea behind WDM was to unite all these frameworks and provide binary (this goal proved far-fetched) or source level compatibility between different kinds of windows. Currently, WDM is supported in Windows XP, Windows 2000, Windows 98, and Windows ME, however each one of them supports a different version, so it's impossible even to keep source compatibility. Of course, currently most driver developers care about Windows XP, so this mitigates the problem.

One the other hand, WDM has lots of disadvantages, eg:

  • It's not simple to learn
  • Power Management and I/O cancellation are tought to handle correcly
  • Doesn't allow user-mode drivers
  • and many more...

For the above reasons, Microsoft has decided to develop a different framework for Windows Vista, which will be called Windows Driver Foundation (WDF) and will allow the creation both of kernel-mode drivers (using the Kernel-Mode Driver Framework or KMDF) and user-mode drivers (using the User-Mode Driver Framework or UMDF). I'll write more details on WDF in the next posts. For a high-level overview of WDM you can look at http://www.cs.stevens.edu/~quynh/courses/cs520-sp06/presentations/Rivera_WindowsIO.ppt

Of course, since WDM is being discontinued, it's obvious that new driver developers should start by learning the WDF (since it's much simpler, too). I'm writing this post mostly for completeness. I'll try to present both links that describe WDM therotically and others that show how to create simple WDM drivers. So, let's start with the first category:

  • Microsoft's Introduction to WDM describes the basic terms, like types of drivers (bus drivers, filter drivers, function drivers) and the differences between the various WDM versions
  • Wikipedia also provides some material on the same topic both here and here.
  • OSR Online shows how WDM combines Plug and Play, WDM, Power Management, etc here.
  • Here you can find a nice WDM unofficial FAQ.
  • A much more complete description of WDM and a comparision with the linux driver model can be found here.
  • A more advanced presentation on WDM's features can be found here.
  • The Windows Driver Kit (WDK) serves as a definitive reference for the WDM (try opening the link with IE).

Afterwards, it is a nice idea to write a few simple drivers. There are some tutorials in the internet:

  • You can create a "Hello World!" driver here.
  • A little bit more advanced driver can be found here.
  • Codeproject has a list of introductory driver development topics here, including a simple pseudo-driver and a 6-part tutorial (links for parts 1, 2, 3, 4, 5, 6)
  • You can look at Melekan Tsegaye's MSc thesis, which describes both a simple WDM driver and a more advanced IEEE 1394 driver. You can also download the code and the corresponding presentation.

Unfortunately, most of the material in the web either replicates the same information or is much more advanced to read. There seems that there is no middle way. A good way to fill this gap is by reading books. I have a list of WDM books in my previous post, however I would like to be more specific: