OSRLogoOSRLogoOSRLogo x Subscribe to The NT Insider

Everything Windows Driver Development

GoToHomePage xLoginx

    Thu, 14 Mar 2019     118020 members


  Online Dump Analyzer
OSR Dev Blog
The NT Insider
The Basics
File Systems
ListServer / Forum
  Express Links
  · The NT Insider Digital Edition - May-June 2016 Now Available!
  · Windows 8.1 Update: VS Express Now Supported
  · HCK Client install on Windows N versions
  · There's a WDFSTRING?
  · When CAN You Call WdfIoQueueP...ously

The Future Is Now -- The WDF Kernel Mode Framework

It’s the biggest thing to happen in the world of Windows drivers since PnP and power management. It’s a totally new interface for writing drivers that will (not might, not could, but will) replace the existing Windows Driver Model (WDM). It will apply to most driver types and even allow many of the drivers you write today to run in user mode. It'll be supported on operating systems from Win2K forward.  It’s the Windows Driver Foundation. And its latest revision is being previewed at WinHEC 2004.

Given the importance of this topic, you might rightly ask: "Why haven’t I read more about this stuff over the past year?" The simple answer is that most of the details are covered by Non Disclosure Agreements (NDA) with Microsoft. Sigh! However, because WinHEC’s sessions are not under NDA, we’re happy to be able to share with you details of the latest WDF release.

We last discussed the Windows Driver Framework (WDF) in an article for last year’s WinHEC (May-June 2003, http:/www.osronline.com/article.cfm?article=212).

Since then, there have been very significant changes. Even the name’s been changed. Now, it’s the Windows Driver Foundation, which comprises a Kernel Mode Framework and a User Mode Framework. Hey, whatever. It’s all WDF to us.

What’s WDF?

If you remember a little from what we wrote last year, you already know that the Framework is meant to be simple, conceptually scalable, highly diagnosable, flexible and extensible. And, like I said before, it’s meant to replace WDM.

I can hear some of you now: "Microsoft is going to force some crappy beginner’s model on us, and shove us in a box, and we’ll be back to the miniport game of trying to fit 10 pounds of product differentiation into a model built to hold 5." I say: "Shut up." This model doesn’t suck, and it’s not a trivial subset driver model designed to please newbies and losers. It’s a C language, object oriented, model that takes a lot of the mundane work out of driver writing by doing the right things by default. Well, at least most of the time.  And if you don't like the defaults WDF provides you, you can drop right back on down to the direct use of WDM without having to totally abandon WDF.

I’ve had time to play with WDF extensively, including some real quality time over the past couple of months. Now remember, I already know WDM from having written tons of WDM drivers. And guess what? Given my choice, I would very strongly prefer to write a driver using WDF today than write a driver using WDM. Yes, on the whole, it’s that’s good.

What’s Changed From A Year Ago?

Well, lots of the bumps have been smoothed out, for one thing. But the really big news is that WDF has an entirely new, integrated, PnP and power management model. It totally abstracts you from the hideousness that is PnP and power management in WDM. That means that if you never did get around to learning how to write a proper power policy owner in WDM, once the Framework is released you’ll never have to.

The available serialization models in the Framework have significantly changed in the past year, too. After a lot of thinking, the WDF team settled on a couple of models that either provide you serialization by default, or basically let you do your own thing.

How Cool Is It?

If you’ve been paying attention, you already know that I think it’s pretty cool. I managed to write a Digital I/O driver (a power policy owner yet) that fully supports PnP, power management, power-down on idle, and the ability to wake itself and the system from sleep, in something like 1200 lines of code. And that includes copious comments.

This is about the same size as the simplest power management implementation that I could write to support those same features. Assuming, of course, I would even dare to try to implement those features in a WDM driver (which, to be perfectly honest, I usually would not). To me, that’s already cool.

What’s ice cold is that the WDF team is still working to smooth out the rough edges. They recognize that they don’t know every type of driver that we write out here in the real world. So they’re looking to the community for feedback. Does the model work for all types of devices? Does the model meet your needs? What could be done better? These folks are serious about wanting your feedback.

So, Show Me Some Code Already!

Well, check out the detailed article A New Framework - Writing a WDF Driver and download our sample driver example and check it out. Join the WDF beta program. Write a driver or two for your own favorite devices and see if the Framework works in the ways that you need it to. And provide feedback.

This is the time when you can really influence how WDF works, what the interfaces look like, and what parameters are passed on each function call. Take the time to get involved. If you don’t, and you don’t like the way the Framework turns out, you’ll only have yourself to blame.

Or, if you’re just a bit more cynical, how’s this for a reason to get involved: Let’s say you do take the time to provide good quality feedback to Microsoft. If they don’t listen to you, and it turns out that you were right, you’ll be able to publicly gloat. How much fun could that be?

User Comments
Rate this article and give us feedback. Do you find anything missing? Share your opinion with the community!
Post Your Comment

"Questions and Answers"
Good questions! Thanks for asking.

1) Will source code be released? My understanding from talking informally with members of the WDF team is that they are all strongly in favor of releasing the WDF source code. I haven't talked to a single person involved in WDF at MS, in fact, who ISN'T in favor of releasing WDF source code. So if the source code is NOT available at first release, my guess would be that it will be because of some major legal obstacle. We'll just have to wait and see.

2) Will there be documentation? Yes. There will be standard DDK-type documentation and there'll be white papers. The documentation is very time consuming to write, and the Framework has gone through a tremendous amount of change in the past six months. So, the documentation is lagging behind the release.

3) Where will it be supported? WDF drivers will be supported on Win2K forward. Nar Ganapathy (the architect and dev mgr responsible for WDF) said in a talk at WinHEC that supporting systems back to Win2K was a direct result of feedback from us folks in the community.

4) Must You Choose? Can You Escape? In fact, ensuring that there's an escape path in WDF (down to WDM) has been a major focus during the development, and again (according to Nar) this was another input from the community that they heard loud and clear. You can ALWAYS get to the "real" WDM underlying objects if you need to. You can even get callbacks within WDF for low-level PnP/Power events.

06-May-04, Peter Viscarola

"Another blackbox"
If microsoft cannot release the source code of WDF, we just have another black box.

From the current interface from the document, its idea is simple but how about the overhead it could introduce? Now even a simplest job might be implemented by a wrapper function.

Instead of another blackbox, I prefer to more detail samples.

05-May-04, Xinhai Kang

"re: "Object oriented model in C!""
The prior comment about "full C++ VM" in the kernel is bogus. First of all, the MS C++ compiler doesn't have a virtual machine, it generates real code. The "extra overhead" is only when you use certain features. If you take an existing C driver, rename the files to be .cpp, put in a few "extern "C"" declarations, you now have a C++ driver that ends up with the same binary code. Convert functions to member functions of classes, and you still have the same binary code.

04-May-04, David Harvey

"re: "Object oriented model in C!""
Writing in C++ involves a lot more runtime overhead. They'd have to put a full C++ VM in the kernel. Not worth it. You can write OO in any language. OOPLs simply make it easier to a point. However, remember that earlier compilers used C as an intermediate language.

04-May-04, Scott Neugroschl

I just took the WDM course. What percentage of that material is becoming obsolescent? Will it be possible to write a WDM driver?

04-May-04, Barry Morris

Post Your Comments.
Print this article.
Email this article.
bottom nav links