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

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

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


What is wrong with this INF?

Ramakrishna_SaripalliRamakrishna_Saripalli Member Posts: 60

Hi, I am trying to convert a lower disk filter driver that was written in WDM. The WDM driver installs and runs just fine on Win7 and Windows 10 x64.

The driver will layer as a lower filter driver of disk.sys.

I created the KMDF driver using the KMDF driver project type in VS 2019 and modified the INF file generated to the one as follows.
When I compile the driver, the INF validator integrated into the build complains of the following error

1308 Found legacy DelProperty operation

How do I get around this error?. It points to line 1 in the INF file but line 1 is a comment. The Visual Studio documentation is not of any help at all

Also, I am not able to reference HKLM in the INF file (The old WDM INF file modifies the LowerFilters registry key in HLKM but looks like I have to use HKR).

Does the following INF file look ok for installing the lower filter driver?

Thanks in advance for any help,
RK

==================================================================================INF file==============================================
[Version]
Signature="$WINDOWS NT$"
Class=DiskDrive ; TODO: edit Class
ClassGuid={4d36e967-e325-11ce-bfc1-08002be10318} ; TODO: edit ClassGuid
Provider=%ManufacturerName%
CatalogFile=icsflt.cat
DriverVer=03/07/2020,5.1.2600.0 ; TODO: set DriverVer in stampinf property pages

[DestinationDirs]
DefaultDestDir = 12
icsflt_Device_CoInstaller_CopyFiles = 11

; ================= Class section =====================

[SourceDisksNames]
1 = %DiskName%,,,""

[SourceDisksFiles]
icsflt.sys = 1,,
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1 ; make sure the number matches with SourceDisksNames

;*****************************************
; Install Section
;*****************************************

[Manufacturer]
%ManufacturerName%=Standard,NT$ARCH$

[Standard.NT$ARCH$]
%icsflt.DeviceDesc%=icsflt_Device, Root\icsflt ; TODO: edit hw-id

[icsflt_Device.NT]
CopyFiles=Drivers_Dir

[icsflt_Device.NT.HW]
AddReg=icsflt_Device.NT.AddReg

[icsflt_Device.NT.AddReg]
;HKR,,DeviceCharacteristics,0x10001,0x0100 ; Use same security checks on relative opens
;HKR,,Security,,"D:P(A;;GA;;;BA)(A;;GA;;;SY)" ; Allow generic-all access to Built-in administrators and Local system
HKR,,"LowerFilters", 0x00000004
HKR,,"LowerFilters", 0x00010008, "icsflt"

[Drivers_Dir]
icsflt.sys

;-------------- Service installation
[icsflt_Device.NT.Services]
AddService = icsflt,%SPSVCINST_ASSOCSERVICE%, icsflt_Service_Inst

; -------------- icsflt driver install sections
[icsflt_Service_Inst]
DisplayName = %icsflt.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\icsflt.sys

;
;--- icsflt_Device Coinstaller installation ------
;

[icsflt_Device.NT.CoInstallers]
AddReg=icsflt_Device_CoInstaller_AddReg
CopyFiles=icsflt_Device_CoInstaller_CopyFiles

[icsflt_Device_CoInstaller_AddReg]
HKR,,CoInstallers32,0x00010000, "WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller"

[icsflt_Device_CoInstaller_CopyFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll

[icsflt_Device.NT.Wdf]
KmdfService = icsflt, icsflt_wdfsect
[icsflt_wdfsect]
KmdfLibraryVersion = $KMDFVERSION$

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,578
    [icsflt_Device.NT.AddReg]
    ;HKR,,DeviceCharacteristics,0x10001,0x0100 ; Use same security checks on relative opens
    ;HKR,,Security,,"D:P(A;;GA;;;BA)(A;;GA;;;SY)" ; Allow generic-all access to Built-in administrators and Local system
    HKR,,"LowerFilters", 0x00000004
    HKR,,"LowerFilters", 0x00010008, "icsflt"
    

    The "4" flag to HKR is a delete flag. Remove that line.

    %icsflt.DeviceDesc%=icsflt_Device, Root\icsflt ; TODO: edit hw-id

    Have you followed this instruction? As written, this INF will create a new, fake device, then install your driver as the primary driver for that device, then add your driver again as a lower filter. I feel pretty confident this is not what you wanted.

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

  • Ramakrishna_SaripalliRamakrishna_Saripalli Member Posts: 60

    Tim, thanks. My WDM INF file has no such equivalent setting. What should be the value instead of Root\icsflt if I want to install this as a disk lower filter driver?. I tried SCSI as follows but that did not work either.

    Maybe the INF file is not the way to install KMDF style disk lower filter drivers.
    One person has reported that his disk upper filter driver is installed successfully through sc create and add filter for his KMDF filter driver but I wanted to verify that this does not work before I go the other way

    [Standard.NT$ARCH$]
    %icsflt.DeviceDesc%=icsflt_Device, SCSI ; TODO: edit hw-id

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,578

    So, are you telling us the INF you posted was not actually your INF? Did you just post that for fun? How can we debug your problems if you are sending us fake code? The line you quoted needs to identify the exact hardware ID of the device you want to filter. You can't just throw in random words and hope that it works.

    The disk stack isn't where I spend most of my time, so there may be specific requirements I don't know, but in general a device filter does not actually need an INF. There are three steps: copy the file into place, create a service (which can be done with the "sc" command), and add a LowerFilters or UpperFilters line to the registry for the device you want to filter. You CAN use an INF, but your INF replaces the original one, so you have to identify both the primary driver and your filter.

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

  • Ramakrishna_SaripalliRamakrishna_Saripalli Member Posts: 60
    No it is my Inf file. I have one for wdm driver that works just fine. I did not post that ever

    What i posted is my kmdf driver inf file. That is what i am trying to work

    The wdm driver was written by someone else. It works fine on win 10

    The kmdf driver inf file was generatef by vs2019 and i modified it slightly to use diskclass guid

    Sorry for the confusion
  • Ramakrishna_SaripalliRamakrishna_Saripalli Member Posts: 60

    BTW, I got the SCSI from looking at the Details tab of disk.sys in Device Manager. I thought it would work. Anyways, I am going to try the sc create way and I am hoping that that works. it is just that in my workflow using an INF makes life easier because we already have install scripts

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,578

    If your KMDF driver is a functional replacement for the WDM driver, then the exact same INF will work. The co-installer section is not required unless you need to run on much earlier systems.

    There are two kinds of INF. INFs that use a [DefaultInstall] section are essentially just a cheap software installer. The are sometimes use for class filters, and can be replaced by batch file. All other INFs are PnP INFs that target specific devices. Your INF doesn't target a real device.

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

  • Ramakrishna_SaripalliRamakrishna_Saripalli Member Posts: 60

    Tim, thanks.

    a) First of all, the INF verifier in the VS2019 breaks on the WDM INF file. It complains about multiple errors.
    b) if I remove the INF file as a dependency, it is ok, the driver compiles fine

    Driver installs fine. Debugger is attached at all times and bootdebug is on.
    After the target reboots, I get 0x7B (Inaccessible boot device). I have a int 3 in the DriverEntry and that never hits.
    Of course, the 0x7B is because of my driver because if my driver is not installed, everything is fine of course.

    The WDM driver if installed with the same INF file works just fine.

    I will try your suggestion again in a freshly built VM

    Thanks again,
    Rk

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,013

    First of all, the INF verifier in the VS2019 breaks on the WDM INF file. It complains about multiple errors.

    But it WORKs for the WDM driver, right?

    Remember, most of that INF checking stuff these days is about MSFT policy, and not about whether you have an INF that works. So, at least temporarily ignore the INF warnings and use the old INF file.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • Ramakrishna_SaripalliRamakrishna_Saripalli Member Posts: 60
    Yes it works on the wdm driver. Works from win7 to 10. The kmdf inf file refers to coinstallers. I guess i do not have to worry about that for wdm inf file

    I have written kmdf pci function drivers for pcie daq cards but this is my first go at kmdf filter driver inf files
  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,013

    Yes it works on the wdm driver

    Then, as Mr. Roberts correctly stated, it'll work on your KMDF driver as well.

    The kmdf inf file refers to coinstallers

    Forget about the co-installer. Completely. At least for now. Build your driver targeting the oldest version of the Framework that shipped with the oldest OS version that your driver will support, and just leave out any reference to the CoInstaller completely.

    Later, if you decide you need to require a specific higher version of KMDF than the one that originally shipped with the oldest OS version that you support, you can decide if you care about shipping the co-installer.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • Ramakrishna_SaripalliRamakrishna_Saripalli Member Posts: 60

    Peter / Mr Roberts, thanks a lot for your help. I am going to try with the old INF file. I was not aware that the WDM INF file would work with the KMDF driver. That is a useful hint. Thanks again

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
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 15 Jun 2020 LIVE ONLINE
Writing WDF Drivers 22 June 2020 LIVE ONLINE
Internals & Software Drivers 28 Sept 2020 Dulles, VA