Share via


Selecting the Analysis Mode

Before running PREfast for Drivers (PFD), you need to select the type of analysis that it will perform.

If you are using OACR, PFD tries to determine the analysis mode from context. In cases where PFD fails to determine the analysis mode, you can use the following annotations to correct the problem.

By default, standalone PREfast for Drivers is configured to analyze kernel-mode driver code. If you are using PREfast for Drivers to analyze a different type of code, you need to add one of the following analysis macros to your source code:

  • __kernel_driver
    For kernel-mode driver code. This is the default analysis mode.

  • __kernel_code
    For non-driver kernel code.

  • __user_driver
    For user-mode driver code.

  • __user_code
    For non-driver user-mode code.

Adding an Analysis Mode Macro

The analysis macros are included in Driverspecs.h, which is included in Wdm.h and Ntddk.h. To add an analysis mode macro, type the macro immediately after the #include statement for Wdm.h, Ntddk.h, or Driverspecs.h, if that header file is explicitly included.

For example, to specify the analysis mode for user-mode driver code, use the following macro:

#include <driverspecs.h>
__user_driver;

When a driver (or utility) includes a common header file, the previous two lines of code should appear early in that header.

 

 

Send comments about this topic to Microsoft

Build date: 5/3/2011