<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>My travels with WDF : WDF</title><link>http://blogs.msdn.com/888_umdf_4_you/archive/tags/WDF/default.aspx</link><description>Tags: WDF</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>And here you thought I had a cloaking device</title><link>http://blogs.msdn.com/888_umdf_4_you/archive/2009/12/01/9931159.aspx</link><pubDate>Tue, 01 Dec 2009 23:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9931159</guid><dc:creator>patman</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/888_umdf_4_you/comments/9931159.aspx</comments><wfw:commentRss>http://blogs.msdn.com/888_umdf_4_you/commentrss.aspx?PostID=9931159</wfw:commentRss><description>&lt;P&gt;Got a good one to share with the group;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Q: Can I make a kernel mode driver that opens a handle and talks to a UMDF based driver in another device stack?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;A:&lt;/STRONG&gt; Why yes you can!&amp;nbsp; Quite simply done provide you &lt;A href="http://msdn.microsoft.com/en-us/library/dd568189.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/dd568189.aspx"&gt;follow all the rules&lt;/A&gt;. This is a variant of the UMDF initiated cross stack communication we talked about a while ago, but KMDF, being a DF (driver framework) supports essentially the same &lt;A href="http://msdn.microsoft.com/en-us/library/aa490265.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa490265.aspx"&gt;IoTarget&lt;/A&gt; model that UMDF does.&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Now Playing –&amp;nbsp;Rush &lt;EM&gt;Far Cry&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9931159" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/UMDF/default.aspx">UMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/KMDF/default.aspx">KMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/WDF/default.aspx">WDF</category></item><item><title>The feline, it has escaped the fabric based containment pouch!</title><link>http://blogs.msdn.com/888_umdf_4_you/archive/2009/08/04/9857391.aspx</link><pubDate>Tue, 04 Aug 2009 23:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9857391</guid><dc:creator>patman</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/888_umdf_4_you/comments/9857391.aspx</comments><wfw:commentRss>http://blogs.msdn.com/888_umdf_4_you/commentrss.aspx?PostID=9857391</wfw:commentRss><description>&lt;P&gt;One of the things I’ve been wanting to do for a while is put &lt;A href="http://msdn.microsoft.com/en-us/library/ms789415.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms789415.aspx"&gt;Isochronous&lt;/A&gt; transfer support back in to the 1394 Hybrid sample.&amp;nbsp; Now that Windows 7 has shipped and we’re picking up projects we want to do during this period of product transitions, I felt the time was right to start this up.&amp;nbsp; All happened to dove tail nicely with the implementation of &lt;A href="http://msdn.microsoft.com/en-us/library/dd445738.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/dd445738.aspx"&gt;Direct I/O&lt;/A&gt; support which was added to UMDF 1.9 in the end, allowing me to essentially kill two birds with one stone.&amp;nbsp; What we’ll end up with is a demonstration for various methods of I/O flow through this hybrid driver stack as well as having another&amp;nbsp;demonstration of Isochronous transfers for 1394 devices again.&amp;nbsp; Hooray us!&lt;/P&gt;
&lt;P&gt;So, I’m happy to report that work has begun on said project, and as a result I’ll have some tidbits, details and follies to present to you along this path of coding fun in the coming weeks.&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Now Playing&lt;EM&gt; – &lt;/EM&gt;Geddy Lee&lt;EM&gt; My Favorite Headache&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9857391" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/UMDF/default.aspx">UMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/KMDF/default.aspx">KMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/WDF/default.aspx">WDF</category></item><item><title>Intellisense, the Musical part 3</title><link>http://blogs.msdn.com/888_umdf_4_you/archive/2009/06/03/9698411.aspx</link><pubDate>Thu, 04 Jun 2009 08:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9698411</guid><dc:creator>patman</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/888_umdf_4_you/comments/9698411.aspx</comments><wfw:commentRss>http://blogs.msdn.com/888_umdf_4_you/commentrss.aspx?PostID=9698411</wfw:commentRss><description>&lt;P&gt;Like all good stories, sometimes the 2nd act is the hardest to follow.&amp;nbsp; In this case it was simply a matter of other things coming up rather than writers block. :)&lt;/P&gt;
&lt;P&gt;What kicked me in the rump to get this next part up was a few more questions about driver writing, WDK integration into Visual Studio and Intellisense.&amp;nbsp; One of the very cool features of Visual Studio 2008 is the ability to make a project from existing code.&lt;/P&gt;
&lt;P&gt;The end result can look something like this (warning, this is a 1920x1200 resolution PNG *g*)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/teaser_2.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/teaser_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; MARGIN-LEFT: 0px; BORDER-TOP: 0px; MARGIN-RIGHT: 0px; BORDER-RIGHT: 0px" title=teaser border=0 alt=teaser src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/teaser_thumb.png" width=644 height=404 mce_src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/teaser_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I’ll walk you through this using the “a picture is worth a thousand words” mentality;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/Part1_2.png" mce_href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/Part1_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=Part1 border=0 alt=Part1 src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/Part1_thumb.png" width=457 height=363 mce_src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/Part1_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part2_2.png" mce_href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part2_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=part2 border=0 alt=part2 src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part2_thumb.png" width=675 height=599 mce_src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part2_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Select “Next”&lt;/P&gt;
&lt;P&gt;Then point it to the root of the WDK installation.&amp;nbsp; Pointing it to the root rather than right at the src folder will save you some intellsense headaches later on, sure you’ll get inclusion of all the WDK folders, but it’s actually not a bad thing in the end;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part3_2.png" mce_href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part3_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=part3 border=0 alt=part3 src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part3_thumb.png" width=675 height=599 mce_src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part3_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Select “Next”&lt;/P&gt;
&lt;P&gt;Then;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part4_2.png" mce_href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part4_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=part4 border=0 alt=part4 src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part4_thumb.png" width=675 height=599 mce_src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part4_thumb.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Select “Finish” from here.&amp;nbsp; We’re still not going to use Visual Studio to do any building for now, partly because I refuse to give up all command windows in my life and also because I’m still tinkering with all the settings required to use the WDK build environments under Visual Studio.&lt;/P&gt;
&lt;P&gt;Now your Solution Explorer will probably look like a mess of files listed alphabetically.&amp;nbsp; Simply hover over the “Show All Files” button at the top and toggle it until you get an Explorer like layout of the samples sources structure.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part6_2.png" mce_href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part6_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=part6 border=0 alt=part6 src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part6_thumb.png" width=465 height=1060 mce_src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/IntellisensetheMusicalpart3_14082/part6_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you have pointer to the first picture in the blog post. :)&lt;/P&gt;
&lt;P&gt;As a side note to any Microsoft Employees who may actually read my blog – Yes, you can do the same thing with our Source&amp;nbsp;Control Enlistments (I have a VS project for each branch I work out of).&amp;nbsp; And if you have&amp;nbsp;one of the&amp;nbsp;Source Control plugs in for Visual Studio, you can also have all the check in / check out / history that&amp;nbsp;our source control&amp;nbsp;provides.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9698411" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/VisualStudio/default.aspx">VisualStudio</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/WDF/default.aspx">WDF</category></item><item><title>Genuine UMDF filtered drivers</title><link>http://blogs.msdn.com/888_umdf_4_you/archive/2009/04/15/9551857.aspx</link><pubDate>Thu, 16 Apr 2009 03:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9551857</guid><dc:creator>patman</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/888_umdf_4_you/comments/9551857.aspx</comments><wfw:commentRss>http://blogs.msdn.com/888_umdf_4_you/commentrss.aspx?PostID=9551857</wfw:commentRss><description>&lt;P&gt;Filter drivers have come up in conversations recently (both internal and external), so I wanted to take some time here to address some of the issues that were brought up with regards to UMDF filter drivers and how to make them.&amp;nbsp; Note: I’m not going to cover all the configuration dynamics available for UMDF filter drivers in this one post simply to avoid the risk information overload and clutter, so expect a couple of posts on this subject.&lt;/P&gt;
&lt;P&gt;Let’s start with some basics, we’ll simply demonstrate how to configure and load a UMDF Filter as an upper filter driver to a kernel mode driver (KMDF or WDM) in the same INF-&lt;/P&gt;
&lt;P&gt;As some of you may remember from &lt;A href="http://blogs.msdn.com/888_umdf_4_you/archive/2007/08/08/4297434.aspx" target=_blank mce_href="http://blogs.msdn.com/888_umdf_4_you/archive/2007/08/08/4297434.aspx"&gt;my earlier posts&lt;/A&gt;, a UMDF filter driver&amp;nbsp;should use the&amp;nbsp;&lt;A class="" href="http://msdn.microsoft.com/en-us/library/dd183838.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/dd183838.aspx"&gt;SetFilter();&lt;/A&gt;&amp;nbsp;property in the DeviceInitialization routine. This tells the Framework to do a couple of things for us automatically:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Send I/O for which the Filter has not registered a callback for to the next logical driver in the stack.&amp;nbsp; Example: Your filter driver registers a DeviceIoctl callback method, but not read or write.&amp;nbsp; As a result your filter driver will only see IOCTLs&lt;/LI&gt;
&lt;LI&gt;Automatically forward file create cleanup and close so there is no need to invoke the AutoForwardCreateCleanupClose method.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;That covers the really basic code required at driver / device initialization time.&amp;nbsp; Now we need to add the pertinent sections to the INF file.&amp;nbsp; As we’re going to focus on being an upper filter for this example, you need to make the following modifications to your INF (in addition to the normal UMDF specific sections);&lt;/P&gt;&lt;PRE class=csharpcode&gt;[&amp;lt;mydriver&amp;gt;.NT.Wdf]
UmdfService = &lt;SPAN class=str&gt;"&amp;lt;mydriver&amp;gt;"&lt;/SPAN&gt;, &amp;lt;mydriver&amp;gt;_Install
UmdfServiceOrder = &amp;lt;mydriver&amp;gt;

[&amp;lt;mydriver&amp;gt;_Device_AddReg]
; Load the redirector &lt;SPAN class=kwrd&gt;as&lt;/SPAN&gt; an upperfilter on &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt; specific device.
; 0x00010008 - FLG_ADDREG_TYPE_MULTI_SZ | FLG_ADDREG_APPEND
HKR,,&lt;SPAN class=str&gt;"UpperFilters"&lt;/SPAN&gt;,0x00010008,&lt;SPAN class=str&gt;"WUDFRd"&lt;/SPAN&gt; &lt;/PRE&gt;
&lt;P&gt;So a couple of things to note here -&lt;/P&gt;
&lt;P&gt;One is the UmdfServiceOrder directive, this is load order specific.&amp;nbsp;&amp;nbsp; I’ll address a more UMDF centric stack in the next post, but for those of you who like to work ahead, this is a left to right reading list to determine stack order.&lt;/P&gt;
&lt;P&gt;Second thing is the registry key addition section.&amp;nbsp; As WUDFRd is the kernel mode transport service for UMDF drivers,&amp;nbsp;WUDFRd is the upper level filter driver to a kernel mode driver.&lt;/P&gt;
&lt;P&gt;Now that your driver is loaded as an upper filter, what should your driver do in order to be a good citizen in the stack?&amp;nbsp; Short answer is, as little as possible.&amp;nbsp; You perform the same steps for handling PnP and Power as you would for any basic UMDF driver (one that lets the framework handle the heavy lifting for those two).&amp;nbsp; You register your I/O callback routines and build your queues just like any normal UMDF driver, the only additional requirement here is to forward I/O requests as required.&lt;/P&gt;
&lt;P&gt;For this example, let’s just demonstrate using a fairly simple pass through driver.&amp;nbsp; How you actually implement this is up to you, but the basic requirements here are - as your driver receives the request on&amp;nbsp;the queue,&amp;nbsp;it needs to pas&amp;nbsp;pass it on to the next driver in the stack.&amp;nbsp; So first you need to get the default I/O target (next driver in the stack).&amp;nbsp; Next, format the request using the same type and&amp;nbsp;then finally, send the request.&amp;nbsp; A condensed version would be something along these lines;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    IWDFIoTarget * kmdfIoTarget = NULL;
    
    &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;-&amp;gt;GetFxDevice()-&amp;gt;GetDefaultIoTarget (&amp;amp;kmdfIoTarget);

    Request-&amp;gt;FormatUsingCurrentType();

    hr = Request-&amp;gt;Send (
        kmdfIoTarget, 
        0,  &lt;SPAN class=rem&gt;// 0 Submits Asynchronous else use WDF_REQUEST_SEND_OPTION_SYNCHRONOUS&lt;/SPAN&gt;
        0);&lt;/PRE&gt;
&lt;P&gt;I also have some more basic code &lt;A href="http://blogs.msdn.com/888_umdf_4_you/archive/2007/09/26/5154139.aspx" target=_blank mce_href="http://blogs.msdn.com/888_umdf_4_you/archive/2007/09/26/5154139.aspx"&gt;here for you to peruse&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;So now we have a basic UMDF upper filter driver on top of a kernel mode driver.&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;Now Playing &lt;EM&gt;Capitals v. Rangers&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9551857" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/UMDF/default.aspx">UMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/WDF/default.aspx">WDF</category></item><item><title>Think globally, lock at the smallest scope possible.</title><link>http://blogs.msdn.com/888_umdf_4_you/archive/2009/01/23/9373349.aspx</link><pubDate>Sat, 24 Jan 2009 02:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9373349</guid><dc:creator>patman</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/888_umdf_4_you/comments/9373349.aspx</comments><wfw:commentRss>http://blogs.msdn.com/888_umdf_4_you/commentrss.aspx?PostID=9373349</wfw:commentRss><description>&lt;p&gt;Yes, I know that's a rip off of a &lt;a href="http://www.thinkgeek.com/tshirts-apparel/unisex/itdepartment/a882/" target="_blank" mce_href="http://www.thinkgeek.com/tshirts-apparel/unisex/itdepartment/a882/"&gt;ThinkGeek&lt;/a&gt; shirt (which I own). &lt;/p&gt;  &lt;p&gt;Well, this is going to be my &lt;a href="http://blogs.msdn.com/888_umdf_4_you/archive/2006/11/06/1004439.aspx" target="_blank" mce_href="http://blogs.msdn.com/888_umdf_4_you/archive/2006/11/06/1004439.aspx"&gt;second post on this topic&lt;/a&gt; (okay, &lt;a href="http://blogs.msdn.com/888_umdf_4_you/archive/2007/02/23/1749739.aspx" target="_blank" mce_href="http://blogs.msdn.com/888_umdf_4_you/archive/2007/02/23/1749739.aspx"&gt;third&lt;/a&gt;), but as it managed to rear its head again recently, what better time to blog.&amp;#160; And I'm going to also blog it simply to prove to Doron that I can provide something other than comic relief.&lt;/p&gt;  &lt;p&gt;You'll notice a few of the existing UMDF samples have their locking constraint set to WdfDeviceLevel in their Device Initialization routines and some others don't set it at all, which defaults to WdfDeviceLevel.&lt;/p&gt;  &lt;p&gt;So, what is the problem with doing it the way some of those samples are?&amp;#160; Well, it does put the widest locking scope on all your objects that the device holds, meaning the device framework acquires a device presentation lock before passing some I/O to their driver callbacks.&amp;#160; This results in serialized calls to that callback for your file and queue operations which is really unnecessary.&amp;#160; There's a really good table in the Windows Driver Foundation book (pg 390) that shows what callbacks are serialized when using the Device Scope level.&amp;#160; And to save some of you looking it up, I'll tell you now that yes, OnDeviceIoControl, OnRead, and OnWrite will get serialized if you set the locking constraint to Device Level.&lt;/p&gt;  &lt;p&gt;So unless your driver really requires a synchronization scope that wide, initialize that constraint to None; &lt;/p&gt;  &lt;pre class="csharpcode"&gt;HRESULT
CVDevDevice::Initialize ( 
                         __in IWDFDriver           * FxDriver,
                         __in IWDFDeviceInitialize * FxDeviceInit)
{
    IWDFDevice * fxDevice = NULL;

    HRESULT hr = S_OK;

    FxDeviceInit-&amp;gt;SetLockingConstraint (None);

    {
        IUnknown * unknown = &lt;span class="kwrd"&gt;this&lt;/span&gt;-&amp;gt;QueryIUnknown ();

        hr = FxDriver-&amp;gt;CreateDevice (FxDeviceInit, unknown, &amp;amp;fxDevice);

        unknown-&amp;gt;Release ();
    }

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (SUCCEEDED (hr)) 
    {
        m_FxDevice = fxDevice;
        fxDevice-&amp;gt;Release();
    }

    &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The primary differences here between KMDF and UMDF are UMDF doesn't set an execution level, so the likely hood of you bug checking by screwing this up is greatly reduced. :)&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Edit: For those on RSS, sorry about the embedded style sheet nonsense, I keep forgetting to clear that tick box&lt;/p&gt;

&lt;p&gt;&lt;font size="1"&gt;*Currently playing - King's X &lt;em&gt;Silent Wind&lt;/em&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9373349" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/UMDF/default.aspx">UMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/KMDF/default.aspx">KMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/WDF/default.aspx">WDF</category></item><item><title>When it leaks, it pours</title><link>http://blogs.msdn.com/888_umdf_4_you/archive/2009/01/16/9331185.aspx</link><pubDate>Sat, 17 Jan 2009 00:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9331185</guid><dc:creator>patman</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/888_umdf_4_you/comments/9331185.aspx</comments><wfw:commentRss>http://blogs.msdn.com/888_umdf_4_you/commentrss.aspx?PostID=9331185</wfw:commentRss><description>&lt;p&gt;Greetings from the Pacific Northwet.&amp;#160; After our recent Snow-pocalypse, we also suffered a run of flooding.&amp;#160; Amazingly enough, it wasn't directly due to the 13+ inches of snow I had at my house, it was a combination of the snow and the monumental amounts of rain that followed.&amp;#160; Quite a few people were literally cutoff from the rest of Washington State as their egress roads were under rivers.&amp;#160; The only hassle I had to suffer was one of FedEx being a day late with a new laptop.&amp;#160; Oh bother.&lt;/p&gt;  &lt;p&gt;The leaking I did have to suffer was of my own doing. It was my usage of &lt;a href="http://msdn.microsoft.com/en-us/library/aa511425.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/aa511425.aspx"&gt;IWDFIoRequest::GetCompletionParams&lt;/a&gt; in a test driver.&amp;#160; In trying to be a good boy and clean up my I/O requests, and especially since I was going to be using asynchronous I/O, I wanted to get the completion parameters with out having to mess around with a completion routine.&amp;#160; Funny thing is, that call takes a reference on the pointer returned.&amp;#160; All was fine and dandy until I turned on Object leak detection (using WdfVerifier) and reference tracking.&amp;#160; Debugger breaks prevent things from running smoothly I've found. :)&lt;/p&gt;  &lt;p&gt;Now those of you much smarter than me would have told me I could have avoided that by using the CComPtr class on the CompletionParams interface as shown in the sample, but if you're like me and still think you know better and didn't use the CComPtr class, you had best make a subsequent Release() call.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;pWdfRequest-&amp;gt;GetCompletionParams (&amp;amp;CompletionParams);

hr = CompletionParams-&amp;gt;GetCompletionStatus ();
CompletionParams-&amp;gt;Release();&lt;/pre&gt;

&lt;p&gt;Now to answer a question nobody asked, yes my dog &lt;strong&gt;&lt;em&gt;LOVES&lt;/em&gt;&lt;/strong&gt; snow.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/Whenitleaksitpours_B90B/IMG_8300_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="IMG_8300" src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/Whenitleaksitpours_B90B/IMG_8300_thumb.jpg" width="244" height="164" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/Whenitleaksitpours_B90B/IMG_8270_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="IMG_8270" src="http://blogs.msdn.com/blogfiles/888_umdf_4_you/WindowsLiveWriter/Whenitleaksitpours_B90B/IMG_8270_thumb.jpg" width="244" height="164" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I'll spare you all part two of my FiOS TV installation rant because the guy who came out and installed the CableCard in my TiVO made up for the previous incident, ten fold.&amp;#160; All I can say is wow.&amp;#160; I really enjoyed watching Rush R30 in un-bitstuffed HD via the Palladia channel.&amp;#160; Thank you FiOS.&lt;/p&gt;

&lt;p&gt;&lt;font size="1"&gt;*Currently playing - Porcupine Tree &lt;em&gt;Blackest Eyes&lt;/em&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9331185" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/UMDF/default.aspx">UMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/Random/default.aspx">Random</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/FiOS/default.aspx">FiOS</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/WDF/default.aspx">WDF</category></item><item><title>How to find the droids you might be looking for</title><link>http://blogs.msdn.com/888_umdf_4_you/archive/2008/09/29/8969553.aspx</link><pubDate>Tue, 30 Sep 2008 01:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8969553</guid><dc:creator>patman</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/888_umdf_4_you/comments/8969553.aspx</comments><wfw:commentRss>http://blogs.msdn.com/888_umdf_4_you/commentrss.aspx?PostID=8969553</wfw:commentRss><description>&lt;P&gt;Most of you at the DDC will notice that I'm not at the DDC.&amp;nbsp; I'm guessing that makes me one of the "juniors" that &lt;A href="http://blogs.msdn.com/bobkjelgaard/archive/2008/09/29/ddc-starts-in-less-than-an-hour.aspx" target=_blank mce_href="http://blogs.msdn.com/bobkjelgaard/archive/2008/09/29/ddc-starts-in-less-than-an-hour.aspx"&gt;Bob&lt;/A&gt; was referring to. ;)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;4.)&amp;nbsp; How do you build debugging techniques into your driver?&amp;nbsp; Ie, DbgBreakPoint, ASSERT, etc - which is best in various situations?&lt;/STRONG&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;This is one of those personal preference type questions.&amp;nbsp; For the sake of lineal chatter, I'll just use ASSERT in my commentary.&amp;nbsp; But when I say "ASSERT" you can make the determination on which one to use given your own working methods.&lt;/P&gt;
&lt;P&gt;So that preamble aside, it's on with the show.&amp;nbsp; I like to have staged text output via a debug trace level as a first tier technique.&amp;nbsp; Something along these lines;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; FILTERNAME        TEXT(&lt;SPAN class=str&gt;"mydriver"&lt;/SPAN&gt;)
&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; DRIVERNAME        FILTERNAME TEXT(&lt;SPAN class=str&gt;".sys"&lt;/SPAN&gt;)
&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; DRIVERNAME_DBGOUT FILTERNAME TEXT(&lt;SPAN class=str&gt;": "&lt;/SPAN&gt;)

&lt;SPAN class=preproc&gt;#if&lt;/SPAN&gt; DBG
&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; DBG_TRACE_VERBOSE      0
&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; DBG_TRACE_MINIMAL      1
&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; DBG_WARNING            2
&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; DBG_ERROR              3
&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; DBG_FATAL              4 

&lt;SPAN class=kwrd&gt;extern&lt;/SPAN&gt; unsigned &lt;SPAN class=kwrd&gt;char&lt;/SPAN&gt; DebugLevel;

&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; DBG_PRINT( l, _x_ )                   \
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( (l) &amp;gt;= DebugLevel )      \
    {                                         \
      KdPrint((DRIVERNAME_DBGOUT));         \
      KdPrint( _x_ );                       \
    }
&lt;SPAN class=preproc&gt;#else&lt;/SPAN&gt;  &lt;SPAN class=rem&gt;// DBG&lt;/SPAN&gt;

&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; DBG_PRINT( l,_x_ )&lt;/PRE&gt;
&lt;P&gt;&lt;FONT size=1&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;That allows me to compartmentalize failures and thusly allows me to build handlers for each.&amp;nbsp; The question of what to do in each of those situations is another personal preference. As you can see from the error levels above, I follow patterns of building in handlers that fall in to - &lt;EM&gt;terminal&lt;/EM&gt;, &lt;EM&gt;really annoying&lt;/EM&gt;, &lt;EM&gt;nuisance&lt;/EM&gt;, &lt;EM&gt;does it work&lt;/EM&gt; and &lt;EM&gt;assuage&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;I'll ASSERT more frequently for the nuisance issues, but also for the terminal, and some of the really annoying issues.&amp;nbsp; Nuisance issues such as that HANDLE disappeared while I was using it, better ASSERT. This is usually when I find that the other thread using that handle wasn't synch'd properly...laugh all you want, you've done it too. :)&lt;/P&gt;
&lt;P&gt;Using those levels as a guide, I craft an appropriate follow up action.&amp;nbsp; But here I let the driver tell me what to do and it does that based on its end usage.&amp;nbsp; For example;&lt;/P&gt;&lt;PRE class=csharpcode&gt;  Status = IoCreateDevice (
      DriverObject, 
      &lt;SPAN class=kwrd&gt;sizeof&lt;/SPAN&gt; (DEVICE_EXTENSION), 
      &amp;amp;DriverName,
      FILE_DEVICE_UNKNOWN, 
      DeviceType, 
      FALSE, 
      &amp;amp;DeviceObject);
  &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!NT_SUCCESS (Status)) 
  {
    DBG_PRINT (DBG_FATAL, TEXT((&lt;SPAN class=str&gt;"Failed IoCreateDevice: 0x%x\n"&lt;/SPAN&gt;, Status)));
    ASSERT (DeviceObject);
    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; Status;
  }&lt;/PRE&gt;
