Analyzing a Driver Using Code Analysis and Verification Tools
Code analysis and verification tools can help improve the stability and reliability of your driver by systematically analyzing the source code. The code analysis and verification tools can detect errors that are missed by the compiler and by conventional runtime testing. Additionally they can determine whether the driver correctly interacts with the Windows operating system kernel. Using Microsoft Visual Studio Ultimate 2012 and the Windows Driver Kit (WDK), you can configure the code analysis and verification tools to run as part of the build process, or you can schedule the tools to analyze your driver at a predetermined time.
The Windows 8 release of the WDK provides enhancements to the C/C++ Code Analysis tool included with Visual Studio. Specifically, the WDK provides a specialized driver module that is designed to detect errors in kernel-mode driver code. This driver module is integrated into the C/C++ Code Analysis tool.
When to use: You can run the C/C++ Code Analysis tool for drivers very early in the development cycle, as soon as the code compiles correctly.
For information about the Code Analysis tool in Visual Studio, see:
- Analyzing Application Quality using Code Analysis
- Code Analysis for Drivers
- How to run Code Analysis for drivers
- Using SAL Annotations to Reduce C/C++ Code Defects
- SAL 2.0 Annotations for Windows Drivers
Note In previous versions of the WDK, the driver-specific module for code analysis was part of a standalone tool called PREfast for Drivers (PFD). PREfast for Drivers was also integrated into the WDK Build environment, as part of Microsoft Automated Code Review (OACR).
Static Driver Verifier (SDV) is a static verification tool that systematically analyzes the source code of Windows kernel-mode drivers. SDV determines whether the driver correctly interacts with the Windows operating system kernel. SDV can be launched from the Driver menu in Visual Studio or from the Visual Studio Command Prompt window.
When to use: Run Static Driver Verifier early in the development cycle on drivers that compile correctly. Run Static Driver Verifier before you begin the test cycle.
For information about Static Driver Verifier, see:
Note In previous versions of the WDK, Static Driver Verifier was a stand-alone tool that you launched from a WDK Build Environment window.