Microsoft Knowledge Base Email Alertz

(202060) - 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...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 202060 - Last Review: July 13, 2004 - Revision: 1.1

How To Use Testdrv.sys from Windows 98 DDK as a WDM PnP Driver

This article was previously published under Q202060

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.

APPLIES TO
  • Microsoft Win32 Device Driver Kit for Windows 2000
Keywords: 
kbhowto kbkmode KB202060
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate