OSRLogoOSRLogoOSRLogo x Seminar Ad

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

18 Months Later: Release The KMDF Source Code!

Let me start by saying that here at OSR we love KMDF.  Sure, there are still some rough edges.  But we think KMDF is just about the best thing done for Windows driver development since the creation of Driver Verifier.   There is, however, one key item missing that's keeping KMDF from fulfilling its full promise: Release of the source code.

KMDF is a wrapper -- A framework.  Like MFC over Win32, KMDF makes using the WDF goo below it both more convenient and more reliable.  And, like MFC, the sources for KMDF need to be made available to developers.

Why is it important for Microsoft to release the KMDF source code?  Let me enumerate several reasons:

1) Debugging KMDF drivers would be easier. When you get back an error code from a KMDF function call, or your driver breakpoints in KMDF Verifier, it'd be pretty simple to check the sources to help identify the root of the problem.

2) With community review of the source code, KMDF bugs would be fixed sooner.  Like they say in the open-source movement, lots of people looking at the code can only result in better code.

3) Sources would make it easier (er, possible) for KMDF drivers to take advantage of the many checks that Driver Verifier provides.  Driver Verifier has been through years of development and enhancement.  It's probably the single most important tool in ensuring quality driver development.  Yet, using Driver Verifier with a KMDF driver is enough to try the skill and patience of even the most experienced driver dev.  With KMDF source code, the underlying mechanics of KMDF will be visible, and Driver Verifier can once again be used to spot problems.

4) Source availability would remove one of the last existing barriers to KMDF adoption.  Though it may be hard to believe, there are still those in the community that won't buy into another "black box" released by Microsoft.  They say they've been burnt by alternative driver models in the past.  But, with the release of the KMDF source code, this argument would evaporate.

5) People in the community should get a look at what real Windows code looks like.   I've seen the KMDF sources.   Like most of Windows, KMDF is darn well written.  It's good code.  The functions are properly limited in scope, the variable and function names are descriptive, and the in-line comments are excellent.  Not at all like most of the slop code folks are used to seeing in the open source world.  And, better than much of the code in the WDK sample drivers.  It's time for the community to get a look at what properly written kernel-mode code should look like.

6) Good Will.  Providing the sources to the community would generate vast amounts of good will for Microsoft in general and the groups responsible for WDF and the WDK in particular.  Imagine Microsoft releasing source code as a way to help support its most valuable and strategically important partners: The driver development community.  It would be a major, concrete, demonstration of how much Microsoft values our community.

The community isn't monolithic, and every member doesn't agree on the form that a release of KMDF sources should take.  Some feel that the KMDF source code should be released freely, to all who are interested, just like MFC.  Other community members feel that any release of KMDF source code will not be useful unless the sources are buildable into actual Framework libraries.  Here are OSR, we seek more modest goals, at least for the initial KMDF source code release.

Here's what OSR proposes as reasonable guidelines for the initial iteration of a KMDF source code program:

First, we strongly believe that -- like MFC -- the sources that are released for KMDF should not be buildable into binary form.  We can't imagine any worse scenario than having multiple, mutant, customized KMDF libraries floating around customer systems.  OSR believes that the primary goal of releasing the KMDF sources should be to support the community's development efforts.  This goal can be accomplished quite easily, without shipping a buildable version of the Framework.

Next, we think that it's reasonable to require some sort of "auxiliary" license for KMDF source code access.  Sure, it would be great if you just got the KMDF sources when you installed the WDK.  But, realistically, until Microsoft has gained some experience with this program, we think it's reasonable to require you to "opt in" and sign an NDA before you get access to the KMDF sources.  It might even be reasonable to require folks to agree to not work on developing an operating system other than Windows for some period of time after viewing the source code (this is a provision that's traditionally present in Windows source code licenses).

Finally, it is our position that the source code must be released in a downloadable format, suitable for reviewing in your editor of choice and using with the debugger.  Some alternate form of source code access via HTTPS on the web, or something like that, just won't work for KMDF.

Calling All Community Members:  It doesn't matter if you agree or disagree with OSR's proposed guidelines.  They're just our proposals.  If you want Microsoft to release the KMDF source code, stop reading this article right now and send an email to wdfinfo@microsoft.com.  Trust me on this: The number of emails they receive matters, getting emails from folks in multiple countries matters, emails from as many different types of people (dev, test, management) matters.  You can write something simple, like "Please release the KMDF source code.  This will help me write Windows drivers faster and with fewer bugs", you can write something long, reasoned and elaborate, or you can write something in between.  If you really want to make an impact, get your VP or CEO to send a short email saying "Release of the KMDF source code will help our dev and test teams produce better quality Windows drivers"  (and be sure they sign the email with their title).

But whatever you do, please send your opinion to wdfinfo@microsoft.com.

While I've never heard anybody at Microsoft be so foolish as to promise the release of KMDF source code, the mantra has always been "we'll try."   Well, folks, it's time we returned this issue to the Microsoft radar-screen, and helped our friends in Redmond with the evidence they need to convince the powers that be that the community really wants this release.  So, go send an email right now.  C'mon!

Related Articles
I/O Manager & Vista
Starting Out: Should You Learn WDM or WDF?
KMDF Support for USB Devices
Ten Things You Need To Know About KMDF
When is a Queue not just a Queue? WDFQUEUEs
Kernel-Mode Basics: Windows Linked Lists
KMDF Basics: Using Counted Queues

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

"MFC *is* buildable"
I can say with absolute certainty that the MFC 4.2 sources *are* buildable. I know, because I did it once. I think the reason I did it was that I wanted a PDB file with the types in it?

This is what "TNO33" has to say on the subject:

"You may modify the library and redistribute a retail (/release) of your modified library only if you rename it to something other than MFCxx.DLL. You may not redistribute the debug version of either the pre-built or custom built debug DLL."

... which means I probably can't distribute my self-built MFC, and certainly can't distribute the PDB -- not that the former is of any use without the latter, being virtually identical to the official binary -- but there's nothing stopping me from *building* it or even customizing it if I really want to.

While customizing WDF should certainly be strongly discouraged, I'm not sure that providing non-buildable source is the best idea: how can one be sure as to the cause of a bug without trying to fix it?

16-Jul-10, Samuel Bronson

"Maybe allow building only checked KMDF dlls"
As a compromise, maybe Microsoft could allow building KMDF binaries that will only run on the checked OS. I can see a lot of learning scenarios and bug fix scenarios where that would be nice.

At a minimum, the source should be usable with debug symbols (probably by including private .pdb files shipped with the WDK) while debugging.

This is a great idea and would be very helpful. I think it would also be in Microsoft's best interest. Thanks for the suggestion. I'll be sure to send an email.

01-Oct-07, Jonathan Ludwig

"The MFC source is non-buildable?"
I can't say that I've actually built MFC DLLs from the source code provided with VC, but there's plenty of evidence that it's possible, including instructions by Microsoft on how to do it and a clause in the EULA that says it's OK to do as long as your versions of the DLL's don't use the same name (mfc42.dll or such) if you redistribute them.

I guess one of these days I'll have to give it a go to see if it can really be done.

08-Sep-07, Michael Burr

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