&lt;P&gt;Would I use that ASSERT in a test driver?&amp;nbsp; Not likely, all too often our test cases attempt to invoke failures in just those sort of areas and we run chk (debug, no_opt, etc.) builds in our labs frequently. So that ASSERT would be triggered constantly.&amp;nbsp; You could also argue that in a shipping driver you would hit it in a lab under low resource simulation testing, but unless you plan on running low resource simulation 24/7, the nuisance factor is diminished greatly.&amp;nbsp; But having the debug print there is a means for you to see if something happened in a retail / fre build of the driver.&amp;nbsp; You can also wrap Windows logging methods with the same mentality such as &lt;A href="http://msdn.microsoft.com/en-us/library/ms793164.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms793164.aspx"&gt;WPP&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/magazine/cc163437.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/magazine/cc163437.aspx"&gt;ETW&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;All of the above starts with the driver though.&amp;nbsp; The more complex the driver, the more robust the debugging logic, so some of my internal test drivers have one or two ASSERT calls and maybe a couple of lines of debug print statements.&amp;nbsp; So if you peek at the 1394vdev hybrid sample you can get a better idea of my patterning.&amp;nbsp; The lack of ASSERT calls was a design choice based on the pattern established by the previous versions of that sample driver.&lt;/P&gt;
&lt;P&gt;So for those of you at the DDC, enjoy the DDC!&amp;nbsp; If you feel like making Peter laugh, ask him why I'm such a dork.&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;*Currently playing - &lt;EM&gt;Gravity Eyelids &lt;/EM&gt;Porcupine Tree&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8969553" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/UMDF/default.aspx">UMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/KMDF/default.aspx">KMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/WDF/default.aspx">WDF</category></item><item><title>It's all in the wrists</title><link>http://blogs.msdn.com/888_umdf_4_you/archive/2008/09/03/8922376.aspx</link><pubDate>Wed, 03 Sep 2008 20:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8922376</guid><dc:creator>patman</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/888_umdf_4_you/comments/8922376.aspx</comments><wfw:commentRss>http://blogs.msdn.com/888_umdf_4_you/commentrss.aspx?PostID=8922376</wfw:commentRss><description>&lt;P&gt;I got a few interesting questions recently, which was helpful because I was having a tough time finding good material for you guys and gals of late.&amp;nbsp; That's the problem with working on the next Operating System, I can't tell you about all the cool stuff yet. *g*&lt;/P&gt;
&lt;P&gt;So here's today's question (in two parts);&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1.) Do you use a single system to code, compile, verify and test a kernel driver?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Nope, pretty much, kinda sorta and nope.&amp;nbsp; We're actually pretty wide open as far as coding environments around here.&amp;nbsp; Across this team alone you'll find Visual Studio, gVIM, Slick Edit and probably 2 or 3 other IDEs in use (I've actually even seen notepad used once).&amp;nbsp; The only coding requirements are really based around formatting, naming convention(s) and the like.&amp;nbsp; Which is really fun when you get somebody who crafts a build script that goes out and checks for tabs rather than spaces in source code. ;)&lt;/P&gt;
&lt;P&gt;Our compiler is a different story, pretty much everything we build is done so in very much the same environment shipped in the WDK.&amp;nbsp; Yes there are some caveats, but that's only because I can't speak for every team and some of our internal process isn't really meant for general consumption.&amp;nbsp; But our compiler is linked to our source control environment which makes wrapping a full one stop shopping coding / compiling / source control environment more of a challenge.&amp;nbsp; There are a lot of great tools internally to get most of it done depending on your IDE of choice.&amp;nbsp; Personally (if you haven't figured it out yet), I use Visual Studio as my source editor, a couple of internal tools to manage source control from within Visual Studio and then build in that external razzle environment.&amp;nbsp; Like I said before, I'm still not prone to giving up some of my past. :)&lt;/P&gt;
&lt;P&gt;Verification is another tricky question (somewhat open ended really).&amp;nbsp; If we're talking about compile time code verification, then yes we do have a somewhat unified system in place.&amp;nbsp; We use the same tools we ship in the WDK, &lt;A href="http://www.microsoft.com/whdc/DevTools/tools/default.mspx" target=_blank mce_href="http://www.microsoft.com/whdc/DevTools/tools/default.mspx"&gt;PREfast and Static Driver Verifier&lt;/A&gt;.&amp;nbsp; Our internal build system actually runs PREfast for us as a post build process.&lt;/P&gt;
&lt;P&gt;Finally our testing is a real Pandora's Box type question.&amp;nbsp; We do use the same tools we ship externally, Application Verifier, Driver Verifier and WDF Verifier, but we also develop other tools internally to cover scenarios we just can't reach using those tools.&amp;nbsp; Here again, it's not a one stop shopping system across the Windows teams, but for those of you going to the DDC, Bob, Shyamal and Wei will be giving a shared secrets talk which will cover some more of what we do internally.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2.) How do you use virtualization software in the test and dev process?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This is my favorite one, I've been on a big push around here to get more people using virtual environments. Personally I've been using Virtual PC since 2005, I did some test work for them on that release, so I got in on the ground floor somewhat.&amp;nbsp; Anyway, I use VMs to extend test coverage primarily on down level OSes.&amp;nbsp; I keep "clean" installations of Windows XP SP1, SP2, SP3, Server 2003, Vista and Vista SP1 and some variants of those on my system.&amp;nbsp; A lot more people are starting to use HyperV and Virtual PC around here, but given some of the limitations of those environments (e.g. inability to map USB hardware) and other little nuisances we can't use them for a full end to end test beds, this is a little more intrusive on the kernel side where you may require a piece of hardware.&amp;nbsp; I know there are other virtual environments out there that do allow these features, but we're kind of prone to using our own products. :)&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;*Currently playing - King's X&lt;EM&gt; Alone&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8922376" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/UMDF/default.aspx">UMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/KMDF/default.aspx">KMDF</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/VisualStudio/default.aspx">VisualStudio</category><category domain="http://blogs.msdn.com/888_umdf_4_you/archive/tags/WDF/default.aspx">WDF</category></item></channel></rss>