none
Passing Driver specific IOCTLs to file system mini filter driver? RRS feed

  • Question

  • I worked on disk filter drivers using KMDF. In this if I want to pass IOCTL to this specific driver, for that we can create control device and from user side we can open this device and pass our own created IOCTL to this driver.

    we create control device in KMDF based filter driver:

    1. WdfControlDeviceInitAllocate()

    2.WdfDeviceInitSetExclusive()

    3.WdfDeviceInitAssignName()

    4. WdfDeviceInitSetFileObjectConfig()

    5.WdfDeviceCreate()

    6.WdfDeviceCreateSymbolicLink()

    7.WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE()

    6.ioQueueConfig.EvtIoDeviceControl = WdfFltrAppIntDeviceControl; //assigning device control method to queue.

    8.WdfIoQueueCreate()

    9.WdfControlFinishInitializing()

    I create control device in AddDevice routine but in mini filter driver there is no adddevice routine so where exactly do i implement it?

    I am new to mini filter driver. What if I want to implement my own IOCTLs and pass it to mini filter driver. How can I pass our own created IOCTLs to mini filter driver. Like Do I need to create a control device ??? Or there is some sample available on msdn (file system minifilter driver sample??) or what sort of things or apis do I need to do ?



    Monday, April 14, 2014 8:04 PM

Answers

  • Yes you can define your own code for IRP_MJ_DEVICE_CONTROL.  I personally would use a communications port, it is easier than creating a control device.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Monday, April 14, 2014 8:49 PM

All replies

  • I'm going to assume this is for a mini-filters, and all your description of WDF was there to say you want to do something similar.

    The first question is what are you trying to do?  A mini-filter can recieve control requests, as IRP_MJ_DEVICE_CONTROL, IRP_MJ_FILE_SYSTEM_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROL.  If you are doing something that is file specific or volume specific you should use those.   If you are looking to communicate with user space you look at communication ports (see FltCreateCommunicationPort and the related samples), since that is a better way to do this.

    So before we go into more detail, does any of the above which covers almost all the cases seem like what you need?


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Monday, April 14, 2014 8:20 PM
  • Yes, I want to implement similarly like what I have done through KMDF (in disk filter driver) and now I have to write a mini filter driver in that I want to do similarly.

    See there will be a user space application that will send IOCTL to my mini filter driver and this IOCTL will return some information into OutputBuffer parameter. This information can be any general information like some statistics. So I want to pass my own IOCTL to my driver that just can understand the IOCTL and return some information or set some information in driver depends on IOCTL code. I do not think so that I need use FltCreateCommunicationPort. Did you get it what am I trying to do ??

    And IRP_MJ_DEVICE_CONTROL will have some predefined IOCTLs code, right?? but I want to pass my own created IOCTL code. So for this I think I need to create IOCTL code in user application and including that header file in minifilter driver also but in DeviceIoControl first parameter is handle to device or file. So what handle I will pass into DeviceIocontrol ? Like in KMDF driver I create my control device and I open that device in user application so what do  I need to do it here ??




    Monday, April 14, 2014 8:35 PM
  • Yes you can define your own code for IRP_MJ_DEVICE_CONTROL.  I personally would use a communications port, it is easier than creating a control device.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Monday, April 14, 2014 8:49 PM
  • Do I need to create control device here in minifilter driver? If not then I need to create IOCTL code in user application and including that header file in minifilter driver also but in DeviceIoControl first parameter is handle to device or file. So what handle I will pass into DeviceIocontrol ? Like in KMDF driver I create my control device and I open that device in user application so what do  I need to do it here ??
    Monday, April 14, 2014 9:00 PM
  • You will actually see the call if you use any handle to a file on the volume.  The other options as I have said are communication ports (which is the normal way to do this for a mini-filter, but is not an IOCTL), or you can create a control device (but that has challenges for management).


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Monday, April 14, 2014 9:49 PM