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/


Question regarding Bluetooth BthUsb Filter driver

dhaval_chauhandhaval_chauhan Member Posts: 23
Dear all,

I want to write a filter driver to Intercept the URB's sent from BthUsb.sys.
So my doubt is if this is possible? If yes , is there any example or sample Bluetooth Filter driver that I can refer. I am new to windows driver development so I would appreciate if someone provides the method of doing the same.

Comments

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,490
    No such high specialized sample exists. Best bet is to start with the toaster filter sample and then start adding functionality like an internal IOCTL handler

    d

    Bent from my phone
    ________________________________
    From: [email protected]
    Sent: ?12/?9/?2014 1:20 AM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] Question regarding Bluetooth BthUsb Filter driver

    Dear all,

    I want to write a filter driver to Intercept the URB's sent from BthUsb.sys.
    So my doubt is if this is possible? If yes , is there any example or sample Bluetooth Filter driver that I can refer. I am new to windows driver development so I would appreciate if someone provides the method of doing the same.



    ---
    NTDEV is sponsored by OSR

    Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

    OSR is HIRING!! See http://www.osr.com/careers

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
    d
  • dhaval_chauhandhaval_chauhan Member Posts: 23
    Dear Doran,

    Thanks for the response.
    I have taken mouse KMDF filter device sample from MSDN as reference.
    How to i specify the device on which i have to attach the filter driver?
    What are the things that I have to take care while modifying INX file.

    BR,
    Dhaval
  • dhaval_chauhandhaval_chauhan Member Posts: 23
    Dear Doran,

    I have modified Toaster Inx file as mentioned below.
    If the INX file is ok, How do I install this filter driver?

    [Version]
    Signature = "$WINDOWS NT$"
    Class = Bluetooth
    ClassGuid = {e0cbf06c-cd8b-4647-bb8a-263b43f0f974}
    Provider = %MSFT%
    DriverVer = 12/10/2014,5.00.2064
    CatalogFile = KmdfSamples.cat

    [DestinationDirs]
    DefaultDestDir = 12

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

    [ClassInstall32]
    Addreg=ToasterClassReg
    CopyFiles=ToasterClassInstallerCopyFiles

    [ToasterClassReg]
    HKR,,,0,%ClassName%
    HKR,,Icon,,100
    HKR,,Installer32,,"tostrcls.dll,ToasterClassInstaller"
    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

    [ToasterClassInstallerCopyFiles]
    tostrcls.dll

    ;*****************************************
    ; Toaster Device Filter Install Section
    ;*****************************************

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

    ; For Win2K
    [Standard]
    ; DisplayName Section DeviceId
    ; ----------- ------- --------
    %ToasterFilter.DeviceDesc%=ToasterFilter, USB\VID_0930&PID_0215

    ; For XP and later
    [Standard.NT$ARCH$]
    %ToasterFilter.DeviceDesc%=ToasterFilter, USB\VID_0930&PID_0215


    [ToasterFilter.NT]
    Include=bth.inf
    Needs=BthUsb.NT
    CopyFiles=ToasterFilter.NT.Copy

    [ToasterFilter.NT.Copy]
    filter.sys

    [ToasterFilter.NT.HW]
    AddReg = ToasterFilter.NT.HW.AddReg


    [ToasterFilter.NT.HW.AddReg]
    HKR,,"LowerFilters",0x00010000,"ToasterFilter"

    ;*****************************************
    ; Toaster Device Filter Service Section
    ;*****************************************

    [ToasterFilter.NT.Services]
    ;Do not specify SPSVCINST_ASSOCSERVICE on filter drivers.
    Addservice = BTHUSB, 0x00000002, BthUsb_Service_Inst, BthUsb_EventLog_Inst
    Addservice = BTHPORT, , BthPort_Service_Inst, BthPort_EventLog_Inst
    AddService = ToasterFilter,, filter_Service_Inst

    [filter_Service_Inst]
    DisplayName = %filter.SvcDesc%
    ServiceType = 1 ; SERVICE_KERNEL_DRIVER
    StartType = 3 ; SERVICE_DEMAND_START
    ErrorControl = 1 ; SERVICE_ERROR_NORMAL
    ServiceBinary = %12%\filter.sys

    ;*************************
    ; Source file information
    ;*************************


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

    [SourceDisksFiles]
    filter.sys = 1,,
    tostrcls.dll = 1,,

    ;
    ;--- ToasterFilter Coinstaller installation ------
    ;
    [DestinationDirs]
    ToasterClassInstallerCopyFiles = 11
    ToasterFilter_CoInstaller_CopyFiles = 11

    [ToasterFilter.NT.CoInstallers]
    AddReg = ToasterFilter_CoInstaller_AddReg
    CopyFiles = ToasterFilter_CoInstaller_CopyFiles

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

    [ToasterFilter_CoInstaller_CopyFiles]
    WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll

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

    [ToasterFilter.NT.Wdf]
    KmdfService = ToasterFilter, Filter_wdfsect

    [Filter_wdfsect]
    KmdfLibraryVersion = $KMDFVERSION$

    [Strings]
    SPSVCINST_ASSOCSERVICE = 0x00000002
    MSFT = "Microsoft"
    StdMfg = "(Standard system devices)"
    ClassName = "Toaster"
    DiskId1 = "Toaster Filter Installation Disk #1"
    ToasterFilter.DeviceDesc = "Microsoft Toaster Filter"
    filter.SvcDesc = "Microsoft Toaster Filter Driver Refactored"
    Toaster.SVCDESC = "Microsoft WDF Toaster Featured Device Driver"
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,490
    You don't need the coinstaller or security stuff

    d

    Bent from my phone
    ________________________________
    From: [email protected]
    Sent: ?12/?9/?2014 11:54 AM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] Question regarding Bluetooth BthUsb Filter driver

    Dear Doran,

    I have modified Toaster Inx file as mentioned below.
    If the INX file is ok, How do I install this filter driver?

    [Version]
    Signature = "$WINDOWS NT$"
    Class = Bluetooth
    ClassGuid = {e0cbf06c-cd8b-4647-bb8a-263b43f0f974}
    Provider = %MSFT%
    DriverVer = 12/10/2014,5.00.2064
    CatalogFile = KmdfSamples.cat

    [DestinationDirs]
    DefaultDestDir = 12

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

    [ClassInstall32]
    Addreg=ToasterClassReg
    CopyFiles=ToasterClassInstallerCopyFiles

    [ToasterClassReg]
    HKR,,,0,%ClassName%
    HKR,,Icon,,100
    HKR,,Installer32,,"tostrcls.dll,ToasterClassInstaller"
    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

    [ToasterClassInstallerCopyFiles]
    tostrcls.dll

    ;*****************************************
    ; Toaster Device Filter Install Section
    ;*****************************************

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

    ; For Win2K
    [Standard]
    ; DisplayName Section DeviceId
    ; ----------- ------- --------
    %ToasterFilter.DeviceDesc%=ToasterFilter, USB\VID_0930&PID_0215

    ; For XP and later
    [Standard.NT$ARCH$]
    %ToasterFilter.DeviceDesc%=ToasterFilter, USB\VID_0930&PID_0215


    [ToasterFilter.NT]
    Include=bth.inf
    Needs=BthUsb.NT
    CopyFiles=ToasterFilter.NT.Copy

    [ToasterFilter.NT.Copy]
    filter.sys

    [ToasterFilter.NT.HW]
    AddReg = ToasterFilter.NT.HW.AddReg


    [ToasterFilter.NT.HW.AddReg]
    HKR,,"LowerFilters",0x00010000,"ToasterFilter"

    ;*****************************************
    ; Toaster Device Filter Service Section
    ;*****************************************

    [ToasterFilter.NT.Services]
    ;Do not specify SPSVCINST_ASSOCSERVICE on filter drivers.
    Addservice = BTHUSB, 0x00000002, BthUsb_Service_Inst, BthUsb_EventLog_Inst
    Addservice = BTHPORT, , BthPort_Service_Inst, BthPort_EventLog_Inst
    AddService = ToasterFilter,, filter_Service_Inst

    [filter_Service_Inst]
    DisplayName = %filter.SvcDesc%
    ServiceType = 1 ; SERVICE_KERNEL_DRIVER
    StartType = 3 ; SERVICE_DEMAND_START
    ErrorControl = 1 ; SERVICE_ERROR_NORMAL
    ServiceBinary = %12%\filter.sys

    ;*************************
    ; Source file information
    ;*************************


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

    [SourceDisksFiles]
    filter.sys = 1,,
    tostrcls.dll = 1,,

    ;
    ;--- ToasterFilter Coinstaller installation ------
    ;
    [DestinationDirs]
    ToasterClassInstallerCopyFiles = 11
    ToasterFilter_CoInstaller_CopyFiles = 11

    [ToasterFilter.NT.CoInstallers]
    AddReg = ToasterFilter_CoInstaller_AddReg
    CopyFiles = ToasterFilter_CoInstaller_CopyFiles

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

    [ToasterFilter_CoInstaller_CopyFiles]
    WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll

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

    [ToasterFilter.NT.Wdf]
    KmdfService = ToasterFilter, Filter_wdfsect

    [Filter_wdfsect]
    KmdfLibraryVersion = $KMDFVERSION$

    [Strings]
    SPSVCINST_ASSOCSERVICE = 0x00000002
    MSFT = "Microsoft"
    StdMfg = "(Standard system devices)"
    ClassName = "Toaster"
    DiskId1 = "Toaster Filter Installation Disk #1"
    ToasterFilter.DeviceDesc = "Microsoft Toaster Filter"
    filter.SvcDesc = "Microsoft Toaster Filter Driver Refactored"
    Toaster.SVCDESC = "Microsoft WDF Toaster Featured Device Driver"



    ---
    NTDEV is sponsored by OSR

    Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

    OSR is HIRING!! See http://www.osr.com/careers

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
    d
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,403
    [email protected] wrote:
    > I have modified Toaster Inx file as mentioned below.

    Does your device actually have VID=0930 and PID=0215?


    > If the INX file is ok, How do I install this filter driver?

    This INF does not just install a filter driver. (In fact, you can't use
    an INF to install only a filter driver.) This INF is the ENTIRE driver,
    and it happens to include a filter. So, you could go to Device Manager,
    find the device, do Update Driver, and point it to your driver package.

    Your driver package will need to include the INF, your SYS, the
    co-installer, and your CAT file (if you built one).

    You might want to consider cleaning up some things. For example, you
    are not Microsoft, so you shouldn't identify yourself as such. This is
    not a Toaster device, and you really should use a name other than
    "filter.sys".

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

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

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,403
    Doron Holan wrote:
    > You don't need the coinstaller or security stuff

    ...unless you need to run on systems prior to Win 7...

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

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

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,490
    The security section and toaster co installer can be jettisoned regardless of target os, I wasn't speaking to the wdf coinstaller.

    d

    Bent from my phone
    ________________________________
    From: Tim Roberts
    Sent: ?12/?9/?2014 2:25 PM
    To: Windows System Software Devs Interest List
    Subject: Re: [ntdev] Question regarding Bluetooth BthUsb Filter driver

    Doron Holan wrote:
    You don't need the coinstaller or security stuff

    ...unless you need to run on systems prior to Win 7...

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


    ---
    NTDEV is sponsored by OSR

    Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

    OSR is HIRING!! See http://www.osr.com/careers

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
    d
  • dhaval_chauhandhaval_chauhan Member Posts: 23
    Dear Doran,

    I have modified the INX file as u suggested.

    [Version]
    Signature = "$WINDOWS NT$"
    Class = Bluetooth
    ClassGuid = {e0cbf06c-cd8b-4647-bb8a-263b43f0f974}
    Provider = %MSFT%
    DriverVer = 12/10/2014,5.00.2064
    CatalogFile = KmdfSamples.cat

    [DestinationDirs]
    DefaultDestDir = 12

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

    [ClassInstall32]
    Addreg=ToasterClassReg
    CopyFiles=ToasterClassInstallerCopyFiles

    [ToasterClassReg]
    HKR,,,0,%ClassName%
    HKR,,Icon,,100
    HKR,,Installer32,,"tostrcls.dll,ToasterClassInstaller"
    HKR,,DeviceCharacteristics,0x10001,0x100 ;Use same security checks on relative opens

    [ToasterClassInstallerCopyFiles]
    tostrcls.dll

    ;*****************************************
    ; Toaster Device Filter Install Section
    ;*****************************************

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

    ; For Win2K
    [Standard]
    ; DisplayName Section DeviceId
    ; ----------- ------- --------
    %ToasterFilter.DeviceDesc%=ToasterFilter, USB\VID_0930&PID_0215

    ; For XP and later
    [Standard.NT$ARCH$]
    %ToasterFilter.DeviceDesc%=ToasterFilter, USB\VID_0930&PID_0215


    [ToasterFilter.NT]
    Include=bth.inf
    Needs=BthUsb.NT
    CopyFiles=ToasterFilter.NT.Copy

    [ToasterFilter.NT.Copy]
    filter.sys

    [ToasterFilter.NT.HW]
    AddReg = ToasterFilter.NT.HW.AddReg


    [ToasterFilter.NT.HW.AddReg]
    HKR,,"LowerFilters",0x00010000,"ToasterFilter"

    ;*****************************************
    ; Toaster Device Filter Service Section
    ;*****************************************

    [ToasterFilter.NT.Services]
    ;Do not specify SPSVCINST_ASSOCSERVICE on filter drivers.
    Addservice = BTHUSB, 0x00000002, BthUsb_Service_Inst, BthUsb_EventLog_Inst
    Addservice = BTHPORT, , BthPort_Service_Inst, BthPort_EventLog_Inst
    AddService = ToasterFilter,, filter_Service_Inst

    [filter_Service_Inst]
    DisplayName = %filter.SvcDesc%
    ServiceType = 1 ; SERVICE_KERNEL_DRIVER
    StartType = 3 ; SERVICE_DEMAND_START
    ErrorControl = 1 ; SERVICE_ERROR_NORMAL
    ServiceBinary = %12%\filter.sys

    ;*************************
    ; Source file information
    ;*************************


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

    [SourceDisksFiles]
    filter.sys = 1,,
    tostrcls.dll = 1,,

    [Strings]
    SPSVCINST_ASSOCSERVICE = 0x00000002
    MSFT = "Test"
    StdMfg = "(Standard system devices)"
    ClassName = "Toaster"
    DiskId1 = "Toaster Filter Installation Disk #1"
    ToasterFilter.DeviceDesc = "Microsoft Toaster Filter"
    filter.SvcDesc = "Microsoft Toaster Filter Driver Refactored"
    Toaster.SVCDESC = "Microsoft WDF Toaster Featured Device Driver"

    How do I install this as lower filter driver to BthUSB ? I have searched many forums without any luck.
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,490
    You don't need any of this
    ================= Class section =====================

    [ClassInstall32]
    Addreg=ToasterClassReg
    CopyFiles=ToasterClassInstallerCopyFiles

    [ToasterClassReg]
    HKR,,,0,%ClassName%
    HKR,,Icon,,100
    HKR,,Installer32,,"tostrcls.dll,ToasterClassInstaller"
    HKR,,DeviceCharacteristics,0x10001,0x100 ;Use same security checks on relative opens

    [ToasterClassInstallerCopyFiles]
    tostrcls.dll

    You install it by opening device manager, selecting the radio device and updating the driver, pointing to your inf


    d

    Bent from my phone
    ________________________________
    From: [email protected]
    Sent: ?12/?9/?2014 11:44 PM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] Question regarding Bluetooth BthUsb Filter driver

    Dear Doran,

    I have modified the INX file as u suggested.

    [Version]
    Signature = "$WINDOWS NT$"
    Class = Bluetooth
    ClassGuid = {e0cbf06c-cd8b-4647-bb8a-263b43f0f974}
    Provider = %MSFT%
    DriverVer = 12/10/2014,5.00.2064
    CatalogFile = KmdfSamples.cat

    [DestinationDirs]
    DefaultDestDir = 12

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

    [ClassInstall32]
    Addreg=ToasterClassReg
    CopyFiles=ToasterClassInstallerCopyFiles

    [ToasterClassReg]
    HKR,,,0,%ClassName%
    HKR,,Icon,,100
    HKR,,Installer32,,"tostrcls.dll,ToasterClassInstaller"
    HKR,,DeviceCharacteristics,0x10001,0x100 ;Use same security checks on relative opens

    [ToasterClassInstallerCopyFiles]
    tostrcls.dll

    ;*****************************************
    ; Toaster Device Filter Install Section
    ;*****************************************

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

    ; For Win2K
    [Standard]
    ; DisplayName Section DeviceId
    ; ----------- ------- --------
    %ToasterFilter.DeviceDesc%=ToasterFilter, USB\VID_0930&PID_0215

    ; For XP and later
    [Standard.NT$ARCH$]
    %ToasterFilter.DeviceDesc%=ToasterFilter, USB\VID_0930&PID_0215


    [ToasterFilter.NT]
    Include=bth.inf
    Needs=BthUsb.NT
    CopyFiles=ToasterFilter.NT.Copy

    [ToasterFilter.NT.Copy]
    filter.sys

    [ToasterFilter.NT.HW]
    AddReg = ToasterFilter.NT.HW.AddReg


    [ToasterFilter.NT.HW.AddReg]
    HKR,,"LowerFilters",0x00010000,"ToasterFilter"

    ;*****************************************
    ; Toaster Device Filter Service Section
    ;*****************************************

    [ToasterFilter.NT.Services]
    ;Do not specify SPSVCINST_ASSOCSERVICE on filter drivers.
    Addservice = BTHUSB, 0x00000002, BthUsb_Service_Inst, BthUsb_EventLog_Inst
    Addservice = BTHPORT, , BthPort_Service_Inst, BthPort_EventLog_Inst
    AddService = ToasterFilter,, filter_Service_Inst

    [filter_Service_Inst]
    DisplayName = %filter.SvcDesc%
    ServiceType = 1 ; SERVICE_KERNEL_DRIVER
    StartType = 3 ; SERVICE_DEMAND_START
    ErrorControl = 1 ; SERVICE_ERROR_NORMAL
    ServiceBinary = %12%\filter.sys

    ;*************************
    ; Source file information
    ;*************************


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

    [SourceDisksFiles]
    filter.sys = 1,,
    tostrcls.dll = 1,,

    [Strings]
    SPSVCINST_ASSOCSERVICE = 0x00000002
    MSFT = "Test"
    StdMfg = "(Standard system devices)"
    ClassName = "Toaster"
    DiskId1 = "Toaster Filter Installation Disk #1"
    ToasterFilter.DeviceDesc = "Microsoft Toaster Filter"
    filter.SvcDesc = "Microsoft Toaster Filter Driver Refactored"
    Toaster.SVCDESC = "Microsoft WDF Toaster Featured Device Driver"

    How do I install this as lower filter driver to BthUSB ? I have searched many forums without any luck.


    ---
    NTDEV is sponsored by OSR

    Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

    OSR is HIRING!! See http://www.osr.com/careers

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
    d
  • dhaval_chauhandhaval_chauhan Member Posts: 23
    Hi doran,
    I modified the inx file and followed the steps u mentioned in the previous message.

    In device manager I have Intel Bluetooth 4.0 device. When I right click and try to update the driver software, it always shows a dialog mentioning that your device is up to date and I am unable to see the filter in the device tree.

    BR,
    Dhaval
  • dhaval_chauhandhaval_chauhan Member Posts: 23
    Hi doran,

    Thanks for your help. I was able to successfully install the filter driver.
    Now Trying to check if I can intercept URB's sent by BthUsb

    BR,
    Dhaval
  • dhaval_chauhandhaval_chauhan Member Posts: 23
    Hi Doran,

    I was able to intercept URB's in my filter driver and am able to parse HCI commands.
    I am facing a strange issue when I do a device sleep and resume.

    When I do a resume after sleep I see a yellow bang shown in device manager on my bluetooth filter driver. To recover I have to re-install the Bluetooth Filter drivers provided by vendor (Intel Bluetooth Filter Drivers in my case).

    I am also not able to uninstall my filter driver alone. When I try to uninstall my bluetooth filter driver it uninstalls all the other filter drivers attached to BthUsb.

    Do u have any solution for this problem ?

    BR,
    Dhaval
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,403
    [email protected] wrote:
    > I was able to intercept URB's in my filter driver and am able to parse HCI commands.
    > I am facing a strange issue when I do a device sleep and resume.
    >
    > When I do a resume after sleep I see a yellow bang shown in device manager on my bluetooth filter driver. To recover I have to re-install the Bluetooth Filter drivers provided by vendor (Intel Bluetooth Filter Drivers in my case).

    Then you have a bug that you need to chase down. We don't have any of
    your code, so there's nothing we can do. What was the failure code for
    the yellow bang? What does your debug trace show? You didn't try to
    make yourself the power policy owner for the device, did you?


    > I am also not able to uninstall my filter driver alone. When I try to uninstall my bluetooth filter driver it uninstalls all the other filter drivers attached to BthUsb.

    Right. That's because you created a complete INF, with the original
    driver plus your filter. Your INF is now the complete driver for that
    device. When you remove your driver, you have to give it another
    complete driver.

    It is certainly possible to add and remove filter drivers individually,
    without uninstalling the other drivers in the stack, but you can't do
    that with an INF. Remember, adding a filter driver to a device is no
    more complicated than adding your filter's service name to the
    UpperFilters or LowerFilters key in the registry and restarting the
    device. That's literally ALL IT TAKES. You can do that with an
    application. Use the SetupDi APIs to find your device's node, then use
    SetupDiGetDeviceRegistryProperty and SetupDiSetDeviceRegistryProperty to
    modify the registry key, then use SetupDiSetClassInstallParams and
    SetupDiCallClassInstaller to restart the device (stolen from devcon).

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

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

  • dhaval_chauhandhaval_chauhan Member Posts: 23
    Hi Tim,
    Thanks for the reply.
    Regarding the sleep and resume yellow bang issue, my code is the similar to toaster filter driver code.
    I am not handling anything related to power policy management.
    The only additional code which I have added is as follows

    In FilterEvtDeviceAdd function
    ioQueueConfig.EvtIoInternalDeviceControl = FilterEvtIoInternalDeviceControl;

    // FilterEvtIoInternalDeviceControl function
    VOID
    FilterEvtIoInternalDeviceControl(
    IN WDFQUEUE Queue,
    IN WDFREQUEST Request,
    IN size_t OutputBufferLength,
    IN size_t InputBufferLength,
    IN ULONG IoControlCode
    ) {
    PFILTER_EXTENSION filterExt;
    NTSTATUS status = STATUS_SUCCESS;
    WDFDEVICE device;

    UNREFERENCED_PARAMETER(OutputBufferLength);
    UNREFERENCED_PARAMETER(InputBufferLength);

    device = WdfIoQueueGetDevice(Queue);

    filterExt = FilterGetData(device);

    switch (IoControlCode) {
    //
    // Put your cases for handling IOCTLs here
    //

    case IOCTL_INTERNAL_USB_SUBMIT_URB:
    {
    PURB pUrb;

    pUrb = (PURB)IoGetCurrentIrpStackLocation(WdfRequestWdmGetIrp(Request))->Parameters.Others.Argument1;

    switch (pUrb->UrbHeader.Function)
    {
    case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: {
    // My code Here
    break;
    }
    case URB_FUNCTION_CLASS_DEVICE: {
    // My code Here
    break;
    }
    default :
    break;
    }
    default:
    //status = STATUS_INVALID_DEVICE_REQUEST;
    break;
    }

    if (!NT_SUCCESS(status)) {
    WdfRequestComplete(Request, status);
    return;
    }

    //
    // Forward the request down. WdfDeviceGetIoTarget returns
    // the default target, which represents the device attached to us below in
    // the stack.
    //
    #if FORWARD_REQUEST_WITH_COMPLETION
    //
    // Use this routine to forward a request if you are interested in post
    // processing the IRP.
    //
    FilterForwardRequestWithCompletionRoutine(Request,
    WdfDeviceGetIoTarget(device));
    #else
    FilterForwardRequest(Request, WdfDeviceGetIoTarget(device));
    #endif

    return;
    }

    BR,
    Dhaval
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