Developing Drivers
Developing Drivers
Developing Drivers
Windows Drivers
Getting Started with Windows Drivers
DCH Design Principles and Best Practices
Driver Package Isolation
Run From Driver Store
Supporting multiple operating system versions
API Layering
Building a Windows driver
Validating Windows Drivers
DCH-Compliant Driver Package Example
Debugging a Windows Driver
Porting an INF to follow driver package isolation
Building Drivers
Creating a New Device Function Driver
Creating a New Filter Driver
Device Filter Driver Ordering
Creating a New Software Driver
Creating a New Primitive Driver
Creating a Driver From Existing Source Files
Building a Driver with the WDK
Building for OneCore
Building Drivers for Different Versions of Windows
Building Arm64 Drivers with the WDK
Using the Enterprise WDK 10
Installing the WDK 8.1 Build Environment in a Lab
Using the Microsoft C Runtime with User-Mode Drivers and Desktop Apps
Avoiding Floating Point Errors in Custom Build Environments
Counters Manifest Preprocessor Properties for Driver Projects
Driver Model Settings Properties for Driver Projects
Message Compiler Properties for Driver Projects
MOF Compiler Properties for Driver Projects
Stampinf Properties for Driver Projects
Converting WDK 8.1 Projects to WDK 10
Driver convergence model for Windows 10
Target platform on driver reference pages
Analyzing a Driver Using Code Analysis and Verification Tools
Preparing a Computer for Manual Driver Deployment
What happens when you provision a computer (WDK 8.1)
What happens when you provision a computer (WDK 8.0)
Troubleshooting Configuration of Driver Deployment, Testing and Debugging
Creating a Driver Package
Creating a Device Metadata Package
Signing Drivers
Signing a Driver
Signing a Driver During Development and Testing
Signing a Driver for Public Release
Driver Signing Properties
Deploying Drivers
Deploying a Driver to a Test Computer
Deployment Properties for Driver Package Projects
Driver Verifier Properties for Driver Package Projects
KMDF Verifier Properties for Driver Package Projects
UMDF Verifier Properties for Driver Package Projects
Inf2Cat Properties for Driver Package Projects
How to create a custom driver installation script
Installing a driver on Windows 10 Mobile
Debugging a Driver
Testing Drivers
Testing a Driver
Tips for testing drivers during development
How to test a driver at runtime using Visual Studio
How to run the HCK Test Suites in WDK 8.1
How to select and configure the Device Fundamentals tests
How to test a driver package
How to read the driver test results log
How to test a driver at runtime from a Command Prompt
How to write a driver test using a Driver Test template
How to add test metadata
Static Driver Verifier Known Issues - Windows 10 October 2018 Update (version
1809)
Logging
Creating a Driver Verification Log
Creating a log file for the code analysis tool
Creating a log file for Static Driver Verifier
Distributing a driver package
Developing, Testing, and Deploying Drivers
9/20/2022 • 2 minutes to read • Edit Online
The Windows driver development environment and the Windows debuggers are integrated into Microsoft
Visual Studio. In this integrated driver development environment, most of the tools you need for coding,
building, packaging, deploying, and testing a driver are available in the Visual Studio user interface.
To set up the integrated development environment, first install Visual Studio and then install the WDK. You can
find information about how to get Visual Studio and the WDK on the WDK setup and download page. The
Debugging Tools for Windows are included with the WDK installation.
The WDK uses MSBuild.exe, which is available both in the Visual Studio user interface and as a command-line
tool. Drivers created in the Visual Studio environment use Project and Solution files to describe a project or
group of projects. The Visual Studio environment provides a tool for converting legacy Sources and Dirs files to
Project and Solution files.
The Visual Studio environment provides templates for:
New drivers
Driver packages
New tests
Enhancement of existing tests
Custom driver deployment scripts
In the Visual Studio environment, you can configure the build process so that it automatically creates and signs a
driver package. Static and run-time analysis tools are available in Visual Studio. You can configure a target
computer for testing your driver and automatically deploy your driver to the target computer each time you
rebuild. You can choose from an extensive set of run-time tests, and you can write your own tests.
The topics in this section show you how to use Visual Studio to perform several of the tasks involved in driver
development, deployment, and testing.
Additional Videos
You'll find videos on the following pages in the Windows driver docs:
Using the Windows Performance Toolkit (WPT) with WDF
Video: Accessing driver IFR logs without a debugger
Video: Debugging your driver with WDF source code
Videos: Debugging UMDF Drivers
Getting Started with 'Windows Drivers'
9/20/2022 • 2 minutes to read • Edit Online
When you write a driver to run on the Windows operating system, you have two basic choices. You can write a
Windows Desktop driver, which only runs on Windows Desktop editions. Or, you can meet a few extra
requirements and write a Windows Driver, which runs on both Desktop and non-Desktop variants of Windows.
The Windows Driver classification extends and replaces the older Universal Driver classification.
The following additional requirements apply to Windows Drivers:
Compliant with DCH Design Principles.
Follow the principles of Driver Package Isolation.
Follow API Layering Requirements.
Certified with Windows Hardware Compatibility Program Certification Process using the Hardware Lab Kit.
WHCP Certification Process requirements apply to both KMDF and UMDF drivers.
The following table summarizes the distinctions between the two classifications:
While it's not required for a driver running only on Windows Desktop to meet the additional requirements for a
Windows Driver, doing so enhances driver serviceability and reliability, and also prepares the driver for possible
future certification on non-Desktop variants of Windows.
DCH Design Principles and Best Practices
9/20/2022 • 3 minutes to read • Edit Online
This page describes design principles and best practices for Windows Drivers.
Overview
Driver packages that are DCH-compliant contain an INF file and binaries that install and run on Universal
Windows Platform (UWP)-based editions of Windows. They also install and run on other editions of Windows
10 and 11 that share a common set of interfaces.
DCH-compliant driver binaries can use KMDF, UMDF 2, or the Windows Driver Model (WDM).
DCH-compliant drivers consist of the following parts:
A base driver
Optional component packages
An optional hardware support app
The base driver contains all the core functionality and shared code. The optional component packages can
contain customizations and additional settings.
Typically, a device manufacturer, or independent hardware vendor (IHV), writes the base driver. Then, a system
builder, or original equipment manufacturer (OEM), provides any optional component packages.
After an IHV has certified the base driver package, it can be deployed on all OEM systems. Because a base driver
package can be used across all systems that share a hardware part, Microsoft can test the base driver package
broadly via Windows Insider flighting, rather than limiting distribution to specific machines.
The OEM validates only the optional customizations that it provides for the OEM system.
Requirements
To create a driver package that follows DCH design principles, follow these steps:
Create an INF file for your driver:
1. Review the list of INF sections and directives that are valid in Windows Driver packages.
2. Use the InfVerif tool to verify that your driver package's INF file follows Declarative (D) requirements
for Windows Drivers. It should pass infverif /w .
Ensure that any optional component packages that do not contain core driver functionality are separated
from the base driver package.
Hardware support applications associated with your driver package must be distributed through the
Microsoft Store.
Best practices
If you're using the Windows Driver Kit (WDK) with the latest available Visual Studio, set the Target
Platform value in the driver project properties to Windows Driver . This automatically adds the correct
libraries, and it runs the proper INF validation and ApiValidator as a part of build. To do this:
1. Open the driver project properties.
2. Select Driver Settings .
3. Use the drop-down menu to set Target Platform to Windows Driver .
If your INF performs any custom setup actions that depend on the target platform, consider separating
them out into an extension INF. You can update an extension INF independently from the base driver
package to make it more robust and serviceable. For more information, see Using an extension INF file.
If you want to provide an application that works with your device, include a UWP app. For more
information, see Hardware Support App (HSA): Steps for driver developers. An OEM can preload such an
app by using DISM - Deployment Image Servicing and Management. Or, users can manually download
the app from the Microsoft Store.
In the INF DestinationDirs section , set the destination directories to dirid 13 to make the driver run
from the driver store. This setting won't work for some devices.
Driver package isolation
9/20/2022 • 11 minutes to read • Edit Online
Driver package isolation is a requirement for Windows Drivers that makes driver packages more resilient to
external changes, easier to update, and more straightforward to install.
NOTE
While driver package isolation is required for Windows Drivers, Windows Desktop Drivers still benefit from it through
improved resiliency and serviceability.
The following table shows some example legacy driver package practices that are no longer allowed for
Windows Drivers in the left column along with the required behavior for Windows Drivers in the right column.
INF copies files to %windir%\System32 or Driver files are run from the driver store
%windir%\System32\drivers
Interacts with device stacks/drivers using hardcoded paths Interacts with device stacks/drivers using system-supplied
functions or device interfaces
Hardcodes path to global registry locations Uses HKR and system-supplied functions for relative location
of registry and file state
Runtime file writes to any location Files are written relative to locations supplied by the
operating system
For help in determining if your driver package meets driver package isolation requirements, see Validating
Windows Drivers. For examples of how to update an INF to meet driver package isolation requirements, see
Porting an INF to follow driver package isolation.
Access to various registry and file state should be done by calling functions that provide a caller with the
location of the state and then the state is read/written relative to that location. Do not use hardcoded absolute
registry paths and file paths.
This section contains the following subsections:
Registry state
File state
Property state
Registry state
This section contains the following subsections:
PnP device registry state
Device interface registry state
Service registry state
PnP device registry state
Isolated driver packages and user-mode components typically use one of two locations to store device state in
the registry. These are the hardware key (device key) for the device and the software key (driver key) for the
device. The hardware key is typically for settings related to how an individual device instance interacts with the
hardware. For example, to enable a hardware feature or put the hardware into a specific mode. The software key
is typically for settings related to how an individual device instance interacts with the system and other software.
For example, to configure the location of a data file, to inter operate with a framework, or to access app settings
for a device. To retrieve a handle to these registry locations, use one of the following options:
IoOpenDeviceRegistr yKey (WDM)
WdfDeviceOpenRegistr yKey , WdfFdoInitOpenRegistr yKey (WDF)
CM_Open_DevNode_Key (user-mode code)
INF AddReg directive using HKR reg-root entries in an add-registry-section referenced from an INF
DDInstall section or DDInstall.HW section, as shown below:
[ExampleDDInstall.HW]
AddReg = Example_DDInstall.AddReg
[Example_DDInstall.AddReg]
HKR,,ExampleValue,,%13%\ExampleFile.dll
[ExampleDDInstall.Services]
Addservice = ExampleService, 0x2, Example_Service_Inst
[Example_Service_Inst]
DisplayName = %ExampleService.SvcDesc%
ServiceType = 1
StartType = 3
ErrorControl = 1
ServiceBinary = %13%\ExampleService.sys
AddReg=Example_Service_Inst.AddReg
[Example_Service_Inst.AddReg]
HKR, Parameters, ExampleValue, 0x00010001, 1
To access the location of this state from the service at runtime, use one of these functions:
IoOpenDriverRegistr yKey (WDM) with a DRIVER_REGKEY_TYPE of DriverRegKeyParameters
WdfDriverOpenParametersRegistr yKey (WDF)
GetSer viceRegistr yStateKey (Win32 Services) with a SERVICE_REGISTRY_STATE_TYPE of
Ser viceRegistr yStateParameters
These registry values supplied by the INF in the "Parameters" subkey for the service should only be read at
runtime and not modified. They should be treated as read only.
If the registry values supplied by the INF are default settings that can be overwritten at runtime, the override
values should be written into the Internal service registry state or Shared service registry state for the service.
When retrieving the settings, the setting can be looked for first in the mutable state. If it does not exist there,
then the setting can be looked for in the immutable state. RtlQuer yRegistr yValueWithFallback can be used
to help query settings such as these that have an override and a default value.
I n t e r n a l se r v i c e r e g i st r y st a t e
Internal service state is state that is written at runtime and owned and managed by only the service itself and is
only accessible to that service. To access the location for internal service state, use one of these functions from
the service:
IoOpenDriverRegistr yKey (WDM) with a DRIVER_REGKEY_TYPE of DriverRegKeyPersistentState
WdfDriverOpenPersistentStateRegistr yKey (WDF)
GetSer viceRegistr yStateKey (Win32 Services) with a SERVICE_REGISTRY_STATE_TYPE of
Ser viceRegistr yStatePersistent
If the service wants to allow other components to modify these settings, the service must expose an interface
that another component can call into that tells the service how to alter these settings. For example, a Win32
service could expose a COM or RPC interface and a driver service could expose an IOCTL interface via a device
interface.
Sh a r e d se r v i c e r e g i st r y st a t e
Shared service state is state that is written at runtime and can be shared with other user mode components if
they are sufficiently privileged. To access the location for this shared service state, use one of these functions:
IoOpenDriverRegistr yKey (WDM) with a DRIVER_REGKEY_TYPE of
DriverRegKeySharedPersistentState
GetSharedSer viceRegistr yStateKey (Win32 Services) with a
SERVICE_SHARED_REGISTRY_STATE_TYPE of Ser viceSharedRegistr yPersistentState
File state
This section contains the following subsections:
Device file state
Service file state
Device file state
If files related to a device need to be written at runtime, those files should be stored relative to a handle or file
path provided via OS API's. Configuration files specific to that device is one example of what types of files to be
stored here. To access the location of this state, use one of these functions from the service:
IoGetDeviceDirector y (WDM) with the Director yType parameter set to DeviceDirector yData
WdfDeviceRetrieveDeviceDirector yString (WDF)
Service file state
Service file state can be classified into one of 3 categories
Immutable service file state
Internal service file state
Shared service file state
I m m u t a b l e se r v i c e fi l e st a t e
Immutable service file state are files that are part of the driver package. For more information on accessing
those files, see Run from Driver Store .
I n t e r n a l se r v i c e fi l e st a t e
Internal service file state is state that is written at runtime and owned and managed by only the service itself
and is only accessible to that service. To access the location for internal service state, use one of these functions
from the service:
IoGetDriverDirector y (WDM, KMDF) with the Director yType parameter set to DriverDirector yData
WdfDriverRetrieveDriverDataDirector yString (UMDF)
GetSer viceDirector y (Win32 Services) with the eDirector yType parameter set to
Ser viceDirector yPersistentState
If the service wants to allow other components to modify these settings, the service must expose an interface
that another component can call into that tells the service how to alter these settings. For example, a Win32
service could expose a COM or RPC interface and a driver service could expose an IOCTL interface via a device
interface.
Sh a r e d se r v i c e fi l e st a t e
Shared service file state is state that is written at runtime and can be shared with other user mode components
if they are sufficiently privileged. To access the location for this shared service state, use one of these functions:
IoGetDriverDirector y (WDM, KMDF) with the Director yType parameter set to
DriverDirector ySharedData
GetSharedSer viceDirector y (Win32 Services) with the Director yType parameter set to
Ser viceSharedDirector yPersistentState
DriverData and ProgramData
Files that are to be used as part of intermediate operations that can be shared with other components can be
written to either DriverData or ProgramData locations.
These locations offer components a location to write temporary state or state that is meant to be consumed by
other components and potentially collected and copied from a system to be processed by another system. For
example, custom log files or crash dumps fit this description.
Avoid writing files in the root of the DriverData or ProgramData directories. Instead, create a subdirectory with
your company name and then write files and further subdirectories within that directory.
For example, for a company name of Contoso, a kernel-mode driver could write a custom log to
\DriverData\Contoso\Logs and a user-mode application could collect or analyze the log files from
%DriverData%\Contoso\Logs .
Dr i ver Dat a
The DriverData directory is available in Windows 10, version 1803 and later, and is accessible to administrators
and UMDF drivers.
Kernel-mode drivers access the DriverData directory by using a system-supplied symbolic link called
\DriverData .
User-mode programs access the DriverData directory by using the environment variable %DriverData% .
Program Dat a
The %ProgramData% user-mode environment variable is available for user-mode components to use when
storing data.
Property state
Both devices and device interfaces support storing state via the PnP property model. The property model allows
for structured property data to be stored against a device or device interface. This is meant for smaller data that
reasonably fits into the property types supported by the property model.
To access device properties, these APIs can be used:
WDM drivers
IoGetDevicePropertyData
IoSetDevicePropertyData
WDF drivers
WdfDeviceQueryProperty
WdfDeviceAllocAndQueryProperty
WdfDeviceQueryPropertyEx
WdfDeviceAllocAndQueryPropertyEx
WdfDeviceAssignProperty
WdfFdoInitQueryProperty
WdfFdoInitAllocAndQueryProperty
WdfFdoInitQueryPropertyEx
WdfFdoInitAllocAndQueryPropertyEx
User mode code
CM_Get_DevNode_Property
CM_Set_DevNode_Property
To access device interface properties, these APIs can be used:
WDM drivers
IoGetDeviceInterfacePropertyData
IoSetDeviceInterfacePropertyData
WDF drivers
WdfDeviceQueryInterfaceProperty
WdfDeviceAllocAndQueryInterfaceProperty
WdfDeviceAssignInterfaceProperty
User mode code
CM_Get_Device_Interface_Property
CM_Set_Device_Interface_Property
KMDF drivers
K M DF VERSIO N SUP P O RT A DDED
UMDF drivers
UM DF VERSIO N SUP P O RT A DDED
An INF that is using 'run from Driver Store' means that the INF uses DIRID 13 to specify the location for driver
package files on install.
For a 'run from Driver Store' file payloaded by an INF, the subdir listed in the SourceDisksFiles entry for the
file in the INF must match the subdir listed in the DestinationDirs entry for the file in the INF.
Additionally, a CopyFiles directive cannot be used to rename a file that is run from Driver Store. These
restrictions are required so that the installation of an INF on a device does not result in the creation of new files
in the Driver Store directory.
Since SourceDisksFiles entries cannot have multiple entries with the same filename and CopyFiles cannot be
used to rename a file, every 'run from Driver Store' file that an INF references must have a unique file name.
Driver packages have general support for 'run from Driver Store' starting with Windows 10 1709. However,
certain device stacks may place additional restrictions on files you need to provide that plug into that stack.
Some examples are these device stacks that did not support 'run from Driver Store' until Windows 10 1803:
UMDF driver binaries: See Restricting the Loading Location of UMDF Drivers for more information
UEFI firmware update: See Authoring an update driver package for more information
If providing a binary that plugs into a particular device stack, please consult the documentation for the specific
device stack you are plugging into to check if it supports providing a full file path to the binary and if there are
any restrictions on that full file path. If it supports providing a full file path to the binary with no restrictions on
that path, then it should support the file being 'run from Driver Store'.
[ExampleDDInstall.HW]
AddReg = Example_DDInstall.AddReg
[Example_DDInstall.AddReg]
HKR,,ExampleValue,,%13%\ExampleFile.dll
An INF example for setting this as device interface state would be:
[ExampleDDInstall.Interfaces]
AddInterface = {<fill in an interface class GUID for an interface exposed by the
device>},,Example_Add_Interface_Section
[Example_Add_Interface_Section]
AddReg = Example_Add_Interface_Section.AddReg
[Example_Add_Interface_Section.AddReg]
HKR,,ExampleValue,,%13%\ExampleFile.dll
The previous examples use an empty flags value, which results in a REG_SZ registry value. This results in the
%13% being turned into a fully qualified user mode file path. In many cases, it is preferable to have the path be
relative to an environment variable. If a flags value of 0x20000 is used, the registry value is of type
REG_EXPAND_SZ and the %13% converts to a path with appropriate environment variables to abstract the
location of the path. When retrieving this registry value, call ExpandEnvironmentStrings to resolve the
environment variables in the path.
If the value needs to be read by a kernel mode component, the value should be a REG_SZ value. When the
kernel mode component reads that value, it should prepend \??\ before passing it to APIs such as
ZwOpenFile .
To access this setting when it is part of the device's state, first the application must find the identity of the device.
User mode code can use CM_Get_Device_ID_List_Size and CM_Get_Device_ID_List to get a list of devices,
filtered as necessary. That list of devices might contain multiple devices, so search for the appropriate device
before reading state from the device. For example, call CM_Get_DevNode_Proper ty to retrieve properties on
the device when looking for a device matching specific criteria.
Once the correct device is found, call CM_Open_DevNode_Key to get a handle to the registry location where
the device state was stored.
Kernel mode code should retrieve a PDO (physical device object) to the device with the state and call
IoOpenDeviceRegistr yKey . One possible way for the kernel mode code to retrieve the PDO of the device
would be to discover an enabled interface exposed by the device and use IoGetDeviceObjectPointer to
retrieve the device object.
To access this setting when it is device interface state, User mode code can call
CM_Get_Device_Interface_List_Size and CM_Get_Device_Interface_List .
Additionally CM_Register_Notification can be used to be notified of arrivals and removals of device
interfaces so the code gets notified when the interface is enabled and then can retrieve the state. There may be
multiple device interfaces in the device interface class used in the above APIs. Examine those interfaces to
determine which is the correct interface for the setting to read.
Once the correct device interface is found, call CM_Open_Device_Interface_Key .
Kernel mode code can retrieve a symbolic link name for the device interface from which to get state. To do so,
call IoRegisterPlugPlayNotification to register for device interface notifications on the appropriate device
interface class. Alternatively, call IoGetDeviceInterfaces to get a list of current device interfaces on the system.
There may be multiple device interfaces in the device interface class used in the above APIs. Examine those
interfaces to determine which is the correct interface that should have the setting to be read.
Once the appropriate symbolic link name is found, call IoOpenDeviceInterfaceRegistr yKey to retrieve a
handle to the registry location where the device interface state was stored.
NOTE
Use the CM_GETIDLIST_FILTER_PRESENT flag with CM_Get_Device_ID_List_Size and CM_Get_Device_ID_List or the
CM_GET_DEVICE_INTERFACE_LIST_PRESENT flag with CM_Get_Device_Interface_List_Size and
CM_Get_Device_Interface_List . This ensures that the hardware related to the state that contains the file path is
present and ready for communication.
[DestinationDirs]
; Copy the file to %windir%\system32\drivers
Example_CopyFiles = 12
[ExampleDDInstall]
CopyFiles = Example_CopyFiles
[Example_CopyFiles]
ExampleBinary.sys
[ExampleDDInstall.Services]
AddService = ExampleService,0x2,Example_Service_Inst
[Example_Service_Inst]
DisplayName = %SvcDesc%
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
; Point at the file in %windir%\system32\drivers
ServiceBinary = %12%\ExampleBinary.sys
To move this file to be run from the Driver Store, you would need to update the DestinationDirs entry for where
the file will be copied to and update the ServiceBinary directive referencing the location of this file.
[DestinationDirs]
; Update the destination to DIRID 13
Example_CopyFiles = 13
[ExampleDDInstall]
CopyFiles = Example_CopyFiles
[Example_CopyFiles]
ExampleBinary.sys
[ExampleDDInstall.Services]
AddService = ExampleService,0x2,Example_Service_Inst
[Example_Service_Inst]
DisplayName = %SvcDesc%
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
; Point at the run from Driver Store file using DIRID 13
ServiceBinary = %13%\ExampleBinary.sys
[DestinationDirs]
; Copy the file to %windir%\system32\drivers\UMDF
Example_CopyFiles = 12, UMDF
[ExampleDDInstall]
CopyFiles = Example_CopyFiles
[Example_CopyFiles]
ExampleUmdfDriver.dll
[ExampleDDInstall.Wdf]
UmdfService = ExampleUmdfDriver,Example_UMDF_Inst
...
[Example_UMDF_Inst]
; Point at the file in %windir%\system32\drivers\UMDF
ServiceBinary = %12%\UMDF\ExampleUmdfDriver.dll
...
To move this file to be run from the Driver Store, you would need to update the DestinationDirs entry for where
the file will be copied to and update the ServiceBinary directive referencing the location of this file.
[DestinationDirs]
; Update the destination to DIRID 13
Example_CopyFiles = 13
[ExampleDDInstall]
CopyFiles = Example_CopyFiles
[Example_CopyFiles]
ExampleUmdfDriver.dll
[ExampleDDInstall.Wdf]
UmdfService = ExampleUmdfDriver,Example_UMDF_Inst
...
[Example_UMDF_Inst]
; Point at the run from Driver Store file using DIRID 13
ServiceBinary = %13%\ExampleUmdfDriver.dll
...
Other files
If your INF adds a file that may be loaded by other components and is not run from Driver Store, then your INF
may look like the following. In this example, only the name of the file is written to the device's registry state.
Components that read this registry value to determine what file to load would be depending on the file being in
%windir%\system32 or be depending on LoadLibrary's search order being able to find the file.
[DestinationDirs]
; Copy the file to %windir%\system32
Example_CopyFiles = 11
[ExampleDDInstall]
CopyFiles=Example_CopyFiles
AddReg=Example_AddReg
[Example_CopyFiles]
ExampleFile.dll
[Example_AddReg]
HKR,,FileLocation,,"ExampleFile.dll"
To move this file to be run from the Driver Store, you would need to update the DestinationDirs entry for where
the file will be copied to and update the location saved in the device's state. This requires components that read
that registry value to be able to handle that registry value being the full path to a file instead of a file relative to
%windir%\system32 .
[DestinationDirs]
Example_CopyFiles = 13 ; update the destination to DIRID 13
[ExampleDDInstall]
CopyFiles=Example_CopyFiles
AddReg=Example_AddReg
[Example_CopyFiles]
ExampleFile.dll
[Example_AddReg]
; Point at the run from Driver Store file using DIRID 13
HKR,,FileLocation,,"%13%\ExampleFile.dll"
Supporting multiple operating system versions
9/20/2022 • 2 minutes to read • Edit Online
Driver packages generally will support many versions of the Windows operating system. As part of supporting
multiple versions of the operating system, the driver package may need to have different behavior on different
versions of the operating system in order to make use of new features or to meet new requirements of the new
operating system version. For example, a driver package may want to have different behavior on operating
systems after a certain version in order to meet the requirements of Windows Drivers. The following sections
describe how you can have different behaviors both in the driver package's INF file and in the runtime behavior
of binaries in the driver package.
INF support
TargetOSVersion decorations on INF models sections in the INF allow the INF author to provide different
installation instructions and settings for different versions of the operating system.
See Combining platform extensions with operating system versions for more information.
Runtime support
When trying to alter behavior at runtime to support multiple operating system versions, it is recommended you
check for feature or API availability whenever possible instead of trying to check if the code is running on a
certain operating system version or later. For example, if there is an API that you want to use if it is available, you
can attempt to dynamically locate it instead of statically linking to it. If you are able to locate it, you can use it,
however, if it is not present in your current running environment, you can fall back to some alternative behavior.
Kernel mode
For kernel mode, see Writing drivers for different versions of Windows for more information on how to support
multiple versions of Windows from a single driver.
User mode
In user mode, you can use LoadLibraryEx along with GetProcAddress to check if a particular API you want to use
is available in your current running environment and to get a function pointer to use in order to call that API.
See Run-time dynamic linking and Using run-time dynamic linking for more information.
API Layering
9/20/2022 • 2 minutes to read • Edit Online
Overview
API Layering requires that binaries in Windows Driver packages call only those APIs and DDIs that are included
in UWP-based editions of Windows 10 or are from a curated set of Win32 APIs. API Layering is an extension of
the previous "U" requirement that was a part of DCHU design principles.
To see which platform an API supports, visit the documentation page for the API and examine the Target
Platform entry of the Requirements section. Windows Drivers must only use APIs or DDIs that have a Target
Platform listed as Universal , meaning the subset of functionality that is available on all Windows offerings.
The Windows API Sets page describes a set of best practices and tools for determining whether an API is
available on a particular platform.
You can use Microsoft Visual Studio 2019 in conjunction with the Windows Driver Kit (WDK) Version 2004 to
build Windows Drivers. You can download kits and tools from the Windows Hardware Dev Center.
In many cases, you can recompile a legacy kernel-mode driver as a Windows Driver, as long as the driver does
not work with any user-mode components. Legacy WDM and KMDF drivers should recompile as Windows
Drivers targeting Windows 10 with no conversion required. While the drivers may compile without any
conversion, this does not mean that the driver meets all of the Windows Drivers requirements. Please see
Getting Started with Windows Drivers for details regarding Windows Drivers requirements.
In contrast, existing user-mode drivers may require modification to compile as Windows drivers. Specifically,
your driver package must not have any dependencies outside of UWP. For example, only some of the Win32
APIs are part of UWP.
4. You can now build the solution. Visual Studio links against the required libraries and generates a .cat file,
an .inf file, and a driver binary.
Use the InfVerif, Driver Verifier Driver Isolation Checks, and ApiValidator tools to test your Windows Driver for
compliance with the requirements described in Getting Started with Windows Drivers.
InfVerif
InfVerif is a tool that validates INF syntax and checks that the INF conforms to requirements and restrictions.
Use InfVerif with /w and /v to verify that a Windows Driver:
Meets the declarative (D) principle of DCH Design Principles
Complies with the driver package isolation requirement of Getting Started with Windows Drivers
For more details, see Running InfVerif from the command line.
Targeting current and earlier versions of Windows
Each run of InfVerif tests a single ruleset, for example /w (Windows driver compatibility) or /k (Hardware Dev
Center submission). If your INF contains syntax introduced in a more recent version of Windows and you also
want to target previous Windows versions, use INF decorations to mark version-specific INF entries and then
run InfVerif multiple times, for example:
If there are no errors, the INF meets the Driver Package Isolation requirement of Windows Drivers.
For example, the INF AddEventProvider Directive is available starting in Windows 10, version 1809. To use this
directive in an INF targeting an OS version before Windows 10, version 1809, decorate both the install section
using legacy INF syntax for registering ETW event providers as well as the install section using the updated
syntax.
For sample code showing how to use OS decorations, see Combining Platform Extensions with Operating
System Versions.
To check more than one driver, separate each driver name with a space:
You'll need to reboot to enable the verification settings. To do this from the command line, specify:
shutdown /r /t 0
Example: ZwCreateKey provides path relative to a handle that is not from an approved API:
DRIVER_ISOLATION_VIOLATION: <driver name>: Registry operations should only use key handles returned from WDF
or WDM APIs. Detected creation of unisolated registry key \REGISTRY\MACHINE\SYSTEM\SomeKeyThatShouldNotExist
Consider enabling Device Fundamentals tests with DV driver isolation checks to help catch driver isolation
violations early.
ApiValidator
The ApiValidator tool verifies that the APIs that your binaries call are valid for a Windows Driver. The tool returns
an error if your binaries call an API that is outside the set of valid APIs for Windows Drivers. This tool is part of
the WDK for Windows 10.
ApiValidator validates that a driver supports API Layering, one of the requirements for Windows Drivers. For a
full list of requirements, see Getting Started with Windows Drivers.
Running ApiValidator in Visual Studio
If the Target Platform property of your driver project is set to Windows Driver , Visual Studio runs
ApiValidator automatically as a post-build step.
To view all the messages displayed by ApiValidator, navigate to Tools->Options->Projects and Solutions-
>Build and Run , and set MSBuild project build output verbosity to Detailed . When building from the
command line, add the switch /v:detailed or /v:diag to your build command to increase the verbosity.
For the umdf2_fx2 driver sample, API validation errors look this:
Warning 1 warning : API DecodePointer in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe osrusbfx2um
Warning 2 warning : API DisableThreadLibraryCalls in kernel32.dll is not supported. osrusbfx2um.dll calls
this API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe osrusbfx2um
Warning 3 warning : API EncodePointer in kernel32.dll is not supported. osrusbfx2um.dll calls this API.
C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe osrusbfx2um
Warning 4 warning : API GetCurrentProcessId in kernel32.dll is not supported. osrusbfx2um.dll calls this
API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe osrusbfx2um
Warning 5 warning : API GetCurrentThreadId in kernel32.dll is not supported. osrusbfx2um.dll calls this
API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe osrusbfx2um
Warning 6 warning : API GetSystemTimeAsFileTime in kernel32.dll is not supported. osrusbfx2um.dll calls
this API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe osrusbfx2um
Warning 7 warning : API IsDebuggerPresent in kernel32.dll is not supported. osrusbfx2um.dll calls this
API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe osrusbfx2um
Warning 8 warning : API IsProcessorFeaturePresent in kernel32.dll is not supported. osrusbfx2um.dll calls
this API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe osrusbfx2um
Warning 9 warning : API QueryPerformanceCounter in kernel32.dll is not supported. osrusbfx2um.dll calls
this API. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe osrusbfx2um
Error 10 error MSB3721: The command ""C:\Program Files (x86)\Windows Kits\10\bin\x64\ApiValidator.exe" -
DriverPackagePath:"C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\Debug\\" -
SupportedApiXmlFiles:"C:\Program Files (x86)\Windows Kits\10\build\universalDDIs\x86\UniversalDDIs.xml" -
ApiExtractorExePath:"C:\Program Files (x86)\Windows Kits\10\bin\x64"" exited with code -1. C:\Program
Files (x86)\Windows Kits\10\build\WindowsDriver.common.targets 1531 5 osrusbfx2um
%AdditionalDependencies);$(SDK_LIB_PATH)\OneCoreUAP.lib
To review other linker options for targeting OneCore SKUs, see Building for OneCore.
2. Remove or replace API calls that are not permitted one at a time and rerun the tool until there are no
errors.
3. In some cases, you can replace these calls with alternate DDIs that are listed on the reference pages for
the desktop-only DDI. You may have to code a workaround if there is not a suitable replacement. If you
need to, write a new Windows Driver starting from the driver templates in the WDK.
If you see errors like the following, please refer to the guidance in Building for OneCore.
For example, to verify the APIs called by the Activity sample in the WDK, first build the sample in Visual Studio.
Then open a command prompt and navigate to the directory containing the tool, for example
C:\Program Files (x86\Windows Kits\10\bin\x64 . Enter the following command:
ApiValidator.exe: Warning: API DecodePointer in kernel32.dll is not supported. osrusbfx2um.dll calls this
API.
ApiValidator.exe: Warning: API DisableThreadLibraryCalls in kernel32.dll is not supported. osrusbfx2um.dll
calls this API.
ApiValidator.exe: Warning: API EncodePointer in kernel32.dll is not supported. osrusbfx2um.dll calls this
API.
ApiValidator.exe: Warning: API GetCurrentProcessId in kernel32.dll is not supported. osrusbfx2um.dll calls
this API.
ApiValidator.exe: Warning: API GetCurrentThreadId in kernel32.dll is not supported. osrusbfx2um.dll calls
this API.
ApiValidator.exe: Warning: API GetSystemTimeAsFileTime in kernel32.dll is not supported. osrusbfx2um.dll
calls this API.
ApiValidator.exe: Warning: API IsDebuggerPresent in kernel32.dll is not supported. osrusbfx2um.dll calls
this API.
ApiValidator.exe: Warning: API IsProcessorFeaturePresent in kernel32.dll is not supported. osrusbfx2um.dll
calls this API.
ApiValidator.exe: Warning: API QueryPerformanceCounter in kernel32.dll is not supported. osrusbfx2um.dll
calls this API.
Troubleshooting ApiValidator
If ApiValidator.exe outputs an incorrect format error such as the following:
Error 1 error : AitStatic output file has incorrect format or analysis run on incorrect
file types. C:\Program Files (x86)\Windows Kits\10\src\usb\umdf2_fx2\driver\ApiValidator.exe
osrusbfx2um
$(SolutionDir)$(Platform)\$(ConfigurationName)\
This topic describes how the DCHU driver sample applies DCH design principles. You can use it as a model to
apply DCH design principles to your own driver package.
If you would like a local copy of the sample repo, clone from Windows-driver-samples.
Some portions of the sample may use directives and APIs that are only available on certain versions of
Windows 10 and above. Please refer to Device and Driver Installation to see what OS version a given directive is
supported on.
Prerequisites
Before you read this section, you should become familiar with the DCH Design Principles.
Overview
The sample provides example scenarios where two hardware partners, Contoso (a system builder, or OEM) and
Fabrikam (a device manufacturer, or IHV) are working together to create a driver that is DCH-compliant for a
device in Contoso's upcoming system. The device in question is an OSR USB FX2 learning kit. In the past,
Fabrikam would write a legacy driver package that was customized to a specific Contoso product line, and then
hand it to the OEM to handle servicing. This resulted in significant maintenance overhead, so Fabrikam decided
to refactor the code and create a DCH-compliant driver package instead.
[OsrFx2_AddReg]
HKR, OSR, "OperatingMode",, "Default" ; FLG_ADDREG_TYPE_SZ
HKR, OSR, "OperatingParams",, "None" ; FLG_ADDREG_TYPE_SZ
In [ osrfx2_DCHU_extension.inx ], Contoso overrides the OperatingParams registry value set by the base and
adds OperatingExceptions :
[OsrFx2Extension_AddReg]
HKR, OSR, "OperatingParams",, "-Extended"
HKR, OSR, "OperatingExceptions",, "x86"
Note that extensions are always processed after the base INF but in no definite order. If a base INF is updated to
a newer version, then the extensions will still be re-applied after the new base INF is installed.
[OsrFx2_Install.NT]
CopyFiles = OsrFx2_CopyFiles
[OsrFx2_Install.NT.Services]
AddService = WUDFRd, 0x000001fa, WUDFRD_ServiceInstall ; Flag 0x2 sets this as the service for the device
AddService = osrfx2_DCHU_usersvc,, UserSvc_ServiceInstall
[UserSvc_ServiceInstall]
DisplayName = %UserSvcDisplayName%
ServiceType = 0x10 ; SERVICE_WIN32_OWN_PROCESS
StartType = 0x3 ; SERVICE_DEMAND_START
ErrorControl = 0x1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %13%\osrfx2_DCHU_usersvc.exe
AddTrigger = UserSvc_AddTrigger ; AddTrigger syntax is only available in Windows 10
Version 2004 and above
[UserSvc_AddTrigger]
TriggerType = 1 ; SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL
Action = 1 ; SERVICE_TRIGGER_ACTION_SERVICE_START
SubType = %GUID_DEVINTERFACE_OSRFX2% ; Interface GUID
DataItem = 2, "USB\VID_0547&PID_1002" ; SERVICE_TRIGGER_DATA_TYPE_STRING
[OsrFx2_CopyFiles]
osrfx2_DCHU_base.dll
osrfx2_DCHU_filter.dll
osrfx2_DCHU_usersvc.exe
Note that such a service could also be installed in a component or extension INF, depending on the scenario.
Use a component to install legacy software from a driver package
Fabrikam has an executable file osrfx2_DCHU_componentsoftware.exe that they previously installed using a co-
installer. This legacy software displays the registry keys set by the board and is required by the OEM. This is a
GUI-based executable that only runs on Windows for desktop editions. To install it, Fabrikam creates a separate
component driver package and adds it in their extension INF.
The following snippet from [ osrfx2_DCHU_extension.inx ] uses the AddComponent directive to create a virtual
child device:
[OsrFx2Extension_Install.NT.Components]
AddComponent = osrfx2_DCHU_component,,OsrFx2Extension_ComponentInstall
[OsrFx2Extension_ComponentInstall]
ComponentIds=VID_045e&PID_94ab
Then, in the component INF [ osrfx2_DCHU_component.inx ], Fabrikam specifies the AddSoftware directive to
install the optional executable:
[OsrFx2Component_Install.NT.Software]
AddSoftware = osrfx2_DCHU_componentsoftware,, OsrFx2Component_SoftwareInstall
[OsrFx2Component_SoftwareInstall]
SoftwareType = 1
SoftwareBinary = osrfx2_DCHU_componentsoftware.exe
SoftwareArguments = <<DeviceInstanceId>>
SoftwareVersion = 1.0.0.0
[OsrFx2Component_CopyFiles]
osrfx2_DCHU_componentsoftware.exe
The source code for the Win32 app is included in the sample.
Note that the component driver package is only distributed on Desktop SKUs due to targeting set in the
Windows Hardware Dev Center dashboard. For more info, see Publish a driver to Windows Update.
WDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData = { 0 };
static const wchar_t customCapabilities[] = L"CompanyName.yourCustomCapabilityName_YourStorePubId\0";
WDF_DEVICE_INTERFACE_PROPERTY_DATA_INIT(&PropertyData,
&GUID_DEVINTERFACE_OSRUSBFX2,
&DEVPKEY_DeviceInterface_UnrestrictedAppCapabilities);
Status = WdfDeviceAssignInterfaceProperty(Device,
&PropertyData,
DEVPROP_TYPE_STRING_LIST,
sizeof(customCapabilities),
(PVOID)customCapabilities);
The new app (not included in the sample) is secure and can be updated easily in the Microsoft Store. With the
UWP application ready, Contoso uses DISM - Deployment Image Servicing and Management to pre-load the
application on Windows Desktop edition images.
[OsrFx2Extension_Install.NT]
CopyInf=osrfx2_DCHU_component.inf
This directive can also be used to coordinate installation of INF files in multifunction devices. For more details,
see Copying INF files.
NOTE
While a base driver can payload an extension (and target the base driver in the shipping label), an extension bundled with
another driver cannot be published to the extension hardware ID.
[DestinationDirs]
OsrFx2_CopyFiles = 13 ; copy to Driver Store
See the run from Driver Store page for more details regarding how to dynamically find and load files from the
Driver Store.
Summary
The following diagram shows the driver packages that Fabrikam and Contoso created for their DCH-compliant
driver. In the loosely coupled example, they will make three separate submissions on the Windows Hardware
Dev Center dashboard: one for the base, one for the extension, and one for the component. In the tightly
coupled example, they will make two submissions: base and extension/component.
Note that the component INF will match on the component hardware ID, whereas the base and extensions will
match on the board's hardware ID.
See also
Getting Started with Windows Drivers
Using an Extension INF File
osrfx2_DCHU_base.inx
"loosely coupled" osrfx2_DCHU_component.inx
"loosely coupled" osrfx2_DCHU_extension.inx
"tightly coupled" osrfx2_DCHU_component.inx
"tightly coupled" osrfx2_DCHU_extension.inx
Debugging a Windows Driver
9/20/2022 • 2 minutes to read • Edit Online
For general information about debugging drivers, see Getting Started with Windows Debugging.
You can access the ETW logs using Tracelog by using !wmitrace in a debugger session.
Porting an INF to follow driver package isolation
9/20/2022 • 5 minutes to read • Edit Online
This page is intended to be a quick look up guide to help you update an INF file to follow driver package
isolation as part of updating your driver package to be a Windows Driver. The following sections provide
examples of some of the more common things you may have in your driver package INF file with references to
information on how to update those to be driver package isolation compliant. If your driver package needs to
support the old way of doing something for older operating system versions while using the new way on newer
operating system versions, see Combining Platform Extensions with Operating System Versions for how to
achieve that in an INF.
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\ExampleProvider/Analytic",
"OwningPublisher", 0x0, "{35356277-0b54-43da-b324-671006d74759}"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\ExampleProvider/Analytic", "Enabled",
0x00010001, 1
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\ExampleProvider/Analytic", "Isolation",
0x00010001, 1
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\ExampleProvider/Analytic",
"ChannelAccess",0x0, \
"O:BAG:SYD:(A;;0xf0007;;;SY)(A;;0x7;;;BA)(A;;0x3;;;BO)(A;;0x5;;;SO)(A;;0x1;;;IU)(A;;0x3;;;SU)(A;;0x1;;;S-1-
5-3)(A;;0x2;;;S-1-5-33)(A;;0x1;;;S-1-5-32-573)"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\ExampleProvider/Analytic", "Type",
0x00010001, 2
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{35356277-0b54-43da-b324-671006d74759}" ,
, 0x0, "ExampleProvider"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{35356277-0b54-43da-b324-671006d74759}",
"ResourceFileName", 0x00020000, "%13%\ExampleBinary.sys"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{35356277-0b54-43da-b324-671006d74759}",
"MessageFileName", 0x00020000, "%13%\ExampleBinary.sys"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{35356277-0b54-43da-b324-
671006d74759}\ChannelReferences\0", , 0x0, "ExampleProvider/Analytic"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{35356277-0b54-43da-b324-
671006d74759}\ChannelReferences\0", "Id", 0x00010001, 16
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{35356277-0b54-43da-b324-
671006d74759}\ChannelReferences\0", "Flags", 0x00010001, 0
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{35356277-0b54-43da-b324-
671006d74759}\ChannelReferences", Count, 0x00010001, 1
Instead of using an AddReg to register ETW providers and EventLog channels, they should be registered using
an AddEventProvider directive from a DDInstall.Events section. For example:
[ExampleDDInstall.Events]
AddEventProvider={35356277-0b54-43da-b324-671006d74759}, Example_EVvntProvider_Inst
[Example_EventProvider_Inst]
ProviderName=ExampleProvider
ResourceFile=%13%\ExampleBinary.sys
MessageFile=%13%\ExampleBinary.sys
AddChannel=ExampleProvider/Analytic,0x3,Example_Channel_Inst ; Note that the type of the channel here is
different than in the raw AddReg. Please see the AddEventProvider documentation for appropriate values
[Example_Channel_Inst]
Isolation=1
Access="O:BAG:SYD:(A;;0xf0007;;;SY)(A;;0x7;;;BA)(A;;0x3;;;BO)(A;;0x5;;;SO)(A;;0x1;;;IU)(A;;0x3;;;SU)
(A;;0x1;;;S-1-5-3)(A;;0x2;;;S-1-5-33)(A;;0x1;;;S-1-5-32-573)"
Enabled=1
Value=16
Using an AddEventProvider directive from a DDInstall.Events section is supported on Windows 10 1809 and
later versions of Windows.
Instead of using an AddReg to register or update an AutoLogger, it should be registered or updated using an
AddAutoLogger or UpdateAutoLogger directive from a DDInstall.Events section. For example:
[ExampleDDInstall.Events]
AddAutoLogger=ExampleAutoLogger,{6f1373c7-eec8-495c-bfe5-1270336368df},Example_AutoLogger_Inst
[Example_AutoLogger_Inst]
Start=1
BufferSize = 0x40
LogFileMode=0x400
MaximumBuffers=0x40
AddAutoLoggerProvider={35356277-0b54-43da-b324-671006d74759},Example_AutoLoggerProvider_Inst
[Example_AutoLoggerProvider_Inst]
Enabled=1
EnableLevel=0x4
MatchAnyKeyword=0
Using an AddAutoLogger or UpdateAutoLogger directive from a DDInstall.Events section is supported on
Windows 11 and later versions of Windows.
[ExampleDDInstall.CoInstallers]
CopyFiles = CoInstallerCopyFilesSection
AddReg = Example_CoInstallers_AddReg
[CoInstallerCopyFilesSection]
ExampleCoInstall.dll
[Example_CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"ExampleCoInstall.dll,ExampleCoInstallEntryPoint"
Instead, your application should be a Universal Windows Platform application and installed using an
AddSoftware directive from a DDInstall.Software section. See Pairing a driver with a Universal Windows
Platform (UWP) app for more information. An AddSoftware directive is supported on Windows 10 1703 and
later versions of Windows.
[ExampleDDInstall]
AddReg= Example_Registry
[Example_ Registry]
HKLM,SYSTEM\CurrentControlSet\Services\ServiceNotCreatedByThisInf\ExampleKey, ExampleValue, %REG_DWORD%, 1
This is not supported. An INF should only be changing settings on services created by that INF and the INF
should remove this AddReg.
[ExampleDDInstall.Services]
AddService = ExampleService,0x2,Example_Service_Inst
[Example_Service_Inst]
DisplayName = %SvcDesc%
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %13%\ExampleBinary.sys
AddReg = Example_Service_Registry
[Example_Service_Registry]
HKR,,ExampleValue,%REG_DWORD%,0x00000040
HKR,CustomSubkey,ExampleValue,%REG_DWORD%,0x00000040
To be driver package isolation compliant, an AddReg directive supplying service registry keys and values can
only modify keys and values under the service’s Parameters subkey. The settings need to be moved under the
service’s Parameters subkey and the Parameters subkey can be accessed at runtime with
IoOpenDriverRegistryKey using a RegKeyType of DriverRegKeyParameters. IoOpenDriverRegistryKey is
supported on Windows 10 1803 and later versions of Windows.
Instead, the APO registration information should be in a section referenced by an AddReg directive from a
DDInstall section. The HKCR registry root should be changed to an HKR registry root to put the settings relative
to the device’s “software” (aka “driver”) registry state location. See Registering APOs for Processing Modes and
Effects in the INF File for more information.
Creating a New Device Function Driver
9/20/2022 • 4 minutes to read • Edit Online
In this topic we explain how to use Visual Studio to start writing a new device function driver. Device function
drivers are different from filter drivers, software drivers, and file system drivers, which we cover in other topics.
To learn about device function drivers and how they differ from other types of drivers, see What is a Driver?,
Choosing a Driver Model, and Device Nodes and Device Stacks.
To begin, first determine where your device fits in the list of technologies described in Device and Driver
Technologies. To learn about which driver models are available for your device, see the documentation for that
particular technology. The recommended driver model varies from one technology to the next. For some
technologies, the documentation recommends using the User Mode Driver Framework (UMDF) or the Kernel
Mode Driver Framework (KMDF). For other technologies, the documentation explains how to create a minidriver
that is part of a driver pair. Minidrivers go by a variety of names, including miniport and miniclass.
Next, determine which of the following cases describes your driver model recommendation and follow the
steps:
Case 1: The documentation for your technology recommends UMDF.
1. In Visual Studio, on the File menu, choose New | Project .
2. In the New Project dialog box, in the left pane, locate and select Visual C++ | Windows Driver | WDF .
3. In the middle pane, select User Mode Driver (UMDF) .
4. Fill in the Name and Location boxes, and select OK . For more details, see Writing a UMDF Driver Based on a
Template. Note When you create a new UMDF driver, you must select a driver name that has 32 characters
or less. This length limit is defined in wdfglobals.h.
5. At this point, you have a driver project that implements the general code required by most UMDF drivers.
Now you can supply the code that is specific to your device. Refer to the documentation for your technology
to learn about the interfaces that you need to implement.
Case 2: The documentation for your technology recommends KMDF.
1. In Visual Studio, on the File menu, choose New | Project .
2. In the New Project dialog box, in the left pane, locate and select WDF .
3. In the middle pane, select Kernel Mode Driver (KMDF) .
4. Fill in the Name and Location boxes, and select OK . For more details, see Writing a KMDF Driver Based on a
Template. Note When you create a new KMDF driver, you must select a driver name that has 32 characters
or less. This length limit is defined in wdfglobals.h.
5. At this point, you have a driver project that implements the general code required by most KMDF drivers.
Now you can supply the code that is specific to your device. Refer to the documentation for your technology
to learn about the methods that you need to implement.
Case 3: The documentation for your technology describes a minidriver model.
If your device technology has a miniport, miniclass, or some other kind of minidriver model, check to see if
Visual Studio has a specific template for the model.
1. In Visual Studio, on the File menu, choose New | Project .
2. In the New Project dialog box, in the left pane, locate and select Templates | Visual C++ | Windows
Driver .
3. Browse the list of installed templates to find a template for the type of minidriver you need to write.
4. If there is no template for your type of minidriver under Windows Driver , select Online and browse the
templates that are available online.
5. If you find a template for your type of minidriver, select the template, fill in the Name and Location boxes,
and select OK .
6. At this point, you have a driver project that implements the general code required by your minidriver. Now
you can supply the code that is specific to your device. Refer to the documentation for your technology to
learn about the functions that you need to implement.
If your device technology has a minidriver model, and you are not able to find a specific template for your type
of minidriver, the Windows Driver Model (WDM) template is most likely going to be your starting point. Refer to
your technology-specific documentation for guidance. In rare cases, you can use KMDF to write a minidriver, but
usually the starting point is WDM.
1. In Visual Studio, on the File menu, choose New | Project .
2. In Visual Studio, in the New Project dialog box, under Windows Driver , select WDM.
3. Fill in the Name and Location boxes, and select OK .
4. At this point, you have an empty WDM driver project. In the Solution Explorer window, select and hold (or
right-click) your driver project, and choose Add | New Item .
5. In the Add New Item dialog box, select C++ File (.cpp) , enter a name for your file, and select OK .
Note If you want to create a .c file instead of a .cpp file, enter a name that has the .c extension.
6. Refer to the documentation for your technology to learn about the functions that you need to implement.
As you implement and organize your functions, you might decide to add additional .cpp or .c files.
Creating a New Filter Driver
9/20/2022 • 5 minutes to read • Edit Online
In this topic we explain how to use Visual Studio to start writing a new filter driver. Filter drivers are different
from device function drivers, software drivers, and file system drivers, which we cover in other topics. To learn
about filter drivers and how they differ from other types of drivers, see the following topics.
What is a Driver?
Choosing a Driver Model
Device Nodes and Device Stacks
Filter Drivers
Types of WDM Drivers
To begin, first determine which driver model is appropriate for your filter driver. For help determining which
model is best for you, see Choosing a Driver Model. If you are writing a filter driver for a hardware device,
determine where your device fits in the list of technologies described in Device and Driver Technologies. See the
documentation for that particular technology to see whether there is any guidance for choosing a filter driver
model. The recommended filter driver model varies from one technology to the next. For some technologies, the
documentation recommends using the User Mode Driver Framework (UMDF), the Kernel Mode Driver
Framework (KMDF), or the Windows Driver Model (WDM). For other technologies, the documentation gives
explicit details on how to write a filter driver. Some technologies have mini filter models. For some technologies,
there might not be any recommendation for a filter driver model.
Next, determine which of the following cases describes your driver model recommendation and follow the
steps:
Microsoft has developed a method of declaratively adding filters by expressing the intent of the filter, rather than
the stack position, known as device filter driver ordering.
NOTE
Even without levels defined by the base INF, a declarative filter may register as simply upper or lower. When levels are not
defined, this is logically equivalent to appending the filter to the end of the UpperFilters/LowerFilters registry value. When
levels are defined, one of the levels must be marked as the default level in the base driver, and in this case the filter will be
registered into that level.
Scenarios
Consider an I/O device driver that encrypts the data that is coming through the stack. A typical implementation
may use a lower filter driver immediately underneath the function driver to accomplish this. In order to ensure
that the encryption filter is placed at the exact position the driver author desires, they may use declarative filters
as shown below:
The Base INF establishes two levels of lower filters, "Encryption" and "Monitoring" (Default). "Monitoring"
(Default) in this example are the rest of the lower filters that might exist for this particular device. By explicitly
placing the "Encrypt" filter driver in the "Encryption" level, the driver ensures that the resulting device stack
order will put the "Encrypt" filter driver before any other lower filters and immediately following the function
driver.
Let's take the example one step further. Imagine a newer version of the driver comes out and the author has
built in encryption to the function driver. This removes the need for a separate "Encrypt" filter driver. The author
simply needs to remove the level that contained the "Encrypt" filter from the Base INF and when the driver
updates, the stack is dynamically built again.
If a filter declares itself to be in an explicit level that does not exist, the filter does not end up in the device stack.
In the example, the Base INF has been updated and even though the Extension INF remains the same, the
resulting device stack excludes the "Encrypt" filter as it was not included in the Base INF's declaration of levels.
Level Order: A, B, C
DefaultFilterLevel: C
Specifying the default level as the final level indicates that any filter that lacking position information will be
appended to the filter list. Alternatively, the driver author may wish to have the stack always end with filters
explicitly registered to level C:
Level Order: A, B, C
DefaultFilterLevel: B
Due to the default filter level being set to B, any additional filter without position information will be inserted
between A's filters and C's filters.
Syntax
Registering filters
See the INF DDInstall.Filters section and the AddFilter directive documentation for more information.
[DDInstall.Filters]
AddFilter = <FilterName>, [Flags], FilterSection
[FilterSection]
FilterLevel=<LevelName>
Option 2:
[FilterSection]
FilterPosition=Upper/Lower
[DDInstall.HW]
AddReg = FilterLevel_Definition
[FilterLevel_Definition]
HKR,,UpperFilterLevels,%REG_MULTI_SZ%,"LevelA","LevelB","LevelC"
HKR,,UpperFilterDefaultLevel,,"LevelC"
HKR,,LowerFilterLevels,%REG_MULTI_SZ%,"LevelD","LevelE","LevelF"
HKR,,LowerFilterDefaultLevel,,"LevelE"
DEVPKEY_Device_CompoundUpperFilters
DEVPKEY_Device_CompoundLowerFilters
[Filters]
HKR,,"UpperFilters", 0x00010008, "MyFilter"
This syntax will add "MyFilter" to the end of the list of upper filters.
With the new syntax that has been introduced, the above section is logically similar to:
[DDInstall.Filters]
AddFilter = MyFilter,,MyUpperFilterInstall
[MyUpperFilterInstall]
FilterPosition = Upper
This specifies that the filter "MyFilter" should be added to the list of upper filters. If the base INF has specified
filter levels, using FilterPosition will register the filter in the default level for that position.
If filter levels are not specified, this filter will be registered as an upper filter in arbitrary order.
See Also
INF DDInstall.Filters section
AddFilter directive
Creating a New Software Driver
9/20/2022 • 2 minutes to read • Edit Online
In this topic we explain how to use Visual Studio to start writing a new software driver. Software drivers are
different from device function drivers, filter drivers, and file system drivers, which we cover in other topics. For
more information about software drivers and how they differ from other types of drivers, see What is a Driver?
and Choosing a Driver Model.
To begin, first determine which driver model is appropriate for your software driver. The three options are the
Kernel Mode Driver Framework (KMDF), the legacy NT driver model, and the Windows Driver Model (WDM). For
help determining which model is best for you, see Choosing a Driver Model.
NOTE
When you create a new KMDF driver, you must select a driver name that has 32 characters or less. This length
limit is defined in wdfglobals.h.
5. At this point, you have a driver project that implements the general code required by most KMDF drivers.
Now you can supply the code that is specific to your software driver.
NOTE
You are not going to write a WDM driver, but you need the Empty WDM Driver template.
NOTE
If you want to create a .c file instead of a .cpp file, enter a name that has the .c extension.
6. Include ntddk.h.
7. Implement the functions required by your software driver. As you implement and organize your
functions, you might decide to add header files and additional .cpp or .c files.
NOTE
If you want to create a .c file instead of a .cpp file, enter a name that has the .c extension.
6. Include wdm.h.
7. Implement the functions required by your software driver. As you implement and organize your
functions, you might decide to add header files and additional .cpp or .c files.
Creating a new primitive driver
9/20/2022 • 4 minutes to read • Edit Online
Use a primitive driver to handle and manage software that uses INF-based installation but are not necessarily
tied to a particular hardware device.
Legacy Compatibility
While [DefaultUninstall] is prohibited in Primitive Drivers, an exception is made for the sake of down-level OS
compatibility. Windows introduces an INF directive that causes an OS version that supports Primitive Drivers to
ignore the [DefaultUninstall] section. If your driver package needs to support down-level OS versions, include
the following syntax to ensure that the platform will appropriately handle such cases:
[DefaultUninstall.NTamd64]
LegacyUninstall=1
The [DefaultInstall] and [DefaultUninstall] sections must still be architecture decorated ; however, by
including the LegacyUninstall=1 , Windows ignores the [DefaultUninstall] section (in Windows 10 version 1903
and later). By doing so, you can include that section in your INF, where it can be used down-level with a legacy
install/uninstall application in order to uninstall the primitive driver package.
Beginning with Windows 10 version 1903, if you pass an architecture-decorated [DefaultInstall] or
[DefaultUninstall] section in to the InstallHInfSection API in setupapi.dll, the driver package will be checked to
determine if it supports primitive driver functionality. If it does support primitive driver functionality, rather than
process the specified section in the legacy way, the INF is passed to DiInstallDriver or DiUninstallDriver, as
appropriate. This way, a single installer can make use of primitive drivers on compatible OS versions and
maintain support for previous OS versions.
[Driver.NTx86]
%DeviceDesc% = InstallSection_32,
[Driver.NTamd64]
%DeviceDesc% = InstallSection_64,
[InstallSection_64]
CopyFiles = MyCopyFiles_64
AddReg = MyAddReg
[InstallSection_64.Services]
AddService = MyService,, MyService_Install
[InstallSection_32]
CopyFiles = MyCopyFiles_x86
AddReg = MyAddReg
[InstallSection_32.Services]
AddService = MyService,, MyService_Install
[DefaultInstall.NTamd64]
CopyFiles = MyCopyFiles_64
AddReg = MyAddReg
[DefaultInstall.NTamd64.Services]
AddService = MyService,, MyService_Install
[DefaultInstall.NTx86]
CopyFiles = MyCopyFiles_x86
AddReg = MyAddReg
[DefaultInstall.NTx86.Services]
AddService = MyService,, MyService_Install
Creating a Driver From Existing Source Files
9/20/2022 • 2 minutes to read • Edit Online
The WDK is integrated with Microsoft Visual Studio, and uses the same compiler and build tools that you use to
build Visual Studio solutions and projects. MSBuild replaces the Windows Build Utility (Build.exe) that was used
in versions of the WDK prior to Windows Driver Kit (WDK) 8.
To convert a driver that was created with a previous version of the WDK, create a new Windows driver solution
in Visual Studio using one of the provided Windows driver templates. If you start with a template for your driver
model, the structure of the project will be in place and the correct platform tool set will be selected. You can then
add your source files to the solution. For information about selecting templates, see Creating a New Device
Function Driver, Creating a New Filter Driver, or Creating a New Software Driver.
Related topics
WDK and the Visual Studio build environment
ProjectUpgradeTool
MSBuild
Walkthrough: Using MSBuild
Creating a New Device Function Driver
Creating a New Filter Driver
Creating a New Software Driver
Using Visual Studio or MSBuild to build a driver
9/20/2022 • 5 minutes to read • Edit Online
This topic describes how you can build a driver using the Visual Studio development environment, or from the
command line by using the Microsoft Build Engine (MSBuild).
Impor tant Starting in Windows Driver Kit (WDK) 8, MSBuild replaced the Windows Build Utility (Build.exe). The
WDK now uses the same compiler and build tools that you use to build Visual Studio projects. Driver projects
that were built with previous versions of the WDK must be converted to work in the Visual Studio environment.
You can run a conversion utility from the command line, or you can convert an existing driver by creating new
Visual Studio project from existing sources. For more info, see Creating a Driver From Existing Source Files and
WDK and the Visual Studio build environment.
Syntax - To specify a specific configuration and platform, use the following command syntax:
For example, the following command builds a driver for the "Debug" configuration, "Win32" platform,
and for Windows 10.
The TargetPlatformVersion setting is optional and allows you to specify the kit version to build with.
The default is to use the latest kit.
Signing properties for individual driver files (see Signing Signing properties for driver packages (see Signing a
a Driver) Driver)
Counters Manifest Preprocessor Properties for Driver Deployment Properties for Driver Package Projects (see
Projects (for CTRPP) Deploying a Driver to a Test Computer)
Driver Model Settings Properties for Driver Projects Driver Verifier Properties for Driver Package Projects
DRIVER P RO JEC T P RO P ERT IES DRIVER PA C K A GE P RO P ERT IES
Message Compiler Properties for Driver Projects KMDF Verifier Properties for Driver Package Projects
Stampinf Properties for Driver Projects UMDF Verifier Properties for Driver Package Projects
WPP Preprocessor (WPP Tracing) Inf2Cat Properties for Driver Package Projects (see the
Inf2Cat tool)
Related topics
Building in Visual Studio
Building Drivers for Different Versions of Windows
Using the Microsoft C Runtime with User-Mode Drivers and Desktop Apps
ProjectUpgradeTool
MSBuild
Creating a Driver From Existing Source Files
WDK and the Visual Studio build environment
Signing a Driver
Deploying a Driver to a Test Computer
Building for OneCore
9/20/2022 • 3 minutes to read • Edit Online
When you use Visual Studio to build user-mode code for Windows 10, you can customize linker options to
target specific versions of Windows. Consider the following factors:
Should the built binary run on only the most recent version of Windows? Or should it run on earlier
versions, such as Windows 7?
Does your project have any UWP dependencies?
For example, when you create a new UMDF v2 driver project, Visual Studio links to OneCoreUAP.lib by default.
This results in a binary that runs on the most recent version of Windows, and it permits addition of UWP
functionality.
However, depending on your requirements, you might choose instead to link to OneCore.lib . The following
table shows the scenarios applicable to each library:
L IB RA RY SC EN A RIO
NOTE
To change linker options in Visual Studio, choose project properties and navigate to Linker->Input->Additional
Dependencies .
A subset of Windows APIs compile cleanly but return runtime errors on non-Desktop OneCore editions (for
example Mobile or IoT).
For example, the InstallApplication function returns ERROR_ NOT_SUPPORTED on non-Desktop OneCore editions.
The ApiValidator tool also reports these problems. The next section describes how to fix them.
If your app or base driver needs to run on Windows 10 as well as earlier versions of Windows, you must
remove API calls in the above category.
Error: <Binary Name> has a dependency on <Module Name><Api Name> but is missing: IsApiSetImplemented("
<contract-name-for-Module>)
API calls in the above category compile fine, but may not behave as expected at runtime, depending on
the target operating system. To pass the API Layering requirement for Windows Drivers, wrap these calls
with IsApiSetImplemented .
This enables you to compile your code with no errors. Then at runtime, if the target machine does not have the
needed API, IsApiSetImplemented returns FALSE.
The following code samples illustrate how to do this.
#include <windows.h>
#include <stdio.h>
#include <Wtsapi32.h>
WTSFreeMemory(pInfo);
}
else
{
wprintf(L"WTSEnumerateSessions failure : %x\n", GetLastError());
}
return 0;
}
if (!IsApiSetImplemented("ext-ms-win-session-wtsapi32-l1-1-0"))
{
wprintf(L"IsApiSetImplemented on ext-ms-win-session-wtsapi32-l1-1-0 returns FALSE\n");
}
else
{
if (WTSEnumerateSessionsW(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pInfo, &count))
{
wprintf(L"SessionCount = %d\n", count);
WTSFreeMemory(pInfo);
}
else
{
wprintf(L"WTSEnumerateSessions failure : %x\n", GetLastError());
}
}
return 0;
}
Recommended actions
Review the linker options above and update your Visual Studio project accordingly.
Use the ApiValidator tool in the WDK. This tool runs automatically when you build a driver in Visual Studio.
Use runtime testing to verify that your user-mode code runs as you expect on non-Desktop OneCore
editions. Note that stubbed APIs may generate different error codes.
See Also
Validating Windows Drivers
OneCore
Building Drivers for Different Versions of Windows
9/20/2022 • 3 minutes to read • Edit Online
If you are writing drivers for different versions of Windows, the following section provides some guidelines
about how you should build those drivers using the Windows Driver Kit (WDK), Visual Studio, and MSBuild.
XM L
<KernelBufferOverflowLib>$(DDK_LIB_PATH)\BufferOverflowK.lib</KernelBufferOverflowLib>
For example, if your driver supports Windows 8.1 and Windows 8 debug and release builds, those
configuration sections would look like the following:
XM L
The <KernelBufferOverflowLib> elements must appear in the driver project file before the element
that imports Microsoft.Cpp.props, which imports the tool set.
After you modify and save the driver project file, you can open the project file in Visual Studio and build
the driver.
Related topics
Writing drivers for different versions of Windows
Building a Driver
Building Arm64 Drivers with the WDK
9/20/2022 • 2 minutes to read • Edit Online
Windows 10 can run on machines that are powered by Arm64 processors. However, because Windows 10 on
Arm does not support emulation of x86 kernel-mode or UMDF drivers, you must recompile these drivers to
Arm64 using the instructions below.
Setup
1. Download Visual Studio 2017 or 2019. You'll need at minimum version 15.9.
2. On the Windows start menu, type Visual Studio Installer . Then on the Workloads tab, select Desktop
development with C++ .
4. From Type or Select new Platform , select Arm64 . Copy settings from Win32 . Select OK and Close .
See Also
Debugging Arm64
Windows 10 on Arm
HLK Arm64 Getting Started Guide
Using the Enterprise WDK
9/20/2022 • 2 minutes to read • Edit Online
The Enterprise Windows Driver Kit (Enterprise WDK) is a command-line build environment that does not require
any installation prior to use. Once you have downloaded the EWDK, you can manage it with version control
software or you can zip the files and copy as needed. A .zip file created with the Enterprise WDK contains all the
necessary compilers, linkers, build tools, headers and libs to build Visual Studio-based driver projects.
The Enterprise WDK contains the necessary elements to build drivers and basic Win32 driver test applications.
Use your favorite code editor to modify source code and project files. Because it is command-line based, the
Enterprise WDK does lack some of the features incorporated into Visual Studio, such as an IDE, driver
deployment and driver testing.
Getting Started
NOTE
Starting in Windows 10 version 1709, the Enterprise WDK is ISO-based. To get started, download and mount the ISO,
then run LaunchBuildEnv .
See Also
MSBuild Reference
Installing the WDK 8.1 Build Environment in a Lab
9/20/2022 • 3 minutes to read • Edit Online
The Windows Driver Kit (WDK) 8.1 provides a feature that enables you to copy components of Visual Studio and
the WDK to a new location and then launch the build environment from the command line. From here you can
build Windows drivers without having to run the Visual Studio or WDK installation programs.
You might find this feature useful if you need to integrate the WDK with your build process, or if you want to
distribute the build process in a lab or test environment.
Note You can only use this feature for building drivers and applications that use C and C++. This feature cannot
be used for managed code or UWP apps.
1. Download the Visual Studio and WDK and SDK setup files
To run the set up script that enables this feature, you need to provide the paths to the Visual Studio and WDK
setup files. Be sure to save these files (rather than install them).
1. Download Visual Studio Professional 2013 or Visual Studio Ultimate 2013. Download the Product Layout (for
example, vs_ultimate_download.exe ). When you are asked if you want to run or save
vs_ultimate_download.exe, select Run and then select the download option and specify the download path as
C:\VSSetup (this makes the later steps easier). Select Download to download and install a local copy of the
DVD layout on the computer.
2. Download the standalone SDK. When you are asked if you want to run or save sdksetup.exe, select Run and
then specify the download location as C:\Kits\SDK . Select Next and follow the instructions to download the
standalone SDK.
3. Download the WDK 8.1. When you are asked if you want to run or save wdksetup.exe, select Run and then
specify the download location as C:\Kits\WDK . Select Next and follow the instructions to download the
WDK. If you have already installed the WDK on the computer, the web installation program will tell you that
the features installed on the computer are up-to-date. To download the WDK setup files so that you can
deploy the build environment, select Next and specify the C:\Kits\WDK path.
P O W ERSH EL L
The <VSInstallerFilePath> is the path to the Visual Studio installation program (for example,
Vs_ultimate.exe) and directory that contains the product layout.
The <KitInstallersPath> is the path to the WDK and SDK setup files.
The <Target Directory> is the target directory for the extracted content.
The <LogFilePath> is the target destination for the log file.
<Filename.xml> is the name of the CatalogFile, which contains a list of Microsoft Windows installation
files (MSI) to expand as part of the installation. The name of the file is files.xml.
For example, the following command runs the script from BuildLabSupport directory and installs the
build environment in C:\BuildLabInstall directory.
Related topics
Building a Driver
MSBuild
Using the Microsoft C Runtime with User-Mode
Drivers and Desktop Apps
9/20/2022 • 3 minutes to read • Edit Online
If you are building applications or drivers for Windows 10, you only need to read this section. If you are using a
version of Visual Studio earlier than Visual Studio 2015, skip this section and start with Redistributing the C
Runtime (applies to before Visual Studio 2015).
Starting in Visual Studio 2015, the Universal C Runtime (UCRT) encompasses the C runtime. The other pieces
required for a complete program (C/C++ Language Features, C++ Library) are provided by Visual Studio in the
VC++ Redistributable. To avoid a runtime redistribution requirement, those pieces are statically linked.
WARNING
When building a user-mode driver project in Visual Studio, if you set PlatformToolset to WindowsUserModeDriver10.0 ,
the toolset ignores any runtime library specified in the project and instead links statically against the VC++ Runtime and
dynamically against the UCRT. When using this toolset, this hybrid linking behavior cannot be reconfigured.
If you're not using the WindowsUserModeDriver10.0 toolset, use the following procedure to make modifications
(for example include another DLL):
1. Set to link statically in general: Proper ties > C/C++ > Code Generation > Runtime Librar y = Multi-
threaded (/MT)
2. Remove the statically linked UCRT: Proper ties > Linker > Input > Ignore Specific Default Libraries
+= libucr t.lib
3. Add the dynamically linked UCRT: Proper ties > Linker > Input > Additional Dependencies +=
ucr t.lib , Proper ties > Linker > Input > Ignore Specific Default Libraries += libucr t.lib
Visual Studio installs the latest version of the VCRT into the System32 directory. If the file is not in this location,
you can copy it directly into the build directory of your Visual C++ project.
If your user-mode driver or desktop application uses the VCRT, you must distribute the appropriate dynamic-link
libraries. Use the Visual C++ Redistributable Package ( VCRedist_x86.exe , VCRedist_x64.exe , VCRedist_arm.exe ).
Chain the redistributable package in with other binaries, and the redistributable package will receive automatic
updates.
If you want to achieve isolation or avoid the dependency on the VC++ Redistributable, you can link statically to
the CRT instead. While non-driver projects are usually able to copy the specific Visual C/C++ DLLs to the
application local folder (where the application is installed) to avoid a dependency on the VC++ Redistributable,
app-local deployment is not appropriate for a driver.
Do not copy individual CRT components to System32 instead of using a redistributable package. This may cause
the CRT not to be serviced automatically, and potentially to be overwritten.
The following special considerations apply for printer drivers:
These drivers should include the required CRT files in the INF, so the CRT files are copied to the driver store as
part of the driver payload.
V4 print drivers cannot use a co-installer for setup, so the INF must copy relevant binaries of the C/C++
runtime library to the driver store. To do this, reference the appropriate files in the [COPY_FILES] section of
the driver package.
V3 print drivers should not use co-installers for setup, as they are not run during Point and Print connections.
These drivers should reference the appropriate files in the [COPY_FILES] section of the driver package.
The following is an example of how to include the CRT binaries in the [COPY_FILES] section of an INF:
[COPY_FILES]
;CRT
Msvcr120.dll
; other files
* [SourceDisksFiles]
Msvcr120.dll = 2
; other files
* [SourceDisksNames.amd64]
1 = %Location%,,,
2 = %Location%,,,"amd64"
Msvcr120.dll C runtime
This information is intended for developers and build engineers who compile kernel-mode drivers for Windows.
In Microsoft Visual Studio Professional 2012, the default architecture for the Visual C++ (VC++) compiler
changed from IA32 to the Streaming SIMD Extensions 2 (SSE2) instruction set. As a result of this change, SSE2
floating point (FP) instructions injected into the binary at compile time can generate floating-point errors if not
accounted for. The issue can be encountered by those who use the Microsoft VC++ compiler, or a custom build
environment to develop Windows drivers. However, the issue does not affect developers who use the Microsoft
Visual Studio development environment, or who use the MSbuild utility to build drivers with an unmodified
toolset.
Solution
To avoid these problem with floating-point calculations, add the /kernel flag to the C++ compiler and linker
command lines to prevent generating SSE2 instructions. The /kernel flag changes the default /arch:sse2 value
back to /arch:ia32 .
In addition, if you build a driver using the WDK and the Visual Studio Professional 2012 development
environment, or use MSBuild, in a Visual Studio Command prompt window, the Microsoft provided platform
toolset (WindowsKernelModeDriver8.0 ) sets the /kernel flag. As a result, floating-point generation errors
are avoided.
Recommendations
Here are the recommended solutions based on the type of development environment you use:
Microsoft tool set (MSBuild) - No work required. Use WindowsKernelModeDriver8.0 as the platform
toolset the /kernel is automatically added where appropriate.
Microsoft VC++ Compiler - Add the /kernel flag to prevent compiler from emitting SSE2.
Custom Tooling/Non-Microsoft Compiler - You must manually account for the assembly instructions
used in the resulting binary.
Counters Manifest Preprocessor Properties for
Driver Projects
9/20/2022 • 2 minutes to read • Edit Online
Sets the properties for the CTRPP tool that parses and validates your counters manifest. For information about
working with performance counters, see Performance Counters. For information about using performance
counters in a kernel-mode Windows driver, see Kernel Mode Performance Monitoring.
O P T IO N DESC RIP T IO N
Add Prefix Specifies the prefix to use for the global variables and
functions defined in the generated header file (same as
the -prefix command option.)
Generate header file for containing counter names and Creates a header file that assigns symbols to the counter
GUIDs set names and GUIDs for each counter set in the
manifest.
Generate header file for provider Specifies the name of the header file that the tool
generates. If you do not specify a path, the file is
generated in the current folder.
O P T IO N DESC RIP T IO N
Generate resource file Specifies the name of the resource file that the tool
generates. If you do not specify a path, the file is
generated in the current folder.
Generate Summary Global File Generates a binary counter file per provider. (-
summar y path)
Generates a summary global file GenSumResource.BIN.
Generated Counter Files Path Specifies the path to generate binary counter files. (-
sumPath path)
If no path is specified, the current directory is used.
Header File Name For Counter Generates a header file for containing counter names
and ids. (-ch filename)
Header FileName For Provider Generates a header file for the provider. It replaces the
default name. (-o filename)
Resource File Name Specifies the name for the resource file. This replaces the
default name. (-rc filename)
Comment
The default names of the files that the tool generates are based on the name of the manifest file that you pass to
the CTRPP tool.
Related topics
CTRPP
Performance Counters
Kernel Mode Performance Monitoring
Driver Model Settings Properties for Driver Projects
9/20/2022 • 2 minutes to read • Edit Online
Sets the basic properties for a kernel-mode or user-mode driver, including the WDF library version and
preprocessor definitions.
Related topics
Framework Library Versioning
Building and Loading a Framework-based Driver
UMDF Version History
Building UMDF Drivers
Creating Export Drivers
Message Compiler Properties for Driver Projects
9/20/2022 • 3 minutes to read • Edit Online
Sets the properties for the Message Compiler (MC.exe) tool. The compiler generates the message resource
files that you can add to your project.
For example, if you are using the Event Tracing for Windows (ETW) kernel-mode API to add event tracing to a
kernel-mode driver, you could use the message compiler to create a header file that contains definitions for the
event provider, event attributes, channels, and events. You must include this header file in your source code. The
message compiler creates a resource compiler script (*.rc) that you add to your project file.
O P T IO N DESC RIP T IO N
Ansi Input File Specifies that the input file contains ANSI content (this is
the default). (-a )
Ansi Message In Bin File Specifies that the messages in the output .bin file should
be ANSI. (-A )
Baseline Path The path must point to the folder that contains the .BIN
files that the baseline operation created. (-t directory)
Baseline Resource Path The folder which contains the baseline manifest files. (-s
directory)
Debug Output Path The path in which to place the .dbg C include file. (-x
path)
Enable Callout Macro Adds a callout macro to invoke user code at logging.
Not available for C#, and ignored. (-co )
Enable Debug Output Path Enables the compiler to place the .dbg C include file
specified by the Debug Output Path property.
O P T IO N DESC RIP T IO N
File extension for the generated header Specifies the extension of the generated header file. (-e
extension)
Generate C# (managed) logging class Generates a C# (managed) logging class that includes
methods that you would call to log events in your
manifest. (-cs namespace)
Generate header file for containing counter Use this option to specify the folder into which you want
names and GUIDs the compiler to place the generated header file.
Generate Kernel Mode Logging Macros Generates kernel-mode logging macros. (-km )
Generate MOF File Generate down-level support for all functions and
macros generated. MOF file will be generated from the
manifest. MOF file will be placed in the location specified
by the -h option (-mof ).
Generate static C# (managed) logging class Generates a static C# (managed) logging class that
includes methods that you would call to log events in
your manifest. (-css namespace)
Generate User Mode Logging Macros Generate user-mode logging macros. (-um )
Generated Files Base Name Specifies the base name of all generated files. (-z
basename)
Generated RC and Binar y Message Files Path Specifies the path to the generated the RC and binary
message files.
Header File Path Specifies the path the generated header file. (-h path)
Maximum Message Length Use this argument to have the compiler generate a
warning if any message exceeds length characters. (-m
length)
Prefix Macro Name Use this argument to override the default prefix that the
compiler uses for the logging macro names and method
names. (-p prefix)
O P T IO N DESC RIP T IO N
RC File Path The folder into which you want the compiler to place the
generated resource compiler script (.rc file) and the
generated .bin files. (-r path)
Remove Characters From Symbolic Name Use this argument to remove characters from the
beginning of the symbolic name that you specified for
the event. (-P prefix)
Set Customer Bit Sets the Customer bit in the entire message Ids. (-c)
Terminate Message With Null Terminates all strings with nulls in the message tables. (-
n)
Unicode Input File Specifies that the input file contains Unicode content. (-
u)
The default is ANSI.
Unicode Message In Bin File Specifies that the messages in the output .bin file are
Unicode. (-U )
This is the default.
Use Base Name Of Input Use this argument to have the compiler use the base
name of the input file for the name of the output .bin
files. (-b )
Use Decimal Values Use this argument to use decimal values for the Severity
and Facility constants in the header file instead of
hexadecimal values. (-d )
Validate Against Baseline Resource Use this argument when you create a new version of
your manifest and want to check it for application
compatibility against the baseline that you created using
the -s option.
Related topics
Message Compiler (MC.exe)
WDK and Visual Studio build environment Message compiler task
Event Tracing for Windows (ETW)
MOF Compiler Properties for Driver Projects
9/20/2022 • 2 minutes to read • Edit Online
The Managed Object Format (MOF) compiler (mofcomp.exe) parses MOF files and adds the classes and class
instances defined in the files to the WMI repository. Use the Mofcomp property page to compile MOF files with
your driver. For more information about Mofcomp.exe and WMI, see mofcomp , Compiling MOF Files, and
Compiling a Driver's MOF File.
O P T IO N DESC RIP T IO N
Auto Recover Adds the named MOF file to the list of files compiled
during repository recovery. (-autorecover )
Create Binar y Mof File Requests that the compiler create a binary version of the
MOF file with the name filename without making any
modifications to the WMI repository. (-B: Filename)
Language Neutral Output Name of the language neutral output. (-MOF: Path)
Language Specific Output Name of the language specific output. (-MFL: Path)
O P T IO N DESC RIP T IO N
NamespacePath Requests that the compiler load the MOF file into the
namespace specified as namespacepath. (-
N: namespacepath)
Resource Locale Extracts the localized MOF descriptions from the binary
MOF when used with -ER switch. (-L: ResourceLocale)
Syntax Check Requests that the compiler perform a syntax check only
and print appropriate error messages. No other option
can be used with the Syntax Check option.
WMI Syntax Check Requests that the compiler perform a WMI syntax check
-WMI . If you select this option, you must also select
the Create Binar y Mof File option (-B: Filename)
Related topics
Compiling MOF Files
Compiling a Driver's MOF File
mofcomp
Stampinf Properties for Driver Projects
9/20/2022 • 4 minutes to read • Edit Online
Sets the properties for the Stampinf tool. You can use Stampinf to update common INF and INX file directives
when you build the driver.
Enable VersionStamp Enables the version time stamp. If enabled, the Driver
Version Number must not be empty. The Driver
Version Number specifies the time that is written in
the INF DriverVer directive for the version number. If
not enabled, see the description of the default behavior
for this option under Driver Version Number .
STA M P IN F O P T IO N DESC RIP T IO N
Driver Version Number Specifies the time that is written in the INF DriverVer
directive for the version number. The format for the
time is hours.minutes.seconds.milliseconds (for example,
11.30.20.15). This option is useful during development
because it provides a convenient way to increase the
version number of the driver. This setting is equivalent to
specifying the Stampinf option -v [ time | ] .
To use the current time, specify an asterisk () with this
parameter.
Default behavior:
If the Driver Version Number is not specified, or if
Enable VersionStamp is No or unspecified, Stampinf
uses one of the following version number values:
If the STAMPINF_VERSION environment variable
is set, Stampinf uses the version number value
that is specified by this environment variable.
If the STAMPINF_VERSION environment variable
is not specified, Stampinf extracts the version
number from the ntverp.h file.
Enable DateStamp Enables the date stamp. If enabled, the Driver Version
Directive Date must not be empty. If not enabled, see
the description of the default behavior for this option
under Driver Version Directive Date .
STA M P IN F O P T IO N DESC RIP T IO N
Driver Version Directive Date Specifies the date that is written in the INF DriverVer
directive . The format for the date is month/date/year
(for example, 10/20/2011 ).
To use the current date, specify an asterisk () with this
parameter.
Default behavior:
If the Driver Version Directive Date parameter is not
specified, or if Enable DateStamp is No or unspecified,
Stampinf uses one of the following date values:
If the STAMPINF_DATE environment variable is
set, Stampinf uses the date value that is specified
by this environment variable.
If the STAMPINF_DATE environment variable is
not specified, Stampinf uses the current date.
This setting is equivalent to specifying the Stampinf
option -d [ date|] .
Driver Version Directive Section Specifies the INF section in which to put the INF
DriverVer directive . The default location for this
directive is the INF Version section .
This setting is equivalent to specifying the Stampinf
option -s section.
KMDF Version Number Specifies the version of KMDF that this driver depends
on. This is used to customize the KmdfLibraryVersion
and KMDF co-installer name in the INF file. This option
replaces the $KMDFVERSION$ and
$KMDFCOINSTALLERVERSION$ keywords in the INF file.
The string has the following format:
<major_version>.<minor_version>
For example, if you specify 1.5 as the version string, the
values 1.5 and 01005 are used for the two keywords
(respectively).
This setting is equivalent to specifying the Stampinf
option -k KMDFversion.
STA M P IN F O P T IO N DESC RIP T IO N
UMDF Version Number Specifies the version of UMDF that this driver depends
on. This option is used to specify the
UmdfLibraryVersion and UMDF co-installer name in the
INF file. The version that is specified replaces the
$UMDFVERSION$ and $UMDFCOINSTALLERVERSION$
keywords in the INF file. The version string has the
following format:
<major_version>.<minor_version>.<service_version>
(where <service_version> is typically zero).
For example, if you specify 1.5.0 as the version string,
the values 1.5.0 and 01005 are used for the major and
minor keywords (respectively).
This setting is equivalent to specifying the Stampinf
option -u UMDFversion.
Catalog File Name Specifies the value that is written in the CatalogFile
directive in the INF Version section . By default, the
CatalogFile directive is not written.
This setting is equivalent to specifying the Stampinf
option -c catalogfile.
Version Header Path Specifies the location of Ntverp.h file. The path represent
the fully qualified location of the directory containing
Ntverp.h.
This setting is equivalent to specifying the Stampinf
option -i path.
Related topics
Stampinf
INF DriverVer directive
INF Version section
WDK and Visual Studio build environment
Stampinf task
How to: Use Environment Variables in a Build
Converting WDK 8.1 Projects to WDK 10
9/20/2022 • 2 minutes to read • Edit Online
This topic describes how to convert a driver project that was created using Microsoft Visual Studio 2013 and
Windows Driver Kit (WDK) 8.1 to a driver project that builds in Microsoft Visual Studio 2015 with the Windows
Driver Kit (WDK) 10.
Visual Studio 2015 has new compiler warnings and errors. Even if your driver project built with no errors in
Visual Studio 2013, you might see errors when you build it in Visual Studio 2015.
Use these steps to convert the projects in a driver solution.
1. In Visual Studio 2015, open the legacy driver solution.
Visual Studio automatically runs ProjectUpgradeTool to convert the projects in this solution. You can also
run this tool from the command line. By default, when you install the WDK, ProjectUpgradeTool.exe
installs in Windows Kits\10\bin\x86.
Visual Studio opens a Review Solution Actions dialog with the title Upgrade VC++ Compiler and
Libraries . Select OK and Visual Studio attempts to upgrade all projects in the solution.
If you see a File Modification Detected dialog, choose Reload All .
2. In the Solution Explorer pane, select and hold (or right-click) the driver project name and choose
Proper ties . Select the Configuration Manager button. In the Active solution configuration list,
choose <New...> . Type a name and copy the settings from a Windows 8.1 project context. Select OK .
Typically, the converted solution contains two configuration profiles, one for debug (testing) and one for
release. To create a similar environment with WDK 10, simply choose <New...> twice. To create a debug
profile, copy from the Win 8.1 Debug profile. To create a release profile, copy from the Win 8.1
Release profile.
3. In WDK versions prior to WDK 10, your driver solution always needed a package project. In WDK 10, you
only need a package project if you are including multiple drivers in a driver package. Use the following
guidelines:
If you have only one driver in the solution and a package project exists, delete it.
If you have more than one driver in the solution, ensure that your solution contains a package
project. Then, for each driver project in the solution, open project properties and navigate to
Configuration Proper ties > Driver Settings . Set BuildPackage to No . If you are building
from the command line, set /p:Suppor tsPackaging=false .
4. Again in driver project properties, choose Proper ties . Navigate to Configuration Proper ties >
Driver Settings > General > Target OS Version . Select Windows 10.
Verify that Target Platform is set to Desktop , and build the solution. Fix any errors that occur.
5. Once the solution builds successfully, change Target Platform to Universal .
Build the solution again. At this point, the only errors are from the ApiValidator tool, which checks if the
driver calls any non-universal functionality. Replace any calls to non-universal DDIs with calls to universal
DDIs.
For more information about ApiValidator, see Validating Universal Windows drivers.
To learn how to determine the target platform for a given DDI, see Target platform on driver reference
pages.
Driver convergence model for Windows 10
9/20/2022 • 4 minutes to read • Edit Online
To make your device work on Windows and Windows Phone releases before Windows 10, you probably needed
to write two separate drivers, for example one for Windows 8.1 and one for Windows Phone 8.1. In Windows 10,
in most cases, you can write one driver that will run on any Windows 10 version. This topic describes
convergence plans for device driver interfaces in Windows 10 and provides details when there are version-
specific differences. It answers these questions:
For legacy drivers, will a Windows 8.1 driver work on Windows 10 for desktop editions (Home, Pro, and
Enterprise) and/or Windows 10 Mobile?
For new drivers, can I build one driver with the Windows 10 kit that will work on Windows 10 for desktop
editions and Windows 10 Mobile?
W IN DO W S 8. 1 DRIVER B IN A RY RUN S
T EC H N O LO GY O N W IN DO W S 10? C H A N GES F O R W IN DO W S 10
In the Requirements block at the bottom of Microsoft driver reference pages, you'll see an entry called Target
Platform . This line lists editions of Windows to which the page applies.
Here's an example of such an entry:
The values specified in Target Platform map to the values you can use in Visual Studio, in the Target Platform
property under Configuration Proper ties->Driver Settings->General . Windows Drivers can use any
DDI that specifies Universal as the Target Platform.
Here are the values you might see for Target Platform , and what they mean:
A Windows Driver runs on the following Universal Windows Platform (UWP)-based editions of Windows:
Windows 11
Windows Server 2022
Windows Server 2019
Windows 10 for desktop editions (Home, Pro, and Enterprise)
Windows 10 in S-Mode
Windows 10 IoT Core
Windows Server 2016
Analyzing a Driver Using Code Analysis and
Verification Tools
9/20/2022 • 2 minutes to read • Edit Online
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 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.
You can deploy a driver automatically or manually. In either case, you need to prepare the target computer first.
Here we describe how to prepare the target computer if you choose to deploy your driver manually.
Typically the computer where you install and test a driver is separate from the computer where you develop and
build the driver package. The computer where you build the driver is called the host computer, and the
computer where you install and test the driver is called the target computer or the test computer. The process of
moving the driver package to the target computer and installing the driver it is called deploying the driver.
1. On the target computer, open a Command Prompt window as Administrator. Enter bcdedit /set
TESTSIGNING ON . Reboot the target computer.
2. Copy the DevCon tool to a folder on the target computer (for example, c:\Tools). The DevCon tool is included
in the Windows Driver Kit (WDK). You can find it under the Tools directory (for example, C:\Program Files
(x86)\Windows Kits\10\Tools\x64\devcon.exe).
3. Create or get a certificate (.cer) file that you can install on the target computer. For example, when you build
one of the WDK sample drivers, the build process creates a certificate (.cer) file. The location of the certificate
file varies depending on what you have specified for configuration and platform. For example, if your
configuration is Win7 Debug and your platform is x64, then the certificate file is in your solution folder under
C++\x64\Win7Debug.
4. Copy the certificate file to a folder on your target computer (for example c:\Certificates).
5. On the target computer, select and hold (or right-click) the certificate file, and choose Install . Work through
the installation wizard.
When you build one of the WDK driver samples, the build process creates a test-signing certificate. You need to
install a test-signing certificate only once. If you have installed a certificate from a WDK driver sample, you can
install other driver samples without installing a certificate again.
What happens when you provision a computer
(WDK 8.1)
9/20/2022 • 2 minutes to read • Edit Online
Using Microsoft Visual Studio to configure and set up driver deployment and driver testing is called
provisioning a target computer or provisioning a test computer. For information about provisioning, see
Provision a computer for driver deployment and testing (WDK 8.1). Here we show what happens when you use
version 8.1 of the Windows Driver Kit (WDK) to provision a target computer.
Using Microsoft Visual Studio to configure and set up driver deployment and driver testing is called
provisioning a target computer or provisioning a test computer. For information about provisioning with
Windows Driver Kit (WDK) 8 , see Provision a computer for driver deployment and testing (WDK 8). Here we
show what happens when you use version 8.0 of the Windows Driver Kit (WDK) to provision a target computer.
Note WDK 8 is not the most current version of the WDK. We recommend that you get the current version of
the WDK and provision your target computer according to the provisioning instructions here.
Provisioning a target computer is described in Provision a computer for driver deployment and testing (WDK
8.1). Here we give some troubleshooting tips for the provisioning process.
General tips
Configure Computers menu command is inactive
Provisioning fails
Provisioning fails
The network path was not found
The network name cannot be found
Could not access remote machine
Note The messages that are displayed when you enter an incorrect target computer name can vary. For
example, you might see a message about enabling network discovery.
sxe ld <DriverName>
Note
If you use a driver template to create a driver solution, then the template should automatically create a solution
that contains two projects. One for the driver, and another for the driver package.
You can create a Device Metadata Package for your device directly in Visual Studio. The Device Metadata
Authoring Wizard, located in the Driver menu, allows you to author specific information that appears to end
users in Windows, including the icon and name for your device. It also allows you to associate a UWP device app
to your device, which gets installed automatically when a user first connects the device.
For more information about how to use the Device Metadata Authoring Wizard, please see Device Metadata
Authoring Wizard.
Signing a Driver
9/20/2022 • 2 minutes to read • Edit Online
All drivers running on 64-bit versions of Windows must be signed before Windows will load them. However,
driver signing is not required on 32-bit versions of Windows.
In order to sign a driver, a certificate is required. You can create your own certificate to sign your driver with
during development and testing. However, for a public release you must sign your driver with a certificate
issued by a trusted root authority.
Note A driver package project can package the output of other projects. If you build a driver package project,
Microsoft Visual Studio will build the other projects on which it has dependencies. The driver package project
has its own driver signing properties that are separate from any other dependent projects, and its driver signing
properties apply only to the catalog (if any) produced by the driver package project. That is, the driver package
project will not automatically add an embedded signature to driver binaries produced by other projects, as a
different certificate may be used to sign the other driver projects, for example, a test certificate, and the result in
such a case would be a driver package where the binaries are unintentionally signed with one certificate, while
the package catalog is signed with a different certificate. This can result in performance degradation. For
example, if a boot start driver binary's embedded signature is invalid, Windows cannot use certificate it was
signed with to validate the binary. Instead, Windows must validate the binary against the catalog's signature,
which would increase boot time.
This section describes how to use Visual Studio to sign a driver package.
Signing a Driver During Development and Testing
Signing a Driver for Public Release
Signing a Driver During Development and Testing
9/20/2022 • 2 minutes to read • Edit Online
Before you install a driver on a computer running a 64-bit version of Windows, you must sign the driver
package. For testing purposes, you can test sign the driver package, which is a more relaxed form of signing
than signing for public release.
In Microsoft Visual Studio, test signing is enabled by default. Suppose you have created a KMDF driver solution
as described in Writing a KMDF driver based on a template. When you build the solution, you can see in the
Output window that the driver package has been test signed.
Related topics
Writing Your First Driver
Building a Driver
Developing, Testing, and Deploying Drivers
Signing a Driver for Public Release
9/20/2022 • 6 minutes to read • Edit Online
Before you release a driver package to the public, we recommend that you submit the package for certification.
For more information, see Windows Hardware Certification and Hardware Dashboard Services. To submit a
driver package for certification, you must sign the package with a certificate that you obtain from a trusted
certification authority like VeriSign. For more information, see Get a VeriSign Certificate. You will also need a
cross certificate, which is provided by Microsoft.
Suppose you have obtained a pair of files from Verisign: a private key file (PVK) and a software publishing
certificate (SPC). Also suppose you have a Microsoft Visual Studio solution that contains a driver project named
MyDriver and a driver package project named MyDriver Package. To sign your driver package, follow these
steps.
1. Use the Pvk2Pfx tool to create a Personal Information Exchange (PFX) certificate. The Pvk2Pfx tool takes
your PVK and SPC files as input and creates a single PFX file. For this exercise, assume that your PFX file is
named MyCert.pfx.
Note Once you have created your PFX file, you can reuse it for other driver projects and on other driver
development computers.
2. To determine which cross certificate you need, see Cross-Certificates for Kernel Mode Code Signing.
Verify that the required cross certificate is in $(BASEDIR)\CrossCertificates, where $(BASEDIR) is the base
directory of the Windows kits (for example c:\Program Files (x86)\Windows Kits\8.0\CrossCertificates). If
the required cross certificate is not there, download the cross certificate from Microsoft, and copy it to
$(BASEDIR)\CrossCertificates.
3. In Visual Studio, open the solution that contains the MyDriver and MyDriver Package projects. If the
Solution Explorer window is not already open, choose Solution Explorer from the View menu. In the
Solution Explorer window, select and hold (or right-click) the package project, MyDriver Package , and
choose Proper ties .
4. In the property pages for the package, navigate to Configuration Proper ties > Driver Signing >
General . In the Sign Mode drop-down list, select Production Sign . For Production Cer tificate , do
one of the following:
Enter the path to your signing certificate (for example c:\Certs\MyCert.pfx).
Choose Select From File , and browse to your signing certificate.
Choose Select From Store and choose a certificate that you previously imported into a
certificate store.
Note To import a certificate into a store, select and hold (or right-click) the certificate file (PFX
file), and choose Install PFX . Follow the instructions in the Certificate Import Wizard.
Note If you decide to use a different certificate at a later time, be sure that your new certificate
gets imported into the certificate store. If you choose Select From File and browse to your new
certificate, the new certificate will be automatically imported into the certificate store. However, if
you manually enter the path to your new certificate, it will not be automatically imported into the
certificate store. In that case, you must select and hold (or right-click) your new certificate file and
choose Install PFX .
5. On the Driver Signing > General property page, for TimeStampSer ver , select one of the time stamp
servers in the drop-down list.
Note Using one of the time stamp servers in the drop-down list requires that you be connected to the
Internet when you build your driver package. If you need to be disconnected from the Internet when you
build your driver package, clear the TimeStampSer ver field.
6. In the property pages for the package, navigate to Configuration Proper ties > Inf2Cat > General . In
the Run Inf2Cat drop-down list, select Yes .
7. Close the property pages for the package.
8. Select and hold (or right-click) the driver project, MyDriver , and choose Proper ties
9. In the property pages for the driver, navigate to Configuration Proper ties > Driver Signing >
General . Set TimeStampSer ver to the same value that you used in the driver package properties. Set
Sign Mode to Production Sign , and set Production Cer tificate to the same value that you used in
the driver package properties.
10. When you are ready to build your driver package, press F5 . Visual Studio will automatically sign your
package and your driver file. If you have configured deployment, Visual Studio will also deploy your
signed driver package to a test computer. For more information, see Provision a computer for driver
deployment and testing (WDK 8.1).
Related topics
Driver Signing changes in Windows 10
Availability of SHA-2 Code Signing Support for Windows 7 and Windows Server 2008 R2
Signing a Driver
Windows Hardware Certification
Hardware Dashboard Services
Driver Signing Requirements for Windows
Cross-Certificates for Kernel Mode Code Signing
Kernel-Mode Code Signing Walkthrough
Driver Signing
Installing a Boot-Start Driver
Tools for Signing Drivers
Driver Signing Properties
9/20/2022 • 2 minutes to read • Edit Online
When a project is selected in Solution Explorer, the Proper ties dialog under the Driver Signing node, displays
two sections of properties:
Under General:
Sign Mode
Test Sign - Microsoft Visual Studio should sign the driver with the test certificate specified in Test
Cer tificate (default). If no certificate is specified in Test Cer tificate then Visual Studio will create one for
the driver. Note : Windows requires all 64-bit drivers to be signed.
Production Sign - Visual Studio should sign the driver with the production certificate specified in
Production Cer tificate .
Off - Visual Studio should not sign the driver with any certificate.
Test Cer tificate
Blank - No test certificate is selected (default).
<Edit...> - Selects the certificate to use when Sign Mode is set to Test Sign .
Production Cer tificate
Blank - No production certificate is selected (default).
<Edit...> - Selects the certificate to use when Sign Mode is set to Production Sign .
TimeStampSer ver
Verisign - Use Verisign to time stamp the driver (default).
GlobalSign - Use Globalsign to time stamp the driver.
None - Do not time stamp the driver.
Disable Warnings
No - Display warnings when signing the driver (default).
Yes - Do not display warnings when signing the driver.
Enable Diagnostic Verbosity
No - Do not display diagnostic verbosity when signing the driver (default).
Yes - Display diagnostic verbosity when signing the driver.
File Digest Algorithm
Blank - No file digest algorithm is selected (default).
<Edit...> - Select the file digest algorithm to use when signing the driver.
Taking advantage of the Visual Studio development environment, the WDK provides a test feature that enables
you to build, deploy, and debug a driver on a test computer. To successfully deploy a driver to a test system
using the WDK, you must first set up and configure a test computer. You can set up and configure multiple
computers if you want to test your driver under different testing scenarios.
You can configure the automatic deployment of a driver package on a remote test computer in each
configuration of your project. From the project property pages for your driver, you have additional control over
how you want to deploy your driver for testing. You can choose to deploy the driver automatically whenever you
build the driver solution in each configuration. For more information about deployment, see Provision a
computer for driver deployment and testing (WDK 8.1) and Deploying a Driver to a Test Computer.
Enabling deployment
You can choose to deploy your driver package on a test computer by selecting Enable deployment . In
combination with the configuration list, you could choose to disable deployment for debug builds and enable it
for release builds.
To ensure that you are testing the latest version of the driver, select Remove previous driver versions
before deployment .
Additional Files
You can use the Additional Files box to specify custom installation scripts or applications that you want to
copy to the remote test computer. The files that you specify here are added to the
%Systemdrive%\drivertest\drivers folder on the remote computer.
Related topics
Deploying a Driver to a Test Computer
How to test a driver at runtime using Visual Studio
Getting Started with Windows Debugging
Driver Verifier Properties for Driver Package
Projects
9/20/2022 • 5 minutes to read • Edit Online
Driver Verifier is a run-time verification tool that increases the effectiveness of your driver testing. You can
enable and configure Driver Verifier to run on all test computers when you deploy your driver for testing.
You should always set up a kernel mode debugging connection with the test computer when you enable Driver
Verifier on the remote test computer. For information about configuring a target computer and setting up a
debug cable, see Getting Started with Windows Debugging.
Verify Drivers
Specifies which driver or drivers to verify on the test computer.
All Drivers
Specifies that Driver Verifier verifies all installed drivers on the remote test computer.
Project Output
Specifies that Driver Verifier verifies the driver project installed on the remote test computer. This is the default
option.
Driver List
Specifies the driver or list of drivers that Driver Verifier verifies on the remote test computer. For example, you
could list all of the drivers associated with a particular device. Specify the drivers by binary name, for example,
Driver.sys. Use a semicolon to separate a list of drivers. Wildcard values, such as n*.sys, are not supported.
Driver Verifier Standard Flags
You can configure the following Driver Verifier options on the test computer.
DDI compliance checking (Windows 8)
When this option is active, Driver Verifier applies a set of device driver interface (DDI) rules that check for
the proper interaction between a driver and the kernel interface of the operating system.
Deadlock detection
When this option is active, Driver Verifier monitors the driver's use of spin locks, mutexes, and fast
mutexes. This detects whether the driver's code has the potential for causing a deadlock at some point.
DMA verification
When this option is active, Driver Verifier monitors the driver's use of direct memory access (DMA)
routines. This detects improper use of DMA buffers, adapters, and map registers.
Force IRQL checking
When this option is active, Driver Verifier places extreme memory pressure on the driver by invalidating
pageable code. If the driver attempts to access paged memory at the wrong IRQL or while holding a spin
lock, Driver Verifier detects this behavior.
I/O verification
When this option is active, Driver Verifier allocates the driver's Interrupt Request Packets (IRPs) from a
special pool, and monitors the driver's I/O handling. This detects illegal or inconsistent use of I/O
routines. Driver Verifier also monitors the calls of several I/O Manager routines and performs stress
testing of Plug-and-Play (PnP) IRPs, power IRPs and WMI IRPs.
Miscellaneous checks
When this option is active, Driver Verifier looks for common causes of driver crashes, such as the
mishandling of freed memory.
Pool tracking
When this option is active, Driver Verifier checks to see whether the driver has freed all of its memory
allocations when it is unloaded. This reveals memory leaks.
Security checks
When this option is active, Driver Verifier looks for common errors that can result in security
vulnerabilities, such as a reference to user-mode addresses by kernel-mode routines.
Special pool checking
When this option is active, Driver Verifier allocates most of the driver's memory requests from a special
pool. This special pool is monitored for memory overruns, memory underruns, and memory that is
accessed after it is freed.
Related topics
Driver Verifier
How to test a driver at runtime using Visual Studio
Deploying a Driver to a Test Computer
Getting Started with Windows Debugging
KMDF Verifier Properties for Driver Package
Projects
9/20/2022 • 2 minutes to read • Edit Online
Sets the properties for the KMDF Verifier (or framework verifier) on a remote computer. You can use these
settings when you build and deploy a KMDF driver to a test computer. For information about KMDF drivers, see
Kernel-Mode Driver Framework.
For more information about the framework verifier, see Using the Framework's Verifier and WDF Verifier
Control Application.
O P T IO N DESC RIP T IO N
Enable KMDF Verifier Enables the KMDF verifier on the test computer. The
choices are KMDF verifier is always on or KMDF
verifier is off . If the KMDF verifier is not enabled, basic
framework verification is enabled as part of Driver
Verifier if KMDF version is 1.9 or higher.
KMDF Ser vice Names Specifies the service names of the KDMF drivers to
monitor.
IRQL checks Enables IRQL checks and critical memory leak checks.
For ward Compatible Checks Enables checks created after the current driver version.
For ward Progress Handler Testing Specifies options for testing forward progress handling
of your driver.
No Allocation Failures No faults will be simulated to
test the forward progress handling of your driver.
Fail All Allocations All I/O requests destined for a
forward progress queue will appear to fail, relying on
your driver's forward progress handling.
Randomly Fail Allocations Randomly fail I/O requests
destined for a forward progress queue.
O P T IO N DESC RIP T IO N
Track KMDF Object Handles Specifies the list of object handle types to track.
Enable KMDF Loader Messages Enables KMDF loader messages through the debugger.
A reboot of the target computer is required to enable
this.
Starting with Windows Vista, the operating system
suppresses DbgPrint output by default, which makes the
WDF Loader diagnostic messages unusable until the
suppression is overridden. KDMF Verifier can manage
this for you so that KMDF loader diagnostics are
available in the kernel debugger for these systems.
Memor y Pages for Logs Specifies the number of non-paged pool pages (1-10) to
allocate for kernel event trace logs. The options are
Runtime Choice or [1 -10 ]. If Runtime Choice , the
number of pages depends on the KMDF runtime.
Starting with KMDF 1.9, the runtime uses more pages
when verification is enabled with verbose logging.
Related topics
Kernel-Mode Driver Framework
Driver Verifier
Deploying a Driver to a Test Computer
UMDF Verifier Properties for Driver Package
Projects
9/20/2022 • 2 minutes to read • Edit Online
Sets the properties for the UMDF Verifier on a test computer. You can use these settings when you build and
deploy a driver to a test computer.
For information about deployment, see Provision a computer for driver deployment and testing (WDK 8.1) and
Deploying a Driver to a Test Computer
For information about debugging UMDF drivers, see How to Enable Debugging of a UMDF Driver and WDF
Verifier Control Application.
O P T IO N DESC RIP T IO N
Deploy UMDF Verifier Enables the UMDF verifier settings on the test computer.
UMDF Ser vice Names Specifies the service names of the UMDF drivers to
monitor.
Maximum Restar t Attempts Maximum number of times UMDF will restart a failed
host process.
O P T IO N DESC RIP T IO N
Break into Kernel Debugger Break into kernel debugger when the UMDF host
process fails.
Timeout on Driver Load (sec) Specifies the time to wait (in seconds) before attaching
the debugger after the driver loads.
Timeout on Driver Star t (sec) Specifies the time to wait (in seconds) before attaching
the debugger after the driver starts.
Verify at Current Level Verifies drivers built using earlier versions of the
framework against current framework versions rules.
Related topics
User-Mode Driver Framework
Driver Verifier
Deploying a Driver to a Test Computer
Inf2Cat Properties for Driver Package Projects
9/20/2022 • 2 minutes to read • Edit Online
Sets the properties for the Inf2Cat tool. The Inf2Cat tool can be used to create catalog files for any driver
package that has an INF file.
O P T IO N DESC RIP T IO N
Run Inf2Cat Runs the Inf2Cat tool on any INF files in the project (for
example, .inf, .inx, or .inv files).
Windows Version List Specifies a list of Windows versions supported by the .inf
file. Separate each Windows version with a comma. The
default setting is $(Inf2CatWindowsVersionList), a macro
that builds the driver for the active platform and
configuration.
This setting is equivalent to specifying the Inf2Cat
option /os: WindowsVersionList.
Include Page Hashes Include page hashes with files. Optionally followed by a
list of files.
This setting is equivalent to specifying the Inf2Cat
option /pageHashes[: file1][, file2]...] .
Use Local Time Use the local time zone while verifying the INF
DriverVer Directive directive. By default UTC, is used.
This setting is equivalent to specifying the Inf2Cat
option /uselocaltime .
For more information about the Inf2Cat tool, see Using Inf2Cat to Create a Catalog File.
For information about property pages and projects, see the WDK and Visual Studio build environment.
Related topics
Creating a Catalog File for a PnP Driver Package
Inf2Cat
Creating a Driver Package
Signing a Driver
Using Inf2Cat to Create a Catalog File
WDK and Visual Studio build environment
How to create a custom driver installation script
9/20/2022 • 2 minutes to read • Edit Online
If your deployment scenario requires more than installing the driver package on the test computers, you can
choose to run your own custom command scripts upon installation.
Prerequisites
Driver package that is test signed and ready to install. You must first create and build your driver and then
create a driver package for installation. For more information, see Building a Driver and Creating a Driver
Package.
Test computers that are configured and provisioned for deployment. See How to test a driver at runtime
using Visual Studio.
Instructions
Step 1: To run your own custom command scripts upon installation
From the project property pages for your driver package, you can configure whether you want to automatically
deploy a driver package on a test computer. You can also run a custom installation script from these pages. You
can choose to deploy the driver automatically whenever you build the driver solution in each configuration. For
more information about deployment, see Deploying a Driver to a Test Computer and Deployment Properties for
Driver Projects.
1. Open the property pages for your driver package project. Select and hold (or right-click) the driver
project in Solution Explorer and select Proper ties .
2. In the property pages for the driver package, select Configuration Proper ties , select Driver Settings ,
and then select Deployment .
3. Select Enable deployment and then select the test computer to use.
4. Select Custom Command Line . In the box, type custom command scripts that you want to run upon
installation.
5. In the Additional Files text box, add the command script and other installation files to be copied to the
test computer. When the driver is deployed, the additional files are copied to the
%Systemdrive%\drivertest\drivers folder on the remote computer.
Related topics
Deploying a Driver to a Test Computer
Deployment Properties for Driver Projects
How to test a driver at runtime using Visual Studio
Building a Driver
Creating a Driver Package
Installing a driver on Windows 10 Mobile
9/20/2022 • 2 minutes to read • Edit Online
To install a driver on Windows 10 Mobile, use an .spkg file. An .spkg ("package file") is a standalone module that
contains your driver package.
WDK 10 includes PkgGen, a tool that generates package files. You run PkgGen in Visual Studio when you build
your driver, using the following procedure.
Using PkgGen to generate a package file
1. Select and hold (or right-click) the driver project and choose Add->New Item . Next, under Visual C++-
>Windows Driver , choose Package Manifest . Select Add .
2. Visual Studio adds a file called Package.pkg.xml to your driver project. You can select and hold (or right-click)
the file and choose properties to verify that the item type is PkgGen . (On this same property page, you can
set Excluded from Build to Yes if you decide later that you want to build this driver project and not
generate a package file.) Select OK .
3. Select and hold (or right-click) the driver project and choose Proper ties . Under Configuration Properties,
open the PackageGen node and change Version to any value you like.
4. Save your work and restart Visual Studio as administrator.
5. Build your driver. Visual Studio links against the required libraries and generates a .cat file, an .inf file, a driver
binary, and an .spkg file.
To view the contents of the package file, append a .cab suffix to the file name and then open the cab file in
Windows Explorer.
To learn about running PkgGen outside of Visual Studio, see Creating mobile packages.
To install a mobile driver package (.spkg file), you have two options.
If you are updating an existing package on a target system or adding a new package to the target, use
IUTool.exe to install an .spkg driver package.
If you are combining packages into a mobile OS image, use ImgGen to add the .spkg driver package to a full
flash update (FFU) image that can then be flashed to a mobile device.
Using IUTool to add a mobile driver package (.spkg) to a running device
1. IUTool.exe is in the \tools\bin\<architecture> subdirectory of WDK 10.
Attach your mobile device to the PC. Then, from an elevated command prompt, issue the following
command:
IUTool -p MyKmdfDriver.spkg
Debugging a kernel-mode driver requires two computers. The debugger runs on the host computer, and the
code being debugged runs on the target computer. The target computer is also called the test computer. You can
debug a user-mode driver on the host computer or on a separate target computer. Before you can debug a
driver running on a target computer, you must configure the target computer for debugging.
For general information about debugging drivers, see Getting Started with Windows Debugging.
For information about configuring a target computer and setting up a debug cable using a network connection,
see Setting Up KDNET Network Kernel Debugging Automatically.
See Also
Windows Debugging.
Testing a Driver
9/20/2022 • 2 minutes to read • Edit Online
The WDK adds a driver testing interface to Visual Studio that allows you to build, deploy, install, and test a driver
on a remote test computer on your network. The WDK also provides a collection of device driver tests that you
can use to test features and functions of your driver. You can also write customize or write your own driver tests
using the Driver Test Template in Visual Studio.
Video Demonstration
This video demonstrates the how to run driver-related tests in a test group.
This section describes some strategies for testing driver, and information about how you select and configure a
remote computer to use for testing.
To prepare a driver for public distribution, you should run the Windows Hardware Certification Kit (HCK). For
information about the Windows Certification program and how to obtain the HCK, see Windows Hardware
Certification Program.
The WDK provides the test binaries and tools which make it easy to run the Device Fundamentals tests from the
command-line. For more information, see Run the DevFund Tests via the command-line.
TO P IC DESC RIP T IO N
Tips for testing drivers during development When should you star t testing? As soon as you
have the requirements for your driver, you can begin to
design test cases to test that the critical requirements
have been implemented. Studies show that finding and
fixing defects in code becomes more expensive the
longer the defects remain in the code. Finding and fixing
defects early in the development cycle is less costly and
disruptive than finding defects after the code has been
released and distributed. Creating your test cases early
can also help you find problems in your design.
How to test a driver at runtime using Visual Studio The WDK extensions to Visual Studio provide a device
testing interface that enables you to conveniently build,
deploy, install, and test a driver on a test computer on
your network. The WDK provides a collection of device
driver tests that you can use to test the features and
functions of your driver.
How to write a driver test using a Driver Test template You can use the Windows Driver Kit (WDK) for
Windows 8 to create your own driver tests or to
customize some of the tests that are provided. You can
deploy the tests that you create to remote test
computers using the driver testing framework that the
WDK provides for Microsoft Visual Studio Ultimate 2012.
See Also
Tools for Verifying Drivers
Tips for testing drivers during development
9/20/2022 • 4 minutes to read • Edit Online
When should you star t testing? As soon as you have the requirements for your driver, you can begin to
design test cases to test that the critical requirements have been implemented. Studies show that finding and
fixing defects in code becomes more expensive the longer the defects remain in the code. Finding and fixing
defects early in the development cycle is less costly and disruptive than finding defects after the code has been
released and distributed. Creating your test cases early can also help you find problems in your design.
The WDK extensions to Visual Studio provide a device testing interface that enables you to conveniently build,
deploy, install, and test a driver on a test computer on your network. The WDK provides a collection of device
driver tests that you can use to test the features and functions of your driver.
Prerequisites
A Driver Package that is ready to install. You must first create and build your driver. Starting in Windows 10
WDK versions, a Driver Package is automatically created for installation. For more information, see Building a
Driver.
The driver must be test signed. For more information, see Signing a Driver.
A test computer (or computers). The test computer must be on the same network as the computer that you
are using for development. Both computers must be connected to the same domain, or both connected to
the network under the same workgroup. The test computer should be running the version of Windows that
you want to target for testing.
A device to be tested.
(Recommended) Set up a kernel mode debugging connection to the test computer. To use a network
connection for kernel mode debugging, the target computer must be running Windows 8. On computers
running Windows 7 or Windows Vista, you can set up a USB, 1394, or a serial connection for kernel mode
debugging. For more information, see Provision a computer for driver deployment and testing (WDK 8.1).
Instructions
Step 1: Configure computers for testing
From Visual Studio, you can configure and provision computers for testing. When you configure the test
computers, the WDK driver test framework automatically enables the test computer for remote debugging and
transfers the necessary test binaries and support files.
1. If you have not already done so, follow the instructions to Provision a computer for driver deployment and
testing (WDK 8.1).
2. Connect the device that you want to test to the test computer or computers.
After you have configured and provisioned a test computer, you can use Visual Studio to deploy drivers,
schedule tests, and debug drivers on the test computer. For information about deployment and about how you
can deploy a driver automatically at build time, see Deploying a Driver to a Test Computer.
You can also enable and set options for Driver Verifier, the runtime verification tool for drivers. Driver Verifier
monitors your driver as you run tests on the test computer. For information about setting the Driver Verifier
options for deployment, see Driver Verifier Properties for Driver Projects.
You can also run tests outside of Visual Studio, for more information see How to test a driver at runtime from a
Command Prompt. Starting in WDK 8.1, you can copy and run the HCK Test Suites on test computers using
command scripts. See How to run the HCK Test Suites in WDK 8.1.
Step 2: Select an HCK Test Suite to run on the test computer (using WDK 8.1)
Starting with WDK 8.1, you can select HCK Test Suites to run on the test computer. The HCK Test Suites include
the Device Fundamentals Tests, and Windows Hardware Certification kit (HCK) Basic tests for graphics, imaging,
wireless LAN, mobile broadband (CDMA and GSM), and WiFi Direct devices.
See How to run the HCK Test Suites in WDK 8.1.
Step 3: Select the tests to run on the test computer (WDK 8 and WDK 8.1)
To make driver testing on different test targets easier, tests are scheduled to run against test systems in units
called test groups. A driver test group is a collection of tests that you select to run on the test computer. The
driver test groups help you organize your tests and test results from each test pass. You can save your test
results to separate folders. You can create and manage test groups, change parameters passed to the tests in the
test groups, and schedule them to run against your test systems.
1. From the Driver menu, select Test and then select Test Group Explorer .
2. In the Driver Test Group Explorer window, select the Create a new test group button. Or, select
New Test Group from the Driver menu.
3. In the Driver Test Group window for the group that you created, type a name in Test Group Name
text box to identify the group. The default name is Driver Test Group_nnnnn, where nnnnn represents the
number of the test group
4. Select Add/Remove Tests .
5. In the Add or Remove Driver Tests dialog box, you can specify the driver test category and
architecture (All, x86, x64, Arm). By default all tests are shown. To view the test categories, select the
folders in the Driver Test Categories drop-down list.
For example, in WDK 8, to select all of the Device Fundamentals tests that are used in the Windows
Hardware Certification Kit (HCK), select All Tests , Cer tification , and Device Fundamentals . For
information about the tests, see How to select and configure the Device Fundamentals Tests.
In WDK 8.1, the Device Fundamentals tests are under All Tests , HCK Tests , Cer tification , and Device
Fundamentals folder. In WDK 8.1 the Driver Test Categories include the HCK (Basic) Tests. See How to
run the HCK Test Suites in WDK 8.1 for more information.
6. Be sure that you select the tests that match the architecture of the intended test computer (x86, x64, Arm).
Use the Architecture Filter to show only those tests that will run on your test computer.
7. Select >> to add the selected tests.
Step 4: Configure test parameters
After you select the tests for your test group, you can configure any of the runtime parameters that are passed
to the driver tests. For example, many of the Device Fundamentals Tests have a parameter DQ, which stands for
Device Query. This is a Simple Data Evaluation Language (SDEL) query. The Windows Driver Test Framework
provides SDEL as a query language to simplify the task of collecting targets based on attributes or relationships.
For example, to run the tests for USB devices only, use the device query: class='usb'. You can change the value of
each test parameter in the test group.
1. You can view and edit the all of the runtime test parameters for a test by selecting on the name of the test
in the Driver Test Group window. The Driver Test Group window provides a description of the
selected test and also provides a description of the test parameters that you select. For information about
setting the test parameters, see How to select and configure the Device Fundamentals Tests
2. After you select the tests, set the parameters, and name the group, select Save .
When you save the test group, the test group will become the currently selected test group, and the name
of the test group will appear in the Driver Test toolbar. You can now run tests against the currently
selected remote test computer (also shown in the Driver Test toolbar).
Step 5: Build and deploy the driver
From the Build menu, select Deploy Solution .
For information about deploying a driver automatically at build time, see Deploying a Driver to a Test Computer.
For information about automatically setting the Driver Verifier options on the test computer, see Driver Verifier
Properties for Driver Projects. You should always enable Driver Verifier on your test computer.
Step 6: Run the tests on the test computer
From the Driver menu, select Test > Run test . By default, the Run test command runs all of the tests in the
currently selected test group.
Remarks
For information about the driver tests and test categories, see How to select and configure the Device
Fundamentals Tests. For information about the testing framework, see Test Authoring and Execution Framework
(TAEF) and Windows Driver Test Framework (WDTF).
You can write your own driver tests and deploy those tests on test computers. For more information, see How to
write a driver test.
Running the Device Fundamentals tests in Visual Studio early in the development cycle will help you when are
finally ready to test your driver using the Windows Hardware Certification Kit (HCK).
Related topics
How to run the HCK Test Suites in WDK 8.1
How to select and configure the Device Fundamentals Tests
Deploying a Driver to a Test Computer
Getting Started with Windows Debugging
Hardware Certification Program
Windows Hardware Certification Kit (HCK)
How to test a driver at runtime from a Command Prompt
How to run the HCK Test Suites in WDK 8.1
9/20/2022 • 7 minutes to read • Edit Online
To make testing Windows drivers easier in the WDK, starting with WDK 8.1 you can now select HCK test suites to
run on the test computers. The HCK test suites include the device fundamentals tests, and tests for graphics,
imaging, wireless LAN, mobile broadband (CDMA and GSM), and WiFi Direct devices. These are the same tests
that are used in the Windows Hardware Certification kit (Windows HCK). See Windows Certification Program
for Hardware for information about the Windows HCK.
You can run the HCK test from a Command Prompt window or from Visual Studio. In addition, you can copy
these tests to a new location—which might be another computer or a USB key drive—and run the tests from
that location. Launching the tests automatically sets any local configuration needed to run the tests.
Running the HCK Test Suites on a test computer using Visual Studio
Running the HCK Test Suites from a Command Prompt window
Running the HCK Test Suites on a test computer using Visual Studio
If you have not already done so, follow the instructions in Provision a computer for driver deployment and
testing (WDK 8.1). After you have configured a test computer, the name of the test computer appears in the
toolbar. Be sure you have select the test computer that you have configured for device you are testing with the
HCK Test Suite.
Prepare the test computer as needed, by installing the device and driver and any additional requirements for
test topology (see the HCK test prerequisites for the device you are testing). In place of the HCK Studio and HCK
controller, you run the tests using Visual Studio and WDK 8.1.
To select an HCK Test Suite to run on a test computer
1. From the Driver menu, select Test and then select Test Group Explorer .
2. In the Driver Test Group Explorer window, select one of the HCK Test Suites.
When you select a Test Suite, the Test Suite appears in the Driver Test Group window.
3. Be sure you have selected the test computer that you have configured for device you are testing with the
HCK Test Suite.
4. To use the HCK test suites, you must also follow the configuration requirements for the device you are
testing.
5. You can use the check boxes to select the tests that match the architecture of the intended test computer
(x86, x64, Arm).
6. From the Driver menu, select Test > Run test . By default, the Run test command runs all of the tests in
the currently selected test group.
You can also copy one of the provided HCK Test Suites and export it, along with the necessary test support files
so that you can run the test suite from a Command Prompt window.
To expor t a Test Suite
1. In the Test Group Explorer , select and hold (or right-click) the HCK Test Suite you want to copy and select
Expor t Test Suite... from the short-cut menu. (The command runs the CopyMe.cmd script).
2. Select a destination folder for the test suite. You can export the test suite to a network share or to a USB flash
drive.
3. To run the HCK Test Suite, open a Command Prompt window on the test computer with elevated permissions.
Navigate to the destination directory and run the RunMe.cmd script. For more information, see To run the
HCK Test Suite from a Command Prompt window.
Run on any computer using an administrator command prompt in the same folder as
the RunMe.cmd script.
"RunMe.cmd <infFileName>"
Note If the test computer is running Windows 7, you need to download and install the Microsoft .NET
Framework 4.5 before you can run the HCK Test Suite.
To run the HCK Test Suite from a Command Prompt window
1. On the test computer that you have configured for testing, open a Command Prompt window with
elevated privileges (Run as administrator ) and navigate to the directory where you copied the HCK
Test Suite.
2. Run the RunMe.cmd script and specify the path and name of the INF file. The script has the following
syntax:
RunMe.cmd infFileName
For example:
RunMe.cmd myDriver.inf
Note The Device.Graphics test suite does not make use of an INF file, however, the RunMe.cmd script
requires an INF file. You can provide the name of substitute INF file if necessary.
Test descriptions DF - PNP (disable and enable) with IO Before and After
(Basic)
DF - Sleep with IO Before and After (Basic)
Hardware, software, and test requirements Graphic Adapter or Chipset Testing Prerequisites
HCK
T EST S. B A SIC . DEVIC E. N ET W O RK . M O B IL EB RO A DB A N D. C DM A
T EST SUIT E
HCK
T EST S. B A SIC . DEVIC E. N ET W O RK . M O B IL EB RO A DB A N D. GSM
T EST SUIT E
Hardware, software, and test requirements Wireless LAN (802.11) Testing Prerequisites
Related topics
How to test a driver a runtime using Visual Studio
How to select and configure the Device Fundamentals Tests
Deploying a Driver to a Test Computer
Getting Started with Windows Debugging
Hardware Certification Program
Windows Hardware Certification Kit (HCK)
How to test a driver at runtime from a Command Prompt
How to select and configure the Device
Fundamentals tests
9/20/2022 • 8 minutes to read • Edit Online
The WDK for Windows 8 provides a driver testing framework that includes a set of tests called the Device
Fundamentals tests. The Device Fundamentals tests are a collection of tests that are used both internally at
Microsoft for testing the drivers and driver samples that ship with Windows and the WDK, and externally as part
of the Windows Certification Program for Hardware. You can run the tests from your development environment.
When you run the tests, you can use the same parameters that are used for Windows Certification testing, or
you can configure and customize the run-time parameters according to your testing and debugging needs.
DoPoolCheck True or False. Monitors the driver's use of the paged and
nonpaged system memory pools by using pool tags and
lookaside lists. This option also monitors changes in the
number of exceptions handled which might indicate
errors in exception handling.
FillZeroPageWithNull True or False. Maps the zero page and fills it with NULL
values. This test identifies drivers that do not verify a
pointer reference before dereferencing the pointer.
PingPongPeriod Specifies the ping pong period in minutes; the time the
processor alternates between high (HPU) and low (LPU)
processor utilization levels.
ResumeDelay The delay time (in seconds) after the machine resumes
from sleep mode and before the next I/O cycle starts.
The delay time is necessary to allow devices to restore
their working state (renew IP address for network card
and so on).
Utility tests
T EST DESC RIP T IO N
Display devices that have WDTF Simple I/O plug-ins Parameters: None
Driver Verifier
T EST DESC RIP T IO N
Enable Driver Verifier You can use this test to enable Driver Verifier for all
drivers of a device (or devices) on the test computer.
Parameters: - See Driver Verifier Options.
Related topics
How to How to test a driver at runtime using Visual Studio
Device Fundamentals Tests
Provided WDTF Simple I/O plug-ins
How to customize I/O for your device using the WDTF Simple I/O Action Plug-in
How to test a driver package
9/20/2022 • 2 minutes to read • Edit Online
You can use Visual Studio to deploy and install a driver package on a test computer, and then verify that the
driver is installed and running.
Prerequisites
A driver package that is ready to install. You must first create and build your driver and then create a driver
package for installation. For more information, see Building a Driver and Creating a Driver Package.
If you have not already done so, follow the instructions to Provision a computer for driver deployment and
testing (WDK 8.1).
After you have configured and provisioned a test computer, you can use Visual Studio to deploy drivers,
schedule tests, and debug drivers on the test computer. For information about deployment and about how
you can deploy a driver automatically at build time, see Deploying a Driver to a Test Computer.
Instructions
Step 1: To test the driver installation on a test computer
After you have configured and provisioned a test computer, you can configure the driver package project so that
it is automatically deployed and installed on the test computer.
1. Open the property pages for your driver project. select and hold (or right-click) the driver project in Solution
Explorer and select Proper ties .
2. In the property pages for the driver, select Configuration Proper ties , select Driver Install , and then select
Deployment .
3. Select the Enable deployment option. For more information, see Deployment Properties for Driver
Projects.
4. Select the test computer you have configured as the Remote Computer .
5. Under Driver Installation Options , select Install and Verify , and then select the Default Driver
Installation Task .
Related topics
Provision a computer for driver deployment and testing (WDK 8.1)
Deploying a Driver to a Test Computer
Testing a Driver
How to read the driver test results log
9/20/2022 • 2 minutes to read • Edit Online
From the Driver Test Group Explorer , you can display the results from driver tests, save the test results to a
folder, or load the results from a folder.
Open the test results
1. In the Driver Test Group Explorer window, select the Driver Test Group you are interested in.
2. Select the results from a specific test run.
The results for the test group are shown as a folder titled Results ( computer - date:time)
3. The results for the tests in that test run are listed. Select the name of the test to view the results log.
The results log provides a summary of the tests that were run, along with the details generated by the test cases.
The information recorded included the time and date that each test was run, the name of the remote test
computer that ran the test, and the test results (number of tests run, passed, failed).
The WDK provides device testing components that enable you to test a driver on a test computer on your
network. You can use these components outside of Visual Studio by copying and installing the necessary files.
You can use these components to run the same collection of device driver tests that are available in Visual Studio
to test the features and functions of your driver.
Starting in WDK 8.1, you can copy and run the HCK Test Suites on test computers using command scripts. See
How to run the HCK Test Suites in WDK 8.1.
Prerequisites
Install Visual Studio and the WDK on the computer you use for development.
From Visual Studio, you can configure and provision computers for testing. When you configure the test
computer, the WDK driver test framework automatically enables the test computer for remote debugging
and transfers the necessary test binaries and support files. If you have not already done so, follow the
instructions in Provision a computer for driver deployment and testing (WDK 8.1)
Although it is not recommended, you can also install the necessary test components manually. Follow the
instructions to install the Test Authoring and Execution Framework (TAEF) and WDTF on the test computer.
See Manually installing and uninstalling TAEF on a test computer and WDTF Quick Start.
Instructions
Step 1: Copy the tests to the test computer
Copy the Device Fundamentals Tests from the computer you use for development. Copy the folder
%ProgramFiles%\Windows Kits\8.0\Testing\Tests\Device Fundamentals to the test computer.
Step 2: Run the tests
The TAEF command to run the tests uses the following syntax:
Remarks
You must specify the test binary (.dll) or script (.wsc) file. The test method (/name:<test method>) is optional.
For the test names and test methods, see the Device Fundamentals Tests. For information about specifying test
parameters, see Device Fundamentals Test Parameters and Te.exe Command Options .
For example, to run all PnP tests in the Devfund_PnPDTest.dll on a device with a specific device ID.
For example, to run PnP Surprise Remove test on a device with a specific device ID.
Te.exe /name:"*PNPSurpriseRemoveAndRestartDevice" Devfund_PnPDTest.dll
/P:"DQ=DeviceID='USB\ROOT_HUB\4&1CD5D022&0'"
Related topics
Device Fundamentals Tests
Device Fundamentals Test Parameters
How to run the HCK Test Suites in WDK 8.1
Test Authoring and Execution Framework (TAEF)
Te.exe Command Options
How to write a driver test using a Driver Test
template
9/20/2022 • 4 minutes to read • Edit Online
NOTE
This topic describes functionality that is only available in Visual Studio 2013. For info on previous WDK and Visual Studio
editions, see Other WDK downloads.
You can use the Windows Driver Kit (WDK) for Windows 8 to create your own driver tests or to customize some
of the tests that are provided. You can deploy the tests that you create to remote test computers using the driver
testing framework that the WDK provides for Microsoft Visual Studio Ultimate 2012.
The WDK provides templates that create starter code for a Windows Driver test project in C++, C#, and Script
(JScript). You can select the test cases that you want to include, or you can start with a blank project. You can
customize the code to add new test cases for your driver. You can deploy your tests from Visual Studio using the
driver test framework.
To customize a driver test using the Driver Test template for C++
1. From the File menu, select New > Project .
2. From the list of installed templates in the New Project dialog box, select Visual C++ > Windows Driver
> Tests .
3. Select Windows Driver Test in C++ .
4. Provide a name for your driver test project and a location (or use the default).
5. From the Windows Driver Test dialog box, select the test cases that you want to include or choose an
empty (blank) driver test. For more information about the test cases, see Windows Driver test cases.
6. Add the required test metadata. For more information, see How to add test metadata.
7. Build your driver test.
To customize a driver test using the Driver Test template for Script
1. From the File menu, select New > Project .
2. From the list of installed templates in the New Project dialog box, select Script > Windows Driver .
3. Select Windows Driver Test Script .
4. Provide a name for your driver test project and a location (or use the default).
5. From the Windows Driver Test dialog box, select the test cases that you want to include or choose an
empty (blank) driver test. For information about the test cases, see Windows Driver test cases.
6. Add the required test metadata. For more information, see How to add test metadata.
7. Build your driver test.
Making the driver tests you create available for deployment on test
computers
When you build your driver test, the new test will be available for deployment to a test computer. By default, the
tests that you create will appear in the test category My Test Categor y . The names of the tests are based upon
the test cases that you choose, and they will have names such as My Plug and Play Surprise Remove Test .
During each build of the test, the test will be overwritten. The latest build of the test will be available to deploy
and run on the test computer.
Disable/Enable Provides code for test cases that disable and enable a PnP
device.
Remove Provides code for test cases that remove a PnP device.
Surprise Remove Provides code for test cases that perform a surprise remove
of a PnP device.
Power Management Test Cases Provides test cases that force a driver to handle system sleep
states.
System Sleep States Provides code for test cases that perform device I/O while
the system cycles through sleep and power state.
Stress and Functionality Test Cases Provides test cases that perform I/O stress and function
testing of IOCTL and WMI interfaces.
I/O Stress Provides test cases that perform device I/O stress.
Functional IOCTL Interface Provides a template for creating functional test cases for the
IOCTL interface. (only available for C++ ).
Functional WMI Interface Provides a template for creating functional test cases for the
Windows Management Interface (WMI). (only available in
Script)
For Windows 8, the Windows Driver Kit (WDK) uses the Test Authoring and Execution Framework (TAEF) for
creating test content. A TAEF test is an object implemented as a dynamic-link library (DLL) that contains multiple
methods, where each method maps to a specific test scenario. The TAEF object combines related methods into a
group of tests. For each test, there is a set of metadata that describes the test. To improve test portability and
encapsulation, TAEF stores test metadata within the test object itself. When you create your own driver tests
using the Driver Test templates, you need to add this metadata so that your driver tests are available and can be
deployed using Visual Studio.
Prerequisites
The source code for a driver test written by using one of the Driver Test templates. For information, see How
to write a driver test using a Driver Test template.
To add test metadata attributes
1. Add the required test property metadata to the source files for your test.
2. For example, if you use the Driver Test template to create your version of the SurpriseRemove test, the
following metadata is added. Edit the test description, display name, category, and results file attributes.
C ++
// Declare the test class method DoSurpriseRemove - the main test method within this class
BEGIN_TEST_METHOD(DoSurpriseRemove)
// Required properties for driver tests
TEST_METHOD_PROPERTY(L"Kits.Drivers", L"TRUE")
TEST_METHOD_PROPERTY(L"Kits.Parameter", L"DQ")
TEST_METHOD_PROPERTY(L"Kits.Parameter.DQ.Description", L"A WDTF SDEL query that is used to
identify the target device(s) - https://go.microsoft.com/fwlink/p/?linkid=232678")
TEST_METHOD_PROPERTY(L"Kits.Parameter.DQ.Default",
L"INF::OriginalInfFileName='%InfFileName%'")
TEST_METHOD_PROPERTY(L"RebootPossible", L"true")
// TODO: Required properties to be customized to match your test requirements
TEST_METHOD_PROPERTY(L"Description", L"Plug and Play Surprise Remove Generated Template")
TEST_METHOD_PROPERTY(L"Kits.DisplayName", L"My Plug and Play Surprise Remove Test")
TEST_METHOD_PROPERTY(L"Kits.Category", L"My Test Category")
// Optional properties for driver tests
TEST_METHOD_PROPERTY(L"Kits.Drivers.ResultFile", L"TestTextLog.log")
// TODO: (see Windows Driver Kit documentation for additional optional properties)
END_TEST_METHOD()
C#
//
// DoSurpriseRemove is a test method as identified by the [TestMethod] tag.
// More methods can be added by following this basic pattern.
// The name of the function defines the name of the test.
//
[TestMethod]
// Required properties (see Windows Driver Kit documentation for more information):
[TestProperty("Kits.Drivers", "TRUE")]
[TestProperty("Kits.Parameter", "DQ")]
[TestProperty("Kits.Parameter.DQ.Description", "A WDTF SDEL query that is used to identify
the target device(s) - https://go.microsoft.com/fwlink/p/?linkid=232678")]
[TestProperty("Kits.Parameter.DQ.Default", "INF::OriginalInfFileName='%InfFileName%'")]
// TODO: Required properties to be customized to match your test requirements.
[TestProperty("Description", "Plug and Play Surprise Remove Generated Template")]
[TestProperty("Kits.DisplayName", "My Plug and Play Surprise Remove Test")]
[TestProperty("Kits.Category", "My Test Category")]
[TestProperty("RebootPossible", "true")]
// Optional properties (see Windows Driver Kit documentation for additional optional
properties):
[TestProperty("Kits.Drivers.ResultFile", "TestTextLog.log")]
3. The following table describes the test property attributes. Use the examples for guidance as you edit or
add the metadata for your tests.
Description
A short description of what the test does.
[Script]
< TestProperty name="Description" value= "This test cycles the system through various sleep
states and performs IO on devices before and after each sleep state cycle"/>
C ++
[C++]
TEST_METHOD_PROPERTY(L"Description", L"Plug and Play Surprise Remove Generated Template")
DisplayName
The name of the test as it shown in Driver Test.
[Script]
< TestProperty name="Kits.DisplayName" value="Sleep with IO Before and After"/>
C ++
[C++]
TEST_METHOD_PROPERTY(L"Kits.DisplayName", L"My Plug and Play Surprise Remove Test")
Kits.Parameter
A standard parameter for a method call. A test can have multiple parameters.
[Script]
<ModuleProperty name="Kits.Parameter" value="TM"/>
C ++
[C++]
TEST_METHOD_PROPERTY(L"Kits.Parameter", L"DQ")
Kits.Parameter.<ParameterName>.Description
The description for the parameter.
[Script]
< TestProperty name="Kits.Parameter.TM.Description" value="Test mode parameter: Logo or
Simple"/>
C ++
[C++]
TEST_METHOD_PROPERTY(L"Kits.Parameter.DQ.Description", L"A WDTF SDEL query that is used to
identify the target device(s)")
Kits.Parameter.<ParameterName>.Default
The default value for the parameter.
[Script]
< TestProperty name="Kits.Parameter.TM.Default" value="Logo"/>
C ++
[C++]
TEST_METHOD_PROPERTY(L"Kits.Parameter.DQ.Default",
L"INF::OriginalInfFileName='%InfFileName%'")
Kits.Drivers
This attribute marks the test for inclusion in the WDK.
[Script]
< TestProperty name="Kits.Drivers" value=""/>
C ++
[C++]
TEST_METHOD_PROPERTY(L"Kits.Drivers", L"TRUE")
Kits.Categor y
Describes the category of a test.
[Script]
< TestProperty name="Kits.Category" value="Logo\Device Fundamentals"/>
C ++
[C++]
TEST_METHOD_PROPERTY(L"Kits.Category", L"My Test Category")
Deploymentitem
Identifies files and/or folders as test dependencies. These may contain any resources needed to run the
tests. For more information about using this metadata, see DeploymentItem Metadata.
Related topics
How to write a driver test using a Driver Test template
Static Driver Verifier Known Issues - Windows 10
Version 1809
9/20/2022 • 5 minutes to read • Edit Online
This page describes common issues you may encounter when using the Static Driver Verifier (SDV) tool in the
Windows Driver Kit (WDK). The information below pertains specifically to the version of the tool that ships with
Windows 10 October 2018 Update (Version 1809).
Please see WDK Known Issues for known SDV issues with the latest official WDK.
InterceptedBuild failures
Primary symptom: SDV fails with FATAL ERROR: Unrecoverable error in InterceptedBuild stage .
When examining the DVL file, you will see an AssessmentScore value with
ScoreName="[driverName].[architecture].SDV.NA.Reason" and
ScoreUnit="Unrecoverable error in InterceptedBuild stage."
For InterceptedBuild failures, perform the following steps to diagnose the issue.
1. Rerun SDV from the Visual Studio 2017 Native Tools Command Line with the /debug flag. For details on
command options, see Static Driver Verifier commands.
a. First, run SDV's library function on any dependent library projects. For example:
msbuild /p:Configuration=Release /p:Platform=x64 /t:sdv /p:inputs="/lib /debug" .
b. Then run SDV on the driver project itself. For example:
msbuild /p:Configuration=Release /p:Platform=x64 /t:sdv /p:inputs="/check /debug"
del /s *.obj
del /s *.rawcfg*
del /s *.li
del /s *.pdb
del /s *.sys
Workaround:
1. Back up your project file, and then open the project file in a text editor.
2. Under the section, find two XML tags: one with the format
\<PropertyGroup Label="Globals"\>
\<Configuration\>\[Configuration type\]\</Configuration\> and one with the format
\<Platform Condition="'$(Platform)' == ''"\>\[Architecture\]\</Platform\> , where
\[Configuration type\] and \[Architecture\] are the default configuration and release for this type of
project.
3. Update \[Configuration type\] and \[Architecture\] to values appropriate for your project. For
example, if you removed the Win32 platform, you might update \[Architecture\] to x64 instead.
Alternative workaround:
1. Open a Visual Studio 2017 Native Tools Command Prompt.
2. Navigate to the driver folder.
3. Run msbuild [Your Project] /p:Configuration=[Configuration type] /p:Platform=[Architecture] /t:dvl ,
where \[Your Project\] is the vcxproj file, \[Configuration type\] is a valid configuration such as
Release, and \[Architecture\] is a valid architecture such as x64.
Make sure the TAEF package is deployed or RoMetadata.dll is deployed to a location in your PATH environment
variable.
The key symptom is the failure to load RoMetadata.dll.
If you have a Server GUI installation with the same architecture and Windows version as your ServerCore
installation, copy the RoMetadata.dll file from Server GUI to ServerCore. The DLL can be found in the System32
folder (for example, C:\Windows\System32 ) and should be placed in the same folder on the ServerCore machine.
This should enable the test to run on ServerCore. If you are still experiencing issues, please refer to the next
workaround.
The second workaround is to run on Server GUI and then merge the package with the package containing the
results from Server Core. For info on merging packages, see Merge packages.
This is a known issue. If this issue is blocking your WHCP certification, please use errata 41600.
Creating a Driver Verification Log
9/20/2022 • 4 minutes to read • Edit Online
Certain programs of the Windows Hardware Certification Program require a Driver Verification Log (DVL) for all
driver submissions. The DVL contains a summary of the results from the Code Analysis (CA), Static Driver
Verifier (SDV), and CodeQL log files. The DVL does not contain any source information. You must run the Code
Analysis tool and Static Driver Verifier prior to creating a DVL for your driver.
To create a driver verification log
1. Before running the Code Analysis tools, be sure that you can build and link your driver using the latest
Windows Driver Kit (WDK).
2. For the Driver Solution, make sure that you have selected a Release configuration as the Solution
Configuration and x64 as the Solution Platform.
3. Run Static Driver Verifier. For information about creating the log file, see Creating a log file for Static Driver
Verifier and Using Static Driver Verifier to find defects in drivers.
4. Run the Code Analysis tool for drivers. Address and fix any defects that are found. See Creating a log file for
the code analysis tool and How to run Code Analysis for Drivers. For more information about code analysis,
see Analyzing C/C++ Code Quality by Using Code Analysis.
5. Run CodeQL. Address and fix defects that are found. Certification will fail if defects that are deemed "Must-
Fix" are not corrected. For more information about CodeQL and the Static Tools Logo Test, see CodeQL and
the Static Tools Logo Test.
6. Create the Driver Verification Log. From the Driver menu, select Create Driver Verification Log....
7. Verify that the Code Analysis Log, Static Driver Verifier Log, and CodeQL Log files are detected. Select Create .
The driver verification log has the file name extension .DVL.XML. The log is created in the project folder, for
example, \myDriverProject\myDriverName.DVL.XML.
Note SDV performs a clean rebuild of the driver, which removes the Code Analysis log. As such, please be sure
to run SDV before running CA.
Note When you are ready to test your driver using the Windows Hardware Lab Kit, you need to copy the driver
verification log to the %systemdrive%\DVL directory on the test computer. Be sure to delete the contents of the
directory on the test computer before you copy the new driver verification log.
Remarks
For the most up-to-date information about the Code Analysis tool, Static Driver Verifier, and the Driver
Verification Log, refer to the WDK Release Notes. The Release Notes are available on the Windows Driver Kit
(WDK) download page.
Impor tant Timeouts, spaceouts, and other non-successful results in the DVL file are acceptable for
certification submission. This will not cause the Static Tools test in HLK to fail.
You can also create the driver verification log from a Visual Studio Command Prompt window, either by the
Visual Studio Native Tools Command Prompt installed with Visual Studio or via the Enterprise Windows Driver
Kit (EWDK):
One of the following strings should be used for your driverArchitecture string:
X86
X64
Arm
Arm64
Do not include ".sys" as par t of your driverName string
6. Inspect the generated DVL to ensure that it was generated correctly
This usage is primarily intended for generating DVLs with CodeQL results, but can also be used for SDV and CA
results.
Related topics
Creating a log file for Static Driver Verifier
Creating a log file for the code analysis tool
Hardware Certification Program
Analyzing Driver Quality by Using Code Analysis Tools
How to run Code Analysis for drivers
Using Static Driver Verifier to find defects in drivers
CodeQL and the Static Tools Logo Test
Creating a log file for the code analysis tool
9/20/2022 • 2 minutes to read • Edit Online
The Windows Server 2012 Hardware Certification Program requires a Driver Verification Log (DVL) for all
applicable driver submissions. You must run the Code Analysis tool prior to creating a DVL for your driver. The
DVL contains a summary of the results from the Code Analysis and Static Driver Verifier log files. The log files do
not contain source code information.
To run code analysis on the driver
1. In Microsoft Visual Studio Ultimate 2012, select the driver project file and then select and hold (or right-click)
to open the project properties. Select Windows 8 Release as the Configuration and x64 as the Platform .
2. From the Analyze or Build menu, select Run Code Analysis on Solution .
3. If errors or warnings are found, use the Code Analysis Repor t window to investigate the cause of the
errors. Use the warning messages to fix those problems. For more information about the Code Analysis tool,
see How to run Code Analysis for drivers and Analyzing C/C++ Code Quality by Using Code Analysis.
The Code Analysis tool for drivers writes the results to the file vc.nativecodeanalysis.all.xml in the build
configuration and platform sub-directory of your project, for example, \Windows 8Release\x64.
Remarks
Code Analysis for Drivers is a compile-time static verification tool that detects basic coding errors in C and C++
programs and includes a specialized module that is designed to detect errors in (primarily) kernel-mode driver
code. In previous versions of the WDK, the driver-specific module for code analysis was part of a stand-alone
tool called PREfast for Drivers (PFD).
You can also run the Code Analysis tool from a Visual Studio Command Prompt window. Set up the
environment by running one of the following batch files.
-Or-
For the most up-to-date information about the requirements for the Driver Verification Log, refer to the WDK
Release Notes.
Related topics
Creating a driver verification log
Creating a log file for Static Driver Verifier
Code Analysis for Drivers
Hardware Certification Program
Analyzing C/C++ Code Quality by Using Code Analysis
How to run Code Analysis for drivers
Creating a log file for Static Driver Verifier
9/20/2022 • 2 minutes to read • Edit Online
The Windows Server 2012 Hardware Certification Program requires a Driver Verification Log (DVL) for all
applicable driver submissions. You must run Static Driver Verifier (SDV) prior to creating a DVL for your driver.
The DVL contains a summary of the results from the Code Analysis and Static Driver Verifier log files. The log
files do not contain source code information.
For best results, run the Code Analysis tool before you run Static Driver Verifier.
Remarks
For the most up-to-date information about Static Driver Verifier and the Driver Verification Log, refer to the
WDK Release Notes. The Release Notes are available on the Windows Driver Kit (WDK) download page.
IMPORTANT
Timeouts, spaceouts, and other non-successful results in the DVL file are acceptable for certification submission. This will
not cause the Static Tools test in HCK to fail. For HCK 2.0, the Static Tools Test only requires the presence of DVL file to
show Code Analysis and SDV had been run, and does not require all rules to pass.
You can also run Static Driver Verifier from a Visual Studio Command Prompt window. Set up the environment
by running one of the following batch files.
-Or-
This topic describes how to securely distribute your driver package. This information includes how to distribute
a driver package through the Microsoft Windows Update program. This topic also describes how Windows
protects system files.
Windows Update
Driver packages that pass Windows Hardware Certification Kit (HCK) testing can be digitally-signed by
WHQL. If your driver package is digitally-signed by WHQL, it can be distributed through the Windows
Update program or other Microsoft-supported distribution mechanisms.
Obtaining a WHQL release signature is part of the Windows Hardware Certification Kit (HCK). A WHQL release
signature consists of a digitally-signed catalog file. The digital signature does not change the driver binary files
or the INF file that you submit for testing.
You can distribute a driver package through the Windows Update program if the driver package:
Passes the WHQL test program and receives a WHQL release signature.
Qualifies for the Windows Certification Program.
Meets additional requirements that ensure that Windows Update can determine the correct driver
package for the user's device, can legally distribute it, and can automatically download it.
Because the requirements of the Windows Update program are frequently updated, you should regularly check
the Windows Update driver publishing Web site.