<?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>Static Driver Tools</title><link>http://blogs.msdn.com/staticdrivertools/default.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>PFD/SDV Clean - SDV Roletypes in Samples and Shipping Drivers</title><link>http://blogs.msdn.com/staticdrivertools/archive/2009/06/27/pfd-sdv-clean-sdv-roletypes-in-samples-and-shipping-drivers.aspx</link><pubDate>Sat, 27 Jun 2009 02:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9806104</guid><dc:creator>Michael Fourre</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/staticdrivertools/comments/9806104.aspx</comments><wfw:commentRss>http://blogs.msdn.com/staticdrivertools/commentrss.aspx?PostID=9806104</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In parallel to the Annotation effort (detailed in this &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/staticdrivertools/archive/2009/06/12/pfd-and-sdv-clean-improving-the-quality-of-headers-and-samples-in-the-wdk-and-windows-7-part-1-of-6.aspx" mce_href="http://blogs.msdn.com/staticdrivertools/archive/2009/06/12/pfd-and-sdv-clean-improving-the-quality-of-headers-and-samples-in-the-wdk-and-windows-7-part-1-of-6.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;post&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Calibri&gt;), other members on our team were focused on enabling better checking of Inbox and Sample drivers by adding role types for use with the drivers we were scanning with Static Driver Verifier (SDV). &amp;nbsp;As mentioned in the previous blog post from Andrew (his entry on Role Types is &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/staticdrivertools/archive/2009/05/11/static-analysis-for-drivers-best-practices-declare-entry-points-of-your-driver-through-role-types-this-will-prepare-it-for-static-driver-verifier.aspx" mce_href="http://blogs.msdn.com/staticdrivertools/archive/2009/05/11/static-analysis-for-drivers-best-practices-declare-entry-points-of-your-driver-through-role-types-this-will-prepare-it-for-static-driver-verifier.aspx"&gt;&lt;FONT size=3 face=Calibri&gt;here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;), role types “&lt;SPAN style="mso-ansi-language: EN" lang=EN&gt;act as documentation by describing the intended role of a driver entry point routine (or callback function) and the routine’s return value and parameter types.&amp;nbsp; Best of all, role types enable Static Driver Verifier which can discover complex inter-procedural bugs causing blue screens and system hangs.”&amp;nbsp;&amp;nbsp; &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="mso-ansi-language: EN" lang=EN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ansi-language: EN" lang=EN&gt;Role types and “function class” are synonymous when applied to these routines, and are also useful to PFD.&amp;nbsp; When you use a function class from one of the header files in the WDK, you inherit the PFD annotations on that declaration as well, and enable the PFD (OACR) code checker to identify misuse of an API.&amp;nbsp; Further, if that API for some reason changes in a subsequent release of the WDK, PFD Warning 28253 will appear alerting you that the declaration (set by the role type / function class) and definition no longer match.&amp;nbsp; For example, I made a change to the annotation on the IRP (to “__in_opt”) in my DispatchPower definition in driver.c, which does not match the role type declaration for DRIVER_DISPATCH (IRP is just __in).&amp;nbsp;&amp;nbsp; Note that there is&amp;nbsp;also a special case here: if a function is (a) declared using a function typedef, and (b) the function definition (body) has absolutely NO annotations, it inherits the annotations from the typedef “magically”.&amp;nbsp; If, however, there are annotations on the function definition, then they better match exactly.&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /&gt;&lt;v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"&gt;&lt;/v:path&gt;&lt;o:lock aspectratio="t" v:ext="edit"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;v:shape style="WIDTH: 365.25pt; HEIGHT: 165.75pt" id=Picture_x0020_1 type="#_x0000_t75" alt="" o:spid="_x0000_i1025"&gt;&lt;v:imagedata o:href="cid:image001.png@01C9EEA6.00652420" src="file:///C:\Users\mfourre\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;IMG style="WIDTH: 487px; HEIGHT: 221px" title=PfdWarning28253 alt=PfdWarning28253 src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9806102/original.aspx" width=487 height=221 mce_src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9806102/original.aspx"&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Unlike with the annotation work items, the tactic was different here:&amp;nbsp; our team reviewed the drivers and added updated the appropriate header files with the role types, then submitted those changes to the developers for review.&amp;nbsp; Since the role types apply to the IRP handling routines, it’s not necessary for the developer adding the role types to know exactly what those functions do.&amp;nbsp; The beauty of SDV is that once this map is in place, it does the work of figuring out what a function can and can’t do.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Sample drivers (WDM and KMDF) in the Windows Driver Kit has been updated to use these role types.&amp;nbsp; The “featured1” version of Toaster is an excellent example of this, found at WDKRoot\ src\general\toaster\wdm\func\featured1 (clip of func\shared\toaster.h):&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;…&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;DRIVER_INITIALIZE DriverEntry;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;DRIVER_ADD_DEVICE ToasterAddDevice;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;__drv_dispatchType(IRP_MJ_PNP)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;DRIVER_DISPATCH ToasterDispatchPnp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;__drv_dispatchType(IRP_MJ_POWER)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;DRIVER_DISPATCH ToasterDispatchPower;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;__drv_dispatchType(IRP_MJ_DEVICE_CONTROL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;__drv_dispatchType(IRP_MJ_READ)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;__drv_dispatchType(IRP_MJ_WRITE)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;DRIVER_DISPATCH ToasterDispatchIO;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;…&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Including the role types as part of the Toaster sample is a significant “win” for our tools, since Toaster serves as an introduction to many new driver developers, and the template for a number of new drivers.&amp;nbsp; Each will allow developers to use SDV without significant additional work, enabling them to produce high quality drivers earlier in their development cycle.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9806104" width="1" height="1"&gt;</description></item><item><title>Example of how the Annotations in WDM.H and OACR catch a bug on the developer desktop (PFD/SDV "Clean" 2 of 6)</title><link>http://blogs.msdn.com/staticdrivertools/archive/2009/06/12/example-of-how-the-annotations-in-wdm-h-and-oacr-catch-a-bug-on-the-developer-desktop-pfd-sdv-clean-2-of-6.aspx</link><pubDate>Sat, 13 Jun 2009 01:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9740007</guid><dc:creator>Michael Fourre</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/staticdrivertools/comments/9740007.aspx</comments><wfw:commentRss>http://blogs.msdn.com/staticdrivertools/commentrss.aspx?PostID=9740007</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Suppose you have code that acquires a spinlock and then attempts to wait before releasing that spinlock without specifying a timeout value:&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;NTSTATUS&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;MyDPCRoutineRunningAtDispatchLevel()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp; // A whole bunch of code&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp; KeAcquireSpinLock(&amp;amp;myLock, &amp;amp;oldIrql);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp; // More code&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp; KeWaitForSingleObject(&amp;amp;myTimer, Executive, KernelMode, FALSE, NULL);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp; // Even more code&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Because NULL is an acceptable value for the last parameter to KeWaitForSingleObject, the compiler won’t complain about it.&amp;nbsp; Shortly after the code is done and compiled, however, OACR pops up to warn me of potential issues, including an instance where I’m calling&amp;nbsp; KeWaitForSingleObject at an illegal IRQL.&amp;nbsp; Once I click on the OACR pop-up and bring up the Warning viewer, I see this:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;IMG style="WIDTH: 522px; HEIGHT: 164px" title="PFD Warning 28121" alt="PFD Warning 28121" align=baseline src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9739912/original.aspx" width=522 height=164 mce_src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9739912/original.aspx"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Reading the warning shows that I created a demo driver that is a&amp;nbsp;extremely simplified&amp;nbsp;version of a mistake I’ve seen more than once.&amp;nbsp; Most driver developers know that waiting indefinitely at DISPATCH_LEVEL is a potentially fatal mistake, so it is unlikely that these two calls would appear so close to one another.&amp;nbsp; However, if “//more code” on line 59 was actually a long series of conditionals that resulted in the lock not being freed before the wait call, it may be difficult to see in a visual code review.&amp;nbsp; Another important point:&amp;nbsp; in my example code, I added no annotations, only making those calls to KeAcquireSpinLock and KeWaitForSingleObject at those various points, and OACR/PFD alerted me to this &amp;nbsp;extremely painful bug well before the code left my desktop.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The reason that PFD knew I was violating a basic rule of KeWaitForSingleObject is because of the annotations that are now present on those two functions in wdm.h:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;__drv_maxIRQL(DISPATCH_LEVEL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;__drv_savesIRQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;__drv_setsIRQL(DISPATCH_LEVEL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;_DECL_HAL_KE_IMPORT&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;KIRQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;FASTCALL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;KfAcquireSpinLock (&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __inout __deref __drv_acquiresExclusiveResource(KeSpinLockType)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PKSPIN_LOCK SpinLock&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;__drv_minIRQL(PASSIVE_LEVEL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;__drv_when((Timeout==NULL || *Timeout!=0), __drv_maxIRQL(APC_LEVEL))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;__drv_when((Timeout!=NULL &amp;amp;&amp;amp; *Timeout==0), __drv_maxIRQL(DISPATCH_LEVEL))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;NTKERNELAPI&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;NTSTATUS&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;KeWaitForSingleObject (&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __in __deref __drv_notPointer PVOID Object,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __in __drv_strictTypeMatch(__drv_typeCond) KWAIT_REASON WaitReason,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __in __drv_strictType(KPROCESSOR_MODE/enum _MODE,__drv_typeConst)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; KPROCESSOR_MODE WaitMode,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __in BOOLEAN Alertable,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;B&gt;__in_opt PLARGE_INTEGER&lt;/B&gt; &lt;B&gt;Timeout&lt;/B&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The bolded portions of each API declaration are important to the example above:&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: black; mso-fareast-font-family: Calibri; mso-themecolor: text1"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3 face=Calibri&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;__drv_setsIRQL tells PFD that when this KeAcquireSpinLock (actually Kf…, due to #defines in wdm.h) is called, it sets the IRQL value to DISPATCH_LEVEL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: black; mso-fareast-font-family: Calibri; mso-themecolor: text1"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3 face=Calibri&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;When KeWaitForSingleObject is called &lt;I&gt;and&lt;/I&gt; the timeout is either null or valid and not equal to zero (zero is return immediately), then KeWaitForSingleObject shouldn’t be called at dispatch level.&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The annotations in WDM enabled the developer to see this coding error in very short order, at least as compared to a manual review that would require him or her to a) walk through whatever logic “//more code” represented and b) remember that calling KeWait… at raised IRQL is bad, which also assumes he or she remembered that the spinlock acquisition also raised the IRQL in the first place.&amp;nbsp; Even if the developer is completely knowledgeable about all points in b), the savings on walking the code to find this issue cannot be ignored.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9740007" width="1" height="1"&gt;</description></item><item><title>PFD and SDV Clean:  Improving the Quality of Headers and Samples in the WDK and Windows 7 (Part 1 of 6)</title><link>http://blogs.msdn.com/staticdrivertools/archive/2009/06/12/pfd-and-sdv-clean-improving-the-quality-of-headers-and-samples-in-the-wdk-and-windows-7-part-1-of-6.aspx</link><pubDate>Sat, 13 Jun 2009 01:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9739886</guid><dc:creator>Michael Fourre</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/staticdrivertools/comments/9739886.aspx</comments><wfw:commentRss>http://blogs.msdn.com/staticdrivertools/commentrss.aspx?PostID=9739886</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Overview:&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;With the Windows 7 development process drawing to a close and the product slated to hit the shelves on October 22nd, we’re starting to look back and review the work our team has done.&amp;nbsp;&amp;nbsp; One of our work items – a major one – was a quality-driven initiative we called “PFD/SDV Clean for Drivers”.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Introduction:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;A href="http://www.microsoft.com/whdc/devtools/tools/sdv-case.mspx" mce_href="http://www.microsoft.com/whdc/devtools/tools/sdv-case.mspx"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3 face=Calibri&gt;This article &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;from 2006 talks about our team using Static Driver Verifier (SDV) to find bugs in WDK Samples before the kit was published and get them addressed by the teams that owned the code.&amp;nbsp; That effort translates into savings for any vendor using this code for their own devices, as they don’t have a potentially very difficult bug to track down before (or after!) the release of their product.&amp;nbsp; That further benefits the end consumer in terms of stability of the OS and devices that using that sample code.&amp;nbsp; This thought process serves as the mission statement for the PFD/SDV Clean initiative.&amp;nbsp; Our goal was to establish a “quality bar” for headers and samples in the Win7 WDK, and further extend this bar to the Microsoft authored drivers that ship inbox with Windows 7.&amp;nbsp; The remainder of this and next few blog posts details the work our team did to make this effort successful.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;PFD Clean (Annotating Headers):&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3 face=Calibri&gt;Those of you familiar with PFD know that it is (basically) a function-level code checker that relies upon annotations for accuracy. &amp;nbsp;It was first included as a tool in the 2003 SP1 DDK, and I am of the opinion that it remained relatively anonymous to most of the developers using those kits.&amp;nbsp; The addition of &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/dd445214.aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd445214.aspx"&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3 face=Calibri&gt;OACR &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;to the WDK build environments changes all of that.&amp;nbsp; OACR, which stands for “&lt;I&gt;Microsoft &lt;/I&gt;Auto Code Review”, is a tool that resides in the background once a build environment is opened.&amp;nbsp; Once code is compiled, it uses idle time to scan that compiled code using the various code review plug-ins, one of which happens to be PREfast for Drivers (PFD).&amp;nbsp; Once OACR finishes scanning, it throws a pop-up box in the corner to show you any issues it considers warnings (bad) or errors (worse) with your recent compile.&amp;nbsp; This occurs with &lt;I&gt;any&lt;/I&gt; build command&lt;B&gt;&lt;I&gt; &lt;/I&gt;&lt;/B&gt;in the standard WDK environments, no special commands or switches required:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&lt;IMG style="WIDTH: 446px; HEIGHT: 146px" title="OACR Popup" alt="OACR Popup" align=left src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9739897/original.aspx" width=446 height=146 mce_src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9739897/original.aspx"&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-no-proof: yes"&gt;&lt;?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /&gt;&lt;v:shapetype id=_x0000_t75 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt;&lt;/v:path&gt;&lt;o:lock v:ext="edit" aspectratio="t"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;v:shape style="WIDTH: 331.5pt; HEIGHT: 106.5pt; VISIBILITY: visible" id=_x0000_i1025 type="#_x0000_t75"&gt;&lt;v:imagedata mce_href="cid:image001.png@01C9E9C0.21E04BB0" mce_src="file:///C:\Users\mfourre\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png" src="file:///C:\Users\mfourre\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png" o:href="cid:image001.png@01C9E9C0.21E04BB0"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This addition meant scanning “for free” for everyone that uses the Win7 WDK.&amp;nbsp; It also meant that if we wanted developers to consider those warnings and errors as anything more than a nuisance, we needed to make sure the code checker was as accurate as possible.&amp;nbsp; Thus began phase 1 of the “PFD Clean” initiative, annotation of public driver APIs.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The RC version of the WDK includes 254 files in the inc\ddk folder, and 48 in the inc\wdf\* folders (Windows Driver Framework).&amp;nbsp; A number of these header files are compilations of smaller headers located in different places of the Windows source, because they are a group of API that are used for a single purpose – wdm.h, for example.&amp;nbsp; This means that multiple developers create the content that ultimately ends up in wdm.h, and each individual one gets a “work item” to add annotation to the APIs that they own.&amp;nbsp; In all, to cover the files in the kit that were thought to relate in some way to a driver (which includes some in inc\api as well), nearly 600 work items were filed asking for review and changes to the header files that are published into the WDK – one for each header file.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Quick sidebar:&amp;nbsp; It became evident very quickly that asking developers to add annotation to their code would yield far better results than our local team reviewing and annotating their code:&amp;nbsp;&amp;nbsp; the ramp-up time on the annotation language was far less than any ramp-up time needed to become familiar and comfortable with the code to be annotated. &amp;nbsp;The additional benefit of the developers gaining knowledge of this valuable technology was not ignored in making this decision, either.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The overall response to this task was fantastic – every header file that even remotely relates to drivers was reviewed and annotated appropriately (where/when needed).&amp;nbsp; Combined with OACR in the build environment, this creates immediate impact for any vendor that will use the Win7 WDK to build their driver.&amp;nbsp; &amp;nbsp;&amp;nbsp;If their code is calling one of these API in a manner that it shouldn’t be called in, the OACR pop-up says so.&amp;nbsp; In the next post (part 2 of the “Clean” series), I’ll provide an example of how these annotations and OACR combine to catch a potentially painful bug in the next post.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9739886" width="1" height="1"&gt;</description></item><item><title>Static Analysis for Drivers Best Practices: Declare Entry Points of Your Driver Through Role Types – This Will Prepare It for Static Driver Verifier</title><link>http://blogs.msdn.com/staticdrivertools/archive/2009/05/11/static-analysis-for-drivers-best-practices-declare-entry-points-of-your-driver-through-role-types-this-will-prepare-it-for-static-driver-verifier.aspx</link><pubDate>Mon, 11 May 2009 20:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9603764</guid><dc:creator>Andrew Mikesell</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/staticdrivertools/comments/9603764.aspx</comments><wfw:commentRss>http://blogs.msdn.com/staticdrivertools/commentrss.aspx?PostID=9603764</wfw:commentRss><description>&lt;P&gt;
&lt;META name=ProgId content=Word.Document&gt;
&lt;META name=Generator content="Microsoft Word 12"&gt;
&lt;META name=Originator content="Microsoft Word 12"&gt;&lt;LINK rel=File-List href="file:///D:%5CUsers%5Camikesel%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" mce_href="file:///D:%5CUsers%5Camikesel%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"&gt;&lt;LINK rel=themeData href="file:///D:%5CUsers%5Camikesel%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" mce_href="file:///D:%5CUsers%5Camikesel%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"&gt;&lt;LINK rel=colorSchemeMapping href="file:///D:%5CUsers%5Camikesel%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" mce_href="file:///D:%5CUsers%5Camikesel%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"&gt;
&lt;STYLE&gt;
&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;
	mso-font-charset:2;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;
	mso-font-charset:1;
	mso-generic-font-family:roman;
	mso-font-format:other;
	mso-font-pitch:variable;
	mso-font-signature:0 0 0 0 0 0;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:-520092929 1073786111 9 0 415 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-parent:"";
	margin-top:0in;
	margin-right:0in;
	margin-bottom:10.0pt;
	margin-left:0in;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	mso-themecolor:hyperlink;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-noshow:yes;
	mso-style-priority:99;
	color:purple;
	mso-themecolor:followedhyperlink;
	text-decoration:underline;
	text-underline:single;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	mso-style-unhide:no;
	mso-style-qformat:yes;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:10.0pt;
	margin-left:.5in;
	mso-add-space:auto;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
	{mso-style-priority:34;
	mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-type:export-only;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:.5in;
	margin-bottom:.0001pt;
	mso-add-space:auto;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
	{mso-style-priority:34;
	mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-type:export-only;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:.5in;
	margin-bottom:.0001pt;
	mso-add-space:auto;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
	{mso-style-priority:34;
	mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-type:export-only;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:10.0pt;
	margin-left:.5in;
	mso-add-space:auto;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-default-props:yes;
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:Calibri;
	mso-fareast-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
.MsoPapDefault
	{mso-style-type:export-only;
	margin-bottom:10.0pt;
	line-height:115%;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{mso-list-id:278875715;
	mso-list-type:hybrid;
	mso-list-template-ids:956844300 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
	{mso-level-number-format:bullet;
	mso-level-text:;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Symbol;}
@list l0:level2
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--&gt;
&lt;/STYLE&gt;
&lt;B&gt;Overview&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt; &lt;/P&gt;&lt;B&gt;&lt;/B&gt;
&lt;P class=MsoNormal&gt;The Windows Driver Kit gives you access to static analysis tools: PREfast for Drivers (PFD) and Static Driver Verifier (SDV).&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The purpose of this article is to explain how to use PFD to validate that your driver correctly declares entry points through &lt;I&gt;role types&lt;/I&gt;. This is necessary to make SDV effective in finding bugs.&lt;/P&gt;
&lt;P class=MsoNormal&gt;Role types are function typedefs for driver entry points.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;They are a way of standardizing function prototypes, which is required by the WDK and MSDN.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Role types act as documentation by describing the intended role of a driver entry point routine (or callback function) and the routine’s return value and parameter types.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Best of all, role types enable Static Driver Verifier which can discover complex inter-procedural bugs causing blue screens and system hangs.&lt;/P&gt;
&lt;P class=MsoNormal&gt;As part of your regular driver development process, you should use both PFD and SDV.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;We recommend that you run PFD first and address warnings about missing role types, and then run SDV.&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;B&gt;PREfast for Drivers (PFD)&lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;PREfast for Drivers will generate warnings regarding any missing role types, among other issues.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;PFD runs quickly, and adding role types is fast and easy.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;At the 2008 Microsoft Windows Driver Developer Conference, I worked with a customer who was brand new to the concept of SDV role types but wanted to run SDV on his driver.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;We added all of the necessary role types and got a complete run of SDV on his driver in under an hour.&lt;/P&gt;
&lt;P class=MsoNormal&gt;PFD will generate a list of warnings, including which role types are missing.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The warnings regarding missing role types for a WDM driver include:&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="FONT-FAMILY: Symbol"&gt;&lt;SPAN&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Warning 28101: This warning specifies that PFD has detected the driver’s DriverEntry routine.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Declare this routine with the DRIVER_INITIALIZE role type.&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: Symbol"&gt;&lt;SPAN&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Warning 28155: This warning specifies that a driver routine was not declared with the correct role type.&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN-LEFT: 1in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;o&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Declare &lt;I&gt;driver unload&lt;/I&gt; routines with the DRIVER_UNLOAD role type&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN-LEFT: 1in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;o&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Declare &lt;I&gt;I/O completion routines&lt;/I&gt; with IO_COMPLETION_ROUTINE role type&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN-LEFT: 1in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;o&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Declare &lt;I&gt;add device&lt;/I&gt; routines with the DRIVER_ADD_DEVICE role type&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN-LEFT: 1in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;o&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Declare &lt;I&gt;dispatch routines&lt;/I&gt; with the DRIVER_DISPATCH role type in conjunction with the __drv_dispatchType annotation&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN-LEFT: 1in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;o&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Declare &lt;I&gt;interrupt service routines&lt;/I&gt; with the KSERVICE_ROUTINE role type &lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN-LEFT: 1in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;o&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Declare &lt;I&gt;DPC for ISR routines&lt;/I&gt; with the IO_DPC_ROUTINE role type&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN-LEFT: 1in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;o&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;For other applicable role types, visit the WDK or MSDN role type documentation&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: Symbol"&gt;&lt;SPAN&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Warning 28169:&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;This warning specifies that the driver is missing a __drv_dispatchType annotation on a dispatch routine.&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN-LEFT: 1in" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN&gt;o&lt;SPAN style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Add the __drv_dispatchType annotation to the specified dispatch routine.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;This annotation must be combined with the DRIVER_DISPATCH role type&lt;/P&gt;
&lt;P class=MsoNormal&gt;For example, if the driver header file contains a declaration for the dispatch routine which handles PnP IRPs like this:&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 0.5in" class=MsoNormal&gt;&lt;SPAN&gt;NTSTATUS&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;Driver&lt;/SPAN&gt;&lt;SPAN&gt;DispatchPnP(&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IN&amp;nbsp;PDEVICE_OBJECT&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;DeviceObject&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IN&amp;nbsp;PIRP&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Irp&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;After adding the appropriate annotations, the dispatch routine declaration will look like this:&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 0.5in" class=MsoNormal&gt;__drv_dispatchType(IRP_MJ_PNP)&lt;BR&gt;DRIVER_DISPATCH&amp;nbsp;DriverDispatchPnP;&lt;/P&gt;
&lt;P class=MsoNormal&gt;The process for adding role types for KMDF and NDIS drivers is similar.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In addition to running PFD to discover missing role types, use the WDK or MSDN documentation regarding role types to make sure the driver contains all of the required role types.&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;B&gt;Static Driver Verifier (SDV)&lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;SDV calls the entry points in the driver and attempts to find a valid code path which results in a system hang or bug check.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In order for SDV to recognize your driver’s entry points, you must declare them using role types as described above.&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;B&gt;SDV assumes that no errors of the NULL pointer dereference type are generated when your driver is scanned with PFD.&lt;/B&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In other words, it is recommended that you run SDV on your driver after the driver is PFD clean with respect to NULL pointer dereferences.&lt;/P&gt;
&lt;P class=MsoNormal&gt;To run SDV, open a WDK build environment window and go to the directory which contains the sources file for your driver.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Then run these two commands:&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 0.5in" class=MsoNormal&gt;staticdv /clean&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 0.5in" class=MsoNormal&gt;staticdv /rule=*&lt;/P&gt;
&lt;P class=MsoNormal&gt;The latter command will run all SDV checks on the driver.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;SDV can also run with a single rule or a list of rules as specified in a configuration file which you create (config.sdv).&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;For a list of possible rules, run:&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 0.5in" class=MsoNormal&gt;staticdv /showrules&lt;/P&gt;
&lt;P class=MsoNormal&gt;When SDV has completed, view the results by running:&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 0.5in" class=MsoNormal&gt;staticdv /view &lt;BR&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;For more information about using PFD to add role types in your driver, visit &lt;B&gt;&lt;A href="http://blogs.msdn.com/staticdrivertools/archive/2009/05/07/make-static-driver-verifier-more-efficient-add-a-preset-filter-to-pfd-oacr-defect-viewer.aspx" mce_href="http://blogs.msdn.com/staticdrivertools/archive/2009/05/07/make-static-driver-verifier-more-efficient-add-a-preset-filter-to-pfd-oacr-defect-viewer.aspx"&gt;Make Static Driver Verifier More Efficient: Add a Preset Filter to PFD/OACR Defect Viewer&lt;/A&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;For questions regarding SDV and PFD, please send email to &lt;A href="mailto:sdvpfdex@microsoft.com" mce_href="mailto:sdvpfdex@microsoft.com"&gt;sdvpfdex@microsoft.com&lt;/A&gt;.&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9603764" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/Static+Driver+Tools+PREfast+for+Drivers+PFD+SDV+WDK+Testing/default.aspx">Static Driver Tools PREfast for Drivers PFD SDV WDK Testing</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/PREfast/default.aspx">PREfast</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/quality/default.aspx">quality</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/annotations/default.aspx">annotations</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/drivers/default.aspx">drivers</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/PFD/default.aspx">PFD</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/Annotations+PFD/default.aspx">Annotations PFD</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/sdv+pfd+static+driver+verifier+prefast+for+drivers+filters+preset/default.aspx">sdv pfd static driver verifier prefast for drivers filters preset</category></item><item><title>Make Static Driver Verifier More Efficient: Add a Preset Filter to PFD/OACR Defect Viewer</title><link>http://blogs.msdn.com/staticdrivertools/archive/2009/05/07/make-static-driver-verifier-more-efficient-add-a-preset-filter-to-pfd-oacr-defect-viewer.aspx</link><pubDate>Thu, 07 May 2009 22:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9594595</guid><dc:creator>Michael Fourre</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/staticdrivertools/comments/9594595.aspx</comments><wfw:commentRss>http://blogs.msdn.com/staticdrivertools/commentrss.aspx?PostID=9594595</wfw:commentRss><description>&lt;FONT size=3 face=Calibri&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;The Static Driver Tools team ships two products in the WDK, PREfast for Drivers, and Static Driver Verifier (SDV).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;As such, we have a lot of interaction between the products and have emphasized using the light-weight tool (PFD) to help with some of best-practice work that should be done to maximize the effectiveness of SDV.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When PFD checks a driver, it checks rules related to this best-practice work and if found, they’re listed under warning numbers 6001, 6011, 28101, 28155, 28169, 28177, and 28182.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;A post on specifically that kind of work will shortly follow this entry, which provides specific details about the most important warnings in that list; the purpose of this post is to provide you with a means of keeping that warning set available at your finger-tips.&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;The defect viewer included with both standalone PREfast for Drivers (PFD) tool and the OACR tool include a small number of “preset filters” that will limit the number of defects displayed to the developer when viewing their results.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;While both of the viewers will maintain settings for a custom list between sessions (if, for example, you had limited your list to the above 7&amp;nbsp;warnings), it certainly is useful to have the ability to add your own preset filter that works best with your project.&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;The following steps can add a Preset filter to either the standalone PFD viewer or the OACR viewer, whichever is your preference.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The preset filter can also be used with standalone PFD during the build process to limit the number of defects it looks for:&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;(Note: The environment variable PUBLIC_ROOT refers to the root of the WDK Build Environment that is currently being operated in.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;In all three cases, you’re going to add the following bit of XML to the filters.xml file associated with the viewer you’re running.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In each case, I have added this as the last “preset”, appearing after “wspmin” in that file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;o:p&gt;&amp;nbsp;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&amp;lt;preset name="&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-font-size: 11.0pt"&gt;Static Driver Verifier Prerequisites&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;" invert="1"&amp;gt;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;excludeWarnings&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; 6001;6011;28101;28155;28169;28177;28182&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;/excludeWarnings&amp;gt;&lt;BR&gt;&amp;lt;excludeRegExps&amp;gt;pft;NTPub;VC6;MFC;ATL;LKRH;MIDL;INC&amp;lt;/excludeRegExps&amp;gt;&lt;BR&gt;&amp;lt;/preset&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-size: 10.0pt"&gt;To add this preset filter to the PFD Viewer, add the above XML chunk to: &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;%PUBLIC_ROOT%\tools\pfd\scripts\DefectUI\filters.xml.&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-size: 10.0pt"&gt;To add this preset filter to the x86 OACR Build Environments, add the above XML chunk to: &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;%PUBLIC_ROOT%\bin\x86\OACR\viewer\scripts\defectui\filters.xml&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-size: 10.0pt"&gt;To add this preset filter to the amd64 OACR Build Environments, add the above XML chunk to: &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;%PUBLIC_ROOT%\bin\amd64\OACR\viewer\scripts\defectui\filters.xml&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;Once those steps are completed, the defect&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;viewer that you use will have a new drop-down appear in the Preset Filters called “Static Driver Verifier Prerequisites” for both the x86 and amd64 build environments:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;o:p&gt;&lt;IMG style="WIDTH: 425px; HEIGHT: 298px" title="PFD Viewer with new Preset" alt="PFD Viewer with new Preset" src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9594709/425x298.aspx" width=425 height=298 mce_src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9594709/425x298.aspx"&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: black; FONT-SIZE: 10pt; mso-themecolor: text1"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-no-proof: yes; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /&gt;&lt;v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"&gt;&lt;/v:path&gt;&lt;o:lock aspectratio="t" v:ext="edit"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black; mso-themecolor: text1; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-bidi-font-family: Calibri"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;If that snippet is added to all three instances of filters.xml, it will be available in any of those scenarios where you are reviewing defects.&amp;nbsp; It is worth mentioning, however, that standalone PFD provides two advantages over relying on OACR:&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;1. Warnings 6001 and 6011&amp;nbsp;are enabled by default in standalone PFD.&amp;nbsp; Catching (and clearing!) the issues concerning uninitialized variables (6001) and null dereferences (6011) before scanning your driver with Static Driver Verifier is a very good thing to do:&amp;nbsp;&amp;nbsp;either&amp;nbsp;has a chance of confusing the SDV engine.&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;2. The new preset filter can be applied while building the driver, limiting what the scanner looks for and reports on.&amp;nbsp; Use the following command line to do so (assuming you named the preset "Static Driver Verifier Prerequisites"), the example beneath shows the output on the sample "fail_driver1" that ships with PFD:&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-font-size: 11.0pt"&gt;Prefast /filter /filterpreset=”Static Driver Verifier Prerequisites” build –cZ&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;IMG style="WIDTH: 694px; HEIGHT: 450px" title="Demo of using the filterpreset with standalone PFD" alt="Demo of using the filterpreset with standalone PFD" src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9594762/425x282.aspx" width=425 height=282 mce_src="http://blogs.msdn.com/photos/static_driver_tools_gallery/images/9594762/425x282.aspx"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal mce_keep="true"&gt;&lt;o:p&gt;(UPDATE Note:&amp;nbsp; Included warning 6001 in the list.)&lt;/o:p&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9594595" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/sdv+pfd+static+driver+verifier+prefast+for+drivers+filters+preset/default.aspx">sdv pfd static driver verifier prefast for drivers filters preset</category></item><item><title>Annotating for __success()</title><link>http://blogs.msdn.com/staticdrivertools/archive/2008/11/06/annotating-for-success.aspx</link><pubDate>Thu, 06 Nov 2008 21:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9050125</guid><dc:creator>Michael Fourre</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/staticdrivertools/comments/9050125.aspx</comments><wfw:commentRss>http://blogs.msdn.com/staticdrivertools/commentrss.aspx?PostID=9050125</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;__success() is an annotation that hs been around for "a little while", but isn't widely known about.&amp;nbsp; Admittedly,&amp;nbsp;finding content about&amp;nbsp;it on MSDN is difficult - that should change as we approach&amp;nbsp;the release of Windows 7.&amp;nbsp;&amp;nbsp;&amp;nbsp;Upon release, &lt;/FONT&gt;&lt;FONT size=3 face=Calibri&gt;exposure to the __success() annotation is going to become very common with the release of the Windows 7 WDK: any function that returns NTSTATUS (read: a large majority of Kernel functions we publish in the WDK) will have the __success() annotation appended to it:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;typedef __success(return &amp;gt;= 0) long NTSTATUS;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The annotation carries a dual meaning:&amp;nbsp; to the developer, it is an easy reminder of the return value (or set of return values) that indicate the function was successful.&amp;nbsp; Most NTSTATUS functions return 0 to indicate success, the greater-than or equal sign is present because a select few will return some positive number besides zero to indicate success.&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT size=3 face=Calibri&gt;The scanning engine expands on that feeling by assuming that&amp;nbsp; functions annotated with the __success() annotation will only fulfill their contract when returning a value that is considered to be “success”.&amp;nbsp; The following declaration will help demonstrate this meaning:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;typedef&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;__success(return &amp;gt;= 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;__drv_acquiresGlobalResource(SomeResource)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;long&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;AcqResource (__out int *x);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;When the scanner is processing a function that calls AcqResource, it will assume that &lt;I&gt;SomeResource&lt;/I&gt; is acquired only when the function returns a success status.&amp;nbsp; This follows the a typical coding convention of only doing as the function says when the function is successful; the annotation is a strict reinforcement of that principle.&amp;nbsp; When the __success() annotation is &lt;B&gt;not&lt;/B&gt; included, the scanner will&lt;B&gt; always&lt;/B&gt; assume that the resource is acquired.&amp;nbsp; There is one caveat to keep in mind:&amp;nbsp; if x was not&lt;B&gt; &lt;/B&gt;initialized before this call, the __out annotation stipulates that it will be initialized after this call, &lt;B&gt;successful or not.&amp;nbsp; &lt;/B&gt;When dealing with the fail case, it is common that a fail status from the function means the failure to acquire the resource.&amp;nbsp; &lt;B&gt;&amp;nbsp;&amp;nbsp;&lt;/B&gt;Whether or not the parameter is initialized post-call is a scenario of great debate, so the scanner assumes it was somehow initialized.&amp;nbsp;&amp;nbsp; The best way to deal with this confusion?&amp;nbsp; Initialize the variable when you declare it, always a good idea in practice anyway.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Suppose, however, you have another function where you wish to express that an __out parameter would be returned to the caller as NULL in the case where the function failed.&amp;nbsp; The annotation __on_failure() exists for this reason, to be explained following this example:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;typedef&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;__success (return &amp;gt;= 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;__drv_acquiresGlobalResource(SomeResource)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;long&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;AcqResourceAndX( __out __on_failure(__null) int* x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The __on_failure(__null) annotation states that on function exit, when the return value is less than 0 (__on_failure), assume that the value of x (the address at which the value accessed by *x is found) is null.&amp;nbsp; &amp;nbsp;&amp;nbsp;You may find that within your own coding style, __out parameters are always null or otherwise invalid in a fail case, and wonder why the scanner cannot go figure that out for itself.&amp;nbsp; Remember that the PFD scanner only deals with a function at a time, and has to rely solely on the annotations for information concerning a call within that function.&amp;nbsp; So while you may have code that obviously would set x to null on the failure instance, PFD will not know that unless you tell it specifically.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9050125" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/Annotations+PFD/default.aspx">Annotations PFD</category></item><item><title>PFD Annotations - They're just comments, really.</title><link>http://blogs.msdn.com/staticdrivertools/archive/2008/09/10/pfd-annotations-they-re-just-comments-really.aspx</link><pubDate>Wed, 10 Sep 2008 03:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8938351</guid><dc:creator>Michael Fourre</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/staticdrivertools/comments/8938351.aspx</comments><wfw:commentRss>http://blogs.msdn.com/staticdrivertools/commentrss.aspx?PostID=8938351</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;As someone that has done development work, I know the joy experiecned when asked to better comment my own code after I’ve completed it.&amp;nbsp; It works, I know what it does, and I would rather work on a different feature than go back and change something I’ve already completed.&amp;nbsp; It doesn’t feel like progress; it feels like regress until I can clear all of that other work out.&amp;nbsp; I have these feelings knowing full well that comments are incredibly beneficial, and knowing that for as much as I have thought my own code to be clear and concise without the comments, revisiting the code even just a few months later requires time to become reacquainted with it when those comments aren’t there.&amp;nbsp; The case for commenting has been drilled into every aspiring Dev’s head somewhere along the way, so restating it beyond what I’ve already said isn’t necessary.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Both PFD and SDV make use of SAL (standard source code annotation language) annotations in the code to assist with their checking engines.&amp;nbsp; Both will use these to determine the correct usage of a function, and to warn the developer against things that will cause potential troubleshooting pain later on.&amp;nbsp; SAL annotations have been in place in some form for while – the easily recognizable “IN”, “OUT”, and “OPTIONAL” annotations are found in abundance in the current Windows 2008 WDK.&amp;nbsp; &amp;nbsp;When code compiles, these resolve out to nothing, they’re simply in-code comments that help the developer get&amp;nbsp; a quick idea of what a particular parameter is used for.&amp;nbsp; The annotations for PFD and SDV take this to another level in both code readability and usability of these tools.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Take an example of a function, defined in wdm.h in the Windows 2008 WDK, that seems reasonably easy to determine what it does, based on it’s name:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;NTKERNELAPI&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;NTSTATUS&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;NTAPI&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;KeSaveFloatingPointState (&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OUT PKFLOATING_SAVE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FloatSave&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This function is to be used whenever floating point arithmetic of any sort is to happen in Kernel code.&amp;nbsp; Calling this before doing any sort of operation relieves you of the possibility of nasty little issues that can occur with the floating point&amp;nbsp; registers if you’re switched out while executing your codepath.&amp;nbsp; Based on what is seen above, we know it’s a Kernel API, it returns NTSTATUS and a structre we will use when we need to call KeRestoreFloatingPointState to restore it.&amp;nbsp; &amp;nbsp;Neither wdm.h or fltsafe.h (where the FLOATSAFE struct is defined) provides any other real hint as to concerns we should have for this function call.&amp;nbsp; A trip to the MSDN page for KeSaveFloatingPointState is necessary to tell me that it’s okay to call this at &amp;lt;=DISPATCH_LEVEL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Consider the information provided when appropriate PFD annotations are added:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;__checkReturn&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;__drv_maxIRQL(DISPATCH_LEVEL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;__drv_valueIs(&amp;lt;0;==0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;__drv_when(return==0, __drv_floatSaved)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;__forceinline&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;NTSTATUS&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;KeSaveFloatingPointState (&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __out __deref __drv_neverHold(FloatState)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __drv_when(return==0, __deref __drv_acquiresResource(FloatState))&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PVOID FloatingState&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Based on this information, I now know, without a trip to my browser and MSDN:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: #4f6228; mso-fareast-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3 face=Calibri&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;It is not safe to assume this function is always successful. &amp;nbsp;While the fact that it returns a value of any sort should cement this belief anyway, the annotation “__checkReturn” acts as the concrete.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: #4f6228; mso-fareast-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3 face=Calibri&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The maximum IRQL level that this function can be called at is DISPATCH_LEVEL, so it’s safe to call from a DPC, but not my ISR; and should relieve me of the worry of paged code when calling it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: #4f6228; mso-fareast-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3 face=Calibri&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The value returned is either less than 0 or 0.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: #4f6228; mso-fareast-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3 face=Calibri&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;When the value returned is zero, the floating point state is saved.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The parameters themselves also hold annotations, which admittedly take a bit more getting used to than looking past simple “IN” or “OUT” annotations. &amp;nbsp;The annotations applied to FloatingState translate out to:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: #4f6228; mso-fareast-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3 face=Calibri&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;When this function returns STATUS_SUCCESS, it acquires the resource that we’ll call ‘FloatState’.&amp;nbsp; With that in mind, the ‘FloatState’ resource should never be held when calling this function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: #4f6228; mso-fareast-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3 face=Calibri&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The __deref is part of properly pointing to the resource that the FloatingState pointer is pointing to.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="COLOR: #4f6228; mso-fareast-font-family: Calibri"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3 face=Calibri&gt;-&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The __out annotation is self-explainatory:&amp;nbsp; we’re expecting this function to provide us with something useful to point to with that parameter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;For informational purposes only, those annotations realized the same effect as a simple comment placed before the function defination would have.&amp;nbsp; Review of the SAL annotations leaves a developer with a far better idea of what an API is capable of, regardless of any documentation they may have found on the subject.&amp;nbsp; &amp;nbsp;For example, the annotation makes it apparent that holding the FloatState and attempting to save it again is not a good idea; the MSDN write-up doesn’t mention this.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Annotations can range from very complex and situational down to “duh” for any programmer.&amp;nbsp; Checking the return value of a function is generally a good idea, but you can not do so and nothing in the compiler will stop you.&amp;nbsp; You can also try to drink coffee in large gulps the instant the Barista hands it to you, too, but that doesn’t mean it’s a good idea.&amp;nbsp; It’s why coffee cups have “CAUTION: HOT” written on them these days, and why an annotation like “__checkReturn” exists.&amp;nbsp; They’re safety measures, and help you keep yourself from getting hurt if you follow them, no matter how trivial they may be.&amp;nbsp; The __checkReturn annotation creates a warning for anyone that decides to ignore the status, and much like “CAUTION:HOT”, they can continue to do so possibly at their own peril - I’ve seen a number of crashes simply because a status was ignored.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Whether they’re to be considered fancy comments or warning signs, the benefits of these annotations especially when paired with PFD result in APIs used in their intended manner and less crashes on the user desktop. &amp;nbsp;Problems that can create crashes are brought to the developer’s attention during development, not when users of the beta are clamoring for a fix – or even worse, after release. &amp;nbsp;Application of these annotations for a developer familiar with their DDI is minimal, the savings potentially incredible.&amp;nbsp; As a developer, if applying these means finding a bug in my code before releasing it, the time invested in application has paid for itself already – for basically nothing more than providing information that I should be putting in comments anyway.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: #4f6228"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8938351" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/quality/default.aspx">quality</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/annotations/default.aspx">annotations</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/drivers/default.aspx">drivers</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/PFD/default.aspx">PFD</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/comments/default.aspx">comments</category></item><item><title>PREfast for Drivers and IRQL Levels</title><link>http://blogs.msdn.com/staticdrivertools/archive/2008/05/06/prefast-for-drivers-and-irql-levels.aspx</link><pubDate>Tue, 06 May 2008 04:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8461883</guid><dc:creator>Jon Hagen</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/staticdrivertools/comments/8461883.aspx</comments><wfw:commentRss>http://blogs.msdn.com/staticdrivertools/commentrss.aspx?PostID=8461883</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;IRQL levels can sometimes be a tricky thing to get right, especially if you’re new to drivers and coming from user mode.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Playing with IRQL levels, memory, structures… Mix them the wrong way and you bugcheck the box. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;What can really be painful is the process of inheriting code and having to figure out what’s going on.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Did the developer want this to come in at DISPATCH_LEVEL?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;With all the complexities of writing drivers using driver annotations is almost a necessity.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR style="mso-special-character: line-break"&gt;&lt;BR style="mso-special-character: line-break"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Let’s take this example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt" cellSpacing=0 cellPadding=0 border=1 class="MsoTableGrid"&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;TD class="" style="BORDER-RIGHT: black 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: black 1pt solid; WIDTH: 6.65in; PADDING-TOP: 0in; BORDER-BOTTOM: black 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=638&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: #660000; FONT-FAMILY: 'Courier New'"&gt;NTSTATUS&lt;BR&gt;ResetDevice(&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;B&gt;__in&lt;/B&gt;&amp;nbsp;WDFDEVICE&amp;nbsp;Device&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Off the top of your head without looking at the documentation you may or may not be able to determine what the IRQL level should be when you call this.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Now can you be sure from all the different points in your code where this is called that you are at the correct IRQL?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Now let’s add one line of driver annotation to the same prototype:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt" cellSpacing=0 cellPadding=0 border=1 class="MsoTableGrid"&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;TD class="" style="BORDER-RIGHT: black 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: black 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: black 1pt solid; WIDTH: 6.65in; PADDING-TOP: 0in; BORDER-BOTTOM: black 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid black .5pt; mso-border-themecolor: text1" vAlign=top width=638&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: #660000; FONT-FAMILY: 'Courier New'"&gt;__drv_requiresIRQL&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: #660000; FONT-FAMILY: 'Courier New'"&gt;(PASSIVE_LEVEL)&lt;BR&gt;NTSTATUS&lt;BR&gt;ResetDevice(&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;B&gt;__in&lt;/B&gt;&amp;nbsp;WDFDEVICE&amp;nbsp;Device&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;You can see the obvious benefit in the code of the documentation.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;I could give this to my 9 yr old nephew and ask him what IRQL level this DDI requires.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Here’s the other benefit: You can actually use PFD to check if this is valid in different areas of your code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Any place this is called PFD can detect it from one of two ways.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Annotation inference from another DDI call that either requires a certain IRQL level or raises/lowers the IRQL level.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Looking at another DDI it can infer that the logic between the two DDI’s doesn’t make sense.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(DDI-1 requires PASSIVE_LEVEL while DDI-2 four lines down requires APC_LEVEL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;It allows someone anyone who may have inherited the code to immediately understand the contract requirements and constraints on the DDI.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Obviously, the code above has been shrunk down for simplicity, but you can see how this would be beneficial for a more complicated DDI.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This is something very easy that you can add to your code that will help with code portability and maintenance. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;If you’re all excited to jump into the next set of annotations you can feel free to read up more here:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/cc264089.aspx"&gt;&lt;FONT face=Calibri color=#0000ff size=3&gt;http://msdn2.microsoft.com/en-us/library/cc264089.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8461883" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/PREfast/default.aspx">PREfast</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/IRQL/default.aspx">IRQL</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/quality/default.aspx">quality</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/annotations/default.aspx">annotations</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/drivers/default.aspx">drivers</category><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/PFD/default.aspx">PFD</category></item><item><title>Welcome to the Static Driver Tools Blog!</title><link>http://blogs.msdn.com/staticdrivertools/archive/2008/04/10/welcome-to-the-static-driver-tools-blog.aspx</link><pubDate>Thu, 10 Apr 2008 02:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8373614</guid><dc:creator>Jon Hagen</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/staticdrivertools/comments/8373614.aspx</comments><wfw:commentRss>http://blogs.msdn.com/staticdrivertools/commentrss.aspx?PostID=8373614</wfw:commentRss><description>&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt; 
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Welcome to the Static Driver Tools blog!&amp;nbsp; This is a blog that was created by our team to inform the driver development community of upcoming features and changes to Static Driver Verifier&lt;SPAN style="COLOR: black"&gt; (SDV)&lt;/SPAN&gt; and PREfast for Drivers&lt;SPAN style="COLOR: black"&gt; (PFD)&lt;/SPAN&gt;.&amp;nbsp; &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;BR&gt;If you’re not familiar with the tools you can read more &lt;SPAN style="COLOR: black"&gt;about &lt;/SPAN&gt;each tool here:&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;PREfast for Drivers:&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.microsoft.com/whdc/devtools/tools/PREfast.mspx" mce_href="http://www.microsoft.com/whdc/devtools/tools/PREfast.mspx"&gt;http://www.microsoft.com/whdc/devtools/tools/PREfast.mspx&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Static Driver Verifier:&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.microsoft.com/whdc/devtools/tools/sdv.mspx" mce_href="http://www.microsoft.com/whdc/devtools/tools/sdv.mspx"&gt;http://www.microsoft.com/whdc/devtools/tools/sdv.mspx&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;We’re looking forward to helping out with the tools, investigating bug traces, or just talking about developing, debugging, and testing drivers.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8373614" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/staticdrivertools/archive/tags/Static+Driver+Tools+PREfast+for+Drivers+PFD+SDV+WDK+Testing/default.aspx">Static Driver Tools PREfast for Drivers PFD SDV WDK Testing</category></item></channel></rss>