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/


UMDF filter on VirtualSerial - blasted inf file

jolyon_wrightjolyon_wright Member - All Emails Posts: 29

I'm afraid this is a bit of a "please do my homework for me" question; but I hope someone might point me in the right direction... I am trying to understand user mode drivers and figured that putting a filter driver on the virtual serial sample would be a nice simple fun thing to do. wrong on all counts. So, I bang my head on the desk and plead:- "please help me figure why this INF file does not work". I am struggling to mentally merge the (scant) documentation about this (https://docs.microsoft.com/en-us/windows-hardware/drivers/wdf/installing-a-umdf-filter-driver) and the USB UMDF filter example into something that works.... sigh

;
; VirtualSerial.inf with a filter?
;
;
; WudfUpdate: GetDriverDetailsData: SetupDiGetSelectedDriver: status(E0000203) <no error text>
; WudfUpdate: Error getting details about driver being installed - status(E0000203) <no error text>.
;
; great :(

[Version]
Signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%ProviderString%
CatalogFile=WUDF.cat
DriverVer=03/25/2005,0.0.0.1

[Manufacturer]
%ManufacturerString%=Microsoft,NT$ARCH$

[Microsoft.NT$ARCH$]
%VirtualSerialDeviceName%=VirtualSerial_Install,UMDF\VirtualSerial

[SourceDisksFiles]
MyUMDFVirtualFilter.dll=1
Virtualserial.dll=1
WudfUpdate_$UMDFCOINSTALLERVERSION$.dll=1

[SourceDisksNames]
1 = %MediaDescription%

; =================== UMDF VirtualSerial Device ==================================

[VirtualSerial_Install.NT]
CopyFiles=UMDriverCopy
; ?
; Include=WINUSB.INF                      ; Import sections from WINUSB.INF
; Needs=WINUSB.NT                         ; Run the CopyFiles & AddReg directives for WinUsb.INF


[VirtualSerial_Install.NT.hw]

[VirtualSerial_Install.NT.Services]
AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall
; ?
; AddService=WinUsb,0x000001f8,WinUsb_ServiceInstall  ; this service is installed because its a filter.
; AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall

[VirtualSerial_Install.NT.CoInstallers]
CopyFiles=CoInstallers_CopyFiles
AddReg=CoInstallers_AddReg

[VirtualSerial_Install.NT.Wdf]
UmdfService=VirtualSerial,VirtualSerial_Install
UmdfService=MyUMDFVirtualFilter,MyUMDFVirtualFilter_Install
UmdfServiceOrder=VirtualSerial,MyUMDFVirtualFilter
UmdfKernelModeClientPolicy = AllowKernelModeClients
UmdfFileObjectPolicy = AllowNullAndUnknownFileObjects
UmdfFsContextUsePolicy = CannotUseFsContexts

[VirtualSerial_Install]
UmdfLibraryVersion=$UMDFVERSION$
ServiceBinary=%12%\UMDF\Virtualserial.dll
DriverCLSID={C8ECC087-6B79-4de5-8FB4-C03358A29617}

[WUDFRD_ServiceInstall]
DisplayName = %WudfRdDisplayName%
ServiceType = 1
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\WUDFRd.sys

[MyUMDFVirtualFilter_Install]
UmdfLibraryVersion=$UMDFVERSION$ 
ServiceBinary=%12%\UMDF\MyUMDFVirtualFilter.dll

[CoInstallers_CopyFiles]
WudfUpdate_$UMDFCOINSTALLERVERSION$.dll

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WUDFUpdate_$UMDFCOINSTALLERVERSION$.dll"

[DestinationDirs]
UMDriverCopy=12,UMDF ; copy to drivers\UMDF
CoInstallers_CopyFiles=11

[UMDriverCopy]
Virtualserial.dll
MyUMDFVirtualFilter.dll

; =================== Generic ==================================

[Strings]
ProviderString="TODO-Set-Provider"
ManufacturerString="TODO-Set-Manufacturer"
MediaDescription="Microsoft Sample Driver Installation Media"
WudfRdDisplayName="Windows Driver Foundation - User-mode Driver Framework Reflector"
VirtualSerialDeviceName="Microsoft VirtualSerial User-Mode Device Sample"

any pointers greatly appreciated,

thanks

Jolyon

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,627

    How did you try to install this, exactly? And I assume you realize this is an INF template -- it has to be passed through stampinf before it can be used as a real INF. Stampinf fills in all of those $ variables (like $ARCH$ and $UMDFVERSION$). Are you signing the driver package?

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

  • jolyon_wrightjolyon_wright Member - All Emails Posts: 29

    Thanks - yes; this is the inx file before VS generated the INF.... I tried to install it with "devcon install VirtualSerial.inf UMDF\VirtualSerial".... I am really not understanding how the filter is supposed to get hooked in....

  • jolyon_wrightjolyon_wright Member - All Emails Posts: 29

    it, um, worked fine before i fixed it.... in other words - removing my failed attempts to pull in the UMDF filter does result in a working VirtualSerial driver installation...

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

    Are you writing a FILTER or a function driver?

    I thought you were writing a filter.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,627

    The rules for "how it gets hooked in" are different for UMDF drivers like this. In this case, the drivers in the stack are identified by the UmdfService lines, and their ordering is determined by the UmdfServiceOrder. What, exactly, do you see when you do this installation?

    And note that, once you have done the "devcon install" once and you have a fake devnode, you can go into Device Manager to change the driver using Update Driver.

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

  • jolyon_wrightjolyon_wright Member - All Emails Posts: 29

    thanks Peter and Tim - just to clarify I am trying to integrate a UMDF filter driver into the VirtualSerial sample. When I install with devcon I get the errors

    WudfUpdate: GetDriverDetailsData: SetupDiGetSelectedDriver: status(E0000203)
    WudfUpdate: Error getting details about driver being installed - status(E0000203) .

    and a "question mark" device in devicemanager - I have the setupapi loglevel on max and this is yielding no clues... Neither drivers are actually loaded..

    Thanks for clarifying the "hooking in" mechanism... it's a puzzle... infverif flags nothing...

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,627

    Are you going back to a clean system everytime? It's important to note that "devcon install" does three things: it creates an instance of fake device, it pre-installs your driver in the driver store, and it triggers a rescan to force your driver to be loaded for the fake device. EVERY TIME you run "devcon install", it creates another fake device. If you aren't cleaning up somehow, you probably have a number of fake serial devices, each with some version of a driver.

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

  • jolyon_wrightjolyon_wright Member - All Emails Posts: 29

    Thanks for clarifying what's going on behind the scenes here and the suggestion; I have expunged the driverstore with the same result and removed my failed attempts to add the filter. Installing just the virtual function driver does work. Should I be putting:-

    Include=something_or_other.inf
    Needs=something.or.other

    in there somewhere?

    I am taking the OSR WUDFOsrUsbFilterOnUmFx2Driver.inx as my inspiration for getting this to work. The hardware that this requires is, according to Amazon, not currently available.... I wonder if I could get this to load on some other USB device... hm... I digress...

    Would it be possible, in some future WDK release, to include a UMDF filter sample for a virtual device? This would make this aspect of the framework significantly easier to grasp.

    Is there any way I can circumvent the INF mumbo jumbo in the same way I can for a kmdf filter? The user mode equivalent of using SC to create a kernel mode service and just sticking in an UpperFilters entry?

    Anyway; your input is much appreciated but I suspect that my time, just at the moment, might be better spent trying to get my locked down kitchen into some kind of order :)

    jolyon

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,627

    Include= and Needs=

    In your case, that's not necessary because your INF is complete in itself. You're replacing the original INF. There's no difference between a UMDF filter for a real UMDF device and a UMDF filter for a virtual UMDF device.

    There's nothing in \windows\inf\SetupDev.log? You're including ALL of the necessary files when you do the install (MyUMDFVirtualFilter.dll, VirtualSerial.dll, WudfUpdate_010xx.dll, your INF, your CAT?

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

  • jolyon_wrightjolyon_wright Member - All Emails Posts: 29

    Thanks for clarifying that Include/ Needs stuff...

    Hm well I have resolved this but I am not very comfortable about it at all. Do you remember The Dark Years before kmdf? The endless versions of toaster power management code that was copy pasted into everything and fingers across the world were crossed that we all got lucky....

    I am back there.

    I have gone back to the toaster UMDF filter sample and grafted my code into that, minimizing the changes I make to that rats' nest of XML and I seem to have got lucky. Perhaps my luck will hold... but you know this is not a really great development experience - O where did my nice simple little sources and dirs files go... sigh... I am a luddite :)

    hey ho - very much appreciate your attempts to point me in the right direction!

    jolyon

  • jolyon_wrightjolyon_wright Member - All Emails Posts: 29

    this works for me, should anyone else be banging there head on this one:-

    ;/*++
    ;
    ;Copyright (c) Microsoft Corporation.  All rights reserved.
    ;
    ;Module Name:
    ;
    ;    filterum.INF from the umdf2/filter/generic/filterum.inx sample
    ;
    ; modified to install the virtual serial device with a umdf2 filter
    ;
    ;--*/
    
    [Version]
    Signature="$WINDOWS NT$"
    ; Class=TOASTER
    ; ClassGuid={B85B7C50-6A01-11d2-B841-00C04FAD5171}
    Class=Ports
    ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
    ; (this is not a toaster)
    Provider=%ProviderString%
    DriverVer=06/16/1999,5.00.2064
    CatalogFile=wudf.cat
    
    [DestinationDirs]
    DefaultDestDir = 12
    UMDriverCopy=12,UMDF ; copy to drivers/umdf
    
    ; ================= Class section =====================
    
    ; [ClassInstall32]
    ; Addreg=ToasterClassReg     
    
    ; [ToasterClassReg]
    ; HKR,,,0,%ClassName%
    ; HKR,,Icon,,100
    ; HKR,,DeviceCharacteristics,0x10001,0x100     ;Use same security checks on relative opens
    ; HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GA;;;BA)" ;Allow generic all access to system and built-in Admin.
    ;                                              ;This one overrides the security set by the driver
    
    ;*****************************************
    ; Toaster Device  Install Section
    ;*****************************************
    
    [Manufacturer]
    %StdMfg%=Standard,NT$ARCH$
    
    
    ; For XP and later
    [Standard.NT$ARCH$]
    %WdfSimpleDevice.DeviceDesc%=Toaster_Device, root\toaster
    
    [Toaster_Device.NT]
    CopyFiles=UMDriverCopy
    
    ; jw ; from virtualserial2um.inx
    [Toaster_Device.NT.hw]
    AddReg=SetDeviceType_AddReg
    
    [SetDeviceType_AddReg]
    HKR,,DeviceType,0x10001,0x0000001b  ; 0x1b = FILE_DEVICE_SERIAL_PORT
    ; jw ends
    
    ; ---------------- file copy
    [UMDriverCopy]
    wdfsimpleum.dll,,,0x00004000  ; COPYFLG_IN_USE_RENAME
    filterum.dll,,,0x00004000  ; COPYFLG_IN_USE_RENAME
    
    [SourceDisksNames]
    1 = %DiskId1%,,,""
    
    [SourceDisksFiles]
    ; this guy is really the VirtualSerial sample (Windows-driver-samples/serial/VirtualSerial2/ComPort/virtualserial2um.inx)
    wdfsimpleum.dll  = 1,,
    ; this guy is really my filter
    filterum.dll  = 1,,
    
    ;-------------- Service installation
    
    [Toaster_Device.NT.Services]
    AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall
    
    [WUDFRD_ServiceInstall]
    DisplayName = %WudfRdDisplayName%
    ServiceType = 1
    StartType = 3
    ErrorControl = 1
    ServiceBinary = %12%\WUDFRd.sys
    
    ;-------------- WDF specific section -------------
    [Toaster_Device.NT.Wdf]
    UmdfService=wdfsimpleum, wdfsimple_Install
    UmdfService=filterum, filter_Install
    UmdfServiceOrder=wdfsimpleum, filterum
    
    [wdfsimple_Install]
    UmdfLibraryVersion=$UMDFVERSION$
    ServiceBinary=%12%\UMDF\wdfsimpleum.dll
    
    [filter_Install]
    UmdfLibraryVersion=$UMDFVERSION$
    ServiceBinary=%12%\UMDF\filterum.dll
    
    [Strings]
    SPSVCINST_ASSOCSERVICE= 0x00000002
    ProviderString = "TODO-Set-Provider"
    StdMfg = "(Standard system devices)"
    DiskId1 = "WDF Sample Toaster Installation Disk #1"
    WdfSimpleDevice.DeviceDesc = "Sample WDF Toaster Service + Filter"
    ClassName = "Toaster"
    WudfRdDisplayName="Windows Driver Foundation - User-mode Driver Framework Reflector"
    
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!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE