HOWTO: Use Testdrv.sys from Windows 98 DDK as a WDM PnP Driver

ID: Q202060


The information in this article applies to:


SUMMARY

The Windows 98 DDK contains sample source code for a generic WDM driver in the \ddk\src\general\sys directory. Building this sample yields a binary file named Testdrv.sys. This article discusses how to create an inf and modify the sample so that it can be used as a generic WDM PnP driver.


MORE INFORMATION

The sample as it exists in early versions of the Windows 98 DDK (including the July and October 1998 MSDN releases) does not function correctly as a PnP driver. Using the driver results in Device Manager displaying error code 7 (CM_PROB_FAILED_FILTER).

The problem is that the DRVSHELL_Dispatch function in Drvshell.c by default sets Irp->IoStatus.Status = STATUS_SUCCESS. The IRP_MJ_PNP handler does not explicitly handle the IRP_MN_FILTER_RESOURCE_REQUIREMENTS IRP. When Ntkern.vxd sees that this IRP has been completed and IoStatus.Status = STATUS_SUCCESS, it expects that the driver has set IoStatus.Information to point to an IO_RESOURCE_REQUIREMENTS_LIST structure containing the filtered resource list. Because the sample driver fails to set IoStatus.Information appropriately, Ntkern.vxd emits a "Filtering into nothing, returning failure" debug message and fails the CONFIG_FILTER message resulting in the error code 7.

The following code shows how an IRP_MN_FILTER_RESOURCE_REQUIREMENTS handler can be added to the sample driver to work around this problem by indicating that it is not filtering the resource requirements:


    case IRP_MJ_PNP:
        DEBUG_LOG_PATH("IRP_MJ_PNP_POWER");
        switch(irpStack->MinorFunction)
        {
            case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
                DEBUG_LOG_PATH("IRP_MN_FILTER_RESOURCE_REQUIREMENTS");
                Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
                break; 

Alternately, if resource filtering is required, the IRP_MN_FILTER_RESOURCE_REQUIREMENTS handler could leave IoStatus.Status = STATUS_SUCCESS and set IoStatus.Information to point to an IO_RESOURCE_REQUIREMENTS_LIST structure containing the filtered resource list.

The following sample inf installs Testdrv.sys as a WDM PnP driver loaded by Ntkern.vxd. This inf can be easily adapted for use with any hardware device by including the appropriate hardware ID in the [WDMTest] Device section:

[Version]
Signature="$CHICAGO$"
;set Class to appropriate type for your device
Class=Unknown
;set ClassGUID to appropriate value for the Class
;ClassGUID={XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
provider=%Provider%
[SourceDisksNames]
1="WDM Test Driver Disk",,0
[SourceDisksFiles]
testdrv.sys=1
[Manufacturer]
%Manufacturer%=WDMTest
[WDMTest]
"WDM Test Driver"=WDM_Install, <your hardware ID>;
[WDM_Install]
CopyFiles=WDM.CopyFiles
AddReg=WDM.AddReg
[WDM.AddReg]
HKR,,DevLoader,,*NTKERN
HKR,,NTMPDriver,,testdrv.sys
[DestinationDirs]
WDM.CopyFiles      = 10,system32\drivers ; %SystemRoot%\system32\drivers
[WDM.CopyFiles]
testdrv.sys
[Strings]
Provider="Your Provider Name"
Manufacturer="Your Manufacturer Name" 


REFERENCES

See the Windows 98 DDK for more information on WDM and PnP.


Keywords          : kbDDK kbKMode kbWinOS98 
Version           : WINDOWS:Windows 98
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: March 6, 1999