Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Crash caused by customized upper driver

zviveredzvivered Member Posts: 28
edited July 14 in NTDEV

Hello,

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:
C:\WinDDK\7600.16385.1\src\general\toaster\kmdf\func\simple

Thank you,
Zvika

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,159

    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.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • zviveredzvivered Member Posts: 28

    Hi Tim,

    Thank you very much.

    Best regards,
    Zvika

  • zviveredzvivered Member Posts: 28

    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,
    Zvika

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,507

    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)

    Peter Viscarola
    OSR
    @OSRDrivers

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,159

    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.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,507

    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
    ;
    [DefaultInstall.NT]
    CopyFiles = @FredFlt.sys
    Addreg    = FredFlt.AddReg
    
    [DestinationDirs]
    DefaultDestDir = 12
    
    [FredFlt.AddReg]
    ;
    ; FRED CLASS GUID
    ;
    HKLM, System\CurrentControlSet\Control\Class\{FRED_CLASS_GUID_HERE}, UpperFilters, 0x00010008, %DriverName%
    
    ;
    ; Service installation section
    ;
    
    [DefaultInstall.NT.Services]
    AddService = FredFlt,,FredFlt.Service.Install
    
    [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"
    
    [SourceDisksFiles]
    FredFlt.sys=1
    
    [SourceDisksNames]
    1 = %DiskId1%,,,
    

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • zviveredzvivered Member Posts: 28

    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,
    Zvika

  • NtDev_GeekNtDev_Geek Member - All Emails Posts: 110

    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.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,159

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

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE