Crash caused by customized upper driver


In order to access GPIO I wrote an upper driver for bus\device\function: 0 31 15 (in my PC, msisadrv.sys)
The driver handles IOCTL request coming from the application.** It works fine.**

The problem: Upon shutdown \ Restart to the PC I’m getting blue screen.
If this drier is deleted, shutdown \ restart works OK.

I loaded the dmp file to the the debugger and got the attached analyze.txt.

What code in my driver can cause such crash ?

This driver has no code that deals with restart \ shutdown. It is based on:

Thank you,

The problem is that you are a filter driver, but you have not told KMDF that you are a filter driver. Thus, KMDF is trying to control parts of the PnP and Power requests that it does not own. You need WdfFdoInitSetFilter(DeviceInit);.

Not clear to me why you would start with a function driver sample when you wanted to write a filter.

Hi Tim,

Thank you very much.

Best regards,

Hi Tim, All,

The current code based on the func driver contains the following:
WDF_DRIVER_CONFIG_INIT (&config, ToasterEvtDeviceAdd).

Should **only **I change to:
WDF_DRIVER_CONFIG_INIT (&config, FilterEvtDeviceAdd) ?
FilterEvtDeviceAdd is a routine in the sample kmdf\filter\generic\filter.c

I’m asking because the filter sample contains also inf file.
Is it mandatory in my case ?

Thank you,

Well, you need some way in which to tell the system which device you want to filter. So, either you need to do that via the INF or you need to do it with an application/CoInstaller.

The best way, for many reasons, is to do it with an INF.

Peter (not Tim)

Exactly how did you install this driver? I’m fascinated by the many different ways people use to get a driver installed. Perhaps there needs to be a documentation page that gives the whys and hows of the different installation scenario.

Installing a device filter driver requires exatcly three things. 1, you need to copy your .sys file into place. 2, you need to create a service for it. 3, you need your service name added to the UpperFilters or LowerFilters key for the device you want to filter.

Personally, I have a simple filter driver installer app that I use that does those three things, based on a sample from the Vista DDK. It isn’t very much code.

The only problem with using an INF in this case is that you can’t pinpoint the registry entry for the device you want to filter. Windows 10 has added some new “partial INF” abilities that I haven’t explored yet, so it may be possible, but for the older systems at least, you need at least one manual step.

Well, it depends on whether you want to filter a specific instance of a device, or all classes of a device, right?

For all classes of a given type of device, you can just do (this is a fragment, obviously):

; General installation section
CopyFiles = @FredFlt.sys
Addreg    = FredFlt.AddReg

DefaultDestDir = 12

HKLM, System\CurrentControlSet\Control\Class\{FRED_CLASS_GUID_HERE}, UpperFilters, 0x00010008, %DriverName%

; Service installation section

AddService = FredFlt,,FredFlt.Service.Install

DisplayName      = %ServiceName%
Description      = %ServiceDescription%
ServiceBinary    = %12%\%DriverName%.sys        ;%windir%\system32\drivers\
ServiceType      = 1                            ;SERVICE_KERNEL_DRIVER
StartType        = 0                            ;SERVICE_BOOT_START
ErrorControl     = 1                            ;SERVICE_ERROR_NORMAL
LoadOrderGroup   = "PnP Filter"


1 = %DiskId1%,,,


Hi Peter, Tim, All,

Currently my reference is kmdf\filter.

Can you please tell what should I modify in filter.inx in order to install kmdf\filter\generic as an upper filter for an existing driver developed by MS ?

Should I modify the code required to build tostrcls.dll ?
Why do I need wdffeatured.sys and not only filter.sys ?

From filtex.inx:
“This file is dependant on wdffeatured.inf”
In what way the 2 files are dependent ?

Thank you in advance,

I think you need some basic things clear first… rather asking directly here please take it positively and do some study. follow MSDN for information.

Currently my reference is kmdf\filter.

No, your sample is general\toaster\toastDrv\kmdf\filter. Why would you make us go to search for this? There are hundreds of samples.

You can’t filter a “driver”. You can filter a single device, or you can filter a whole device class. Don’t make us guess. Exactly what kind of device are you trying to filter? The more detail you provide, the better our advice can be.

This file is dependent on wdffeatured.inf. In what way the 2 files are dependent?

Did you look through the sample at all? Wdffeatured.sys is the main function driver for this sample device. It is in general\toaster\toastdrv\kmdf\func. This particular filter driver is designed to be an upper filter to that driver. If you’re not filtering this device (which of course you are not), then you don’t need wdffeatured.

The INF in the sample only works because it is installing the function driver and the filter driver at the same time. If you are adding a filter driver to an existing device, you can’t use an INF file (although you can use one for a class filter).