About Code Analysis for Drivers
Code Analysis for Windows Drivers is an extension of the C/C++ Code Analysis tool included with Visual Studio. In previous versions of the WDK, the driver-specific module for code analysis was part of a standalone tool called PREfast for Drivers (PFD).
The Code Analysis for Drivers tool is a compile-time static verification tool that detects errors missed by the compiler and by conventional runtime testing. It detects common coding errors in C and C++ programs, and is designed to detect errors in kernel-mode driver code. You can run Code Analysis for Drivers very early in the development cycle—as soon as the code compiles correctly. The Code Analysis tool for Drivers supports a large vocabulary of SAL annotations beyond those supported for the C/C++ Code Analysis tool, including annotations for IRQLs, resource-object leaks, memory leaks, and stricter type checking.
Code Analysis for Drivers examines each function in the code independently, looking for common driver errors and unwise coding practices. Code Analysis for Drivers runs quickly, even on larger drivers, and generates a report that identifies the line of driver code with the suspected error.
Code Analysis for Drivers supports Windows Vista and later versions of Windows and is designed to analyze code written for x86-based and x64-based platforms. It can analyze C and C++ source files for drivers in any driver model, including managed code.
You should use Code Analysis for Drivers in conjunction with Driver Verifier, Static Driver Verifier, and the checked build of Windows to ensure that your driver code is safe and reliable.
Code Analysis for Drivers is provided in the Windows Driver Kit (WDK).
What’s New for Code Analysis for Drivers in Windows 8
- Code Analysis for Drivers (formerly known as PREfast for Drivers) is integrated into Visual Studio 2012 Professional, Premium, and Ultimate editions as part of the C/C++ Code Analysis tool. Code Analysis for Drivers is available when you install the WDK.
- Code Analysis for Drivers generates warnings that help you prepare to analyze a driver with Static Driver Verifier (SDV). SDV requires drivers to have declarations that define the role of the driver-supplied callback functions. Code Analysis for Drivers will indicate when you need to add these role type declarations to the driver code.
High Quality Drivers and WDK Samples
For Windows 8, all Microsoft drivers that ship with the operating system and all WDK samples have been verified with the Code Analysis for Drivers tool, and identified defects have been fixed. In addition, the WDK public header files are now annotated with SAL 2 annotations to enable the code analysis tools to better find code defects.
- Because SAL annotations are now in public header files, driver writers can take advantage of these checks by simply running the Code Analysis tool on their drivers. Adding additional driver-specific annotations to your driver code will give you deeper analysis.
- Windows header files provide a comprehensive set of examples of how to annotate your functions.
General C/C++ Code Analysis
- Analyzing Application Quality using Code Analysis
- Using SAL Annotations to Reduce C/C++ Code Defects
Getting Started with Code Analysis for Drivers
- Code Analysis for Drivers
- How to run Code Analysis for drivers
- SAL 2.0 Annotations for Windows Drivers
