BullseyeCoverage Up Contents Search

Windows Kernel Mode

There are a few special instructions and limitations for measuring coverage of Windows kernel mode code. Apart from the exceptions below, you can use BullseyeCoverage the same way with a kernel mode project as with a regular project.

The coverage file must be stored on the target computer file system. Copy the coverage file from the host system to the target system whenever you install your driver.

On the target computer, environment variable COVFILE must be set to the fully qualified path of the coverage file. Set it as a system variable, not a user variable. If your target operating system does not provide a user interface method to modify environment variables, modify them in the registry at the key location below.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Restart the target computer after changing environment variables.

If COVFILE is not set, the default coverage file name is C:\test.cov.

Run-time error messages are normally displayed in the host debugger Command window (using the kernel mode support routine DbgPrintEx). If no debugger is connected and environment variable COVERR is unset, run-time error messages are lost.

Your entry point function name must end with DriverEntry. For example, DriverEntry, FxDriverEntry, or GsDriverEntry.

Environment Variables

If the BullseyeCoverage run-time cannot find an environment variable in the registry, it searches the file C:\BullseyeCoverageEnv.txt. This ASCII text file has the format below:

name1=value1
name2=value2
...

Export Drivers

For an export driver, you must add a call to the BullseyeCoverage run-time function cov_term in your DllUnload function. For example:

void __cdecl cov_term(void);
NTSTATUS DllUnload()
{
    #if _BullseyeCoverage
        cov_term();
    #endif
    return STATUS_SUCCESS;
}

Updated: 8 Jul 2021