none
Basic questions about the KMDF storage filter RRS feed

  • Question

  • Hi all,

    I am a new guy , not familiar with the Windows Device/Driver .

    Now I need to use KMDF to make a driver filter for storage . 

    I have read some articles and samples. (RAMDisk,AddFilter etc)



    Could anyone help me for thest questions , and give me more suggestions ? I may not descript it well .


    1 - How can a desktop app install/uninstall the filter without reboot ?
    (Want the names of some key functions)

    2 - How to insert the filter to the correct position , between the lower PDO and Windows Disk Cache 
    (If the data is cached , it shall not call myfilter.sys , and if myfilter.sys call lower PDO, it shall not be cached)

    3 - When any desktop app use CreateFile with FILE_FLAG_NO_BUFFERING , how myfilter.sys detect that ?

    4 - In myfilter.sys code , can it call CreateFile/ReadFile/WriteFile ?
    (Or any other functions I can use ?)

    5 - If #4 is OK , How to determine whether the IRQ is sent when myfilter.sys call CreateFile/ReadFile/WriteFile ?
    (To avoid some recursive/block problems.)


    6 - Can myfilter.sys code execute the lower PDO directy without CreateFile/ReadFile/WriteFile ? 
    (Create an new IRQ and wait for the result ?)


    7 - Shall I create a new temp device and make a symlink on this device to communicate with desktop app ?
    (Or use NamedPipe ? any other way is better.)

    8 - In myfilter.sys , how to get the special information of a disk , for example , 'How many times the power on'

    9 - I plan to support XP later , shall I go with WDM directly instead of the KMDF , 
    (Or use KMDF will be easier , when I have more experience , migrate to XP later?)



    Thank you very much.

    Regards,

    NS.






    Wednesday, May 1, 2013 6:53 AM

Answers

  • As to the questions:

    1 - How can a desktop app install/uninstall the filter without reboot ?

        You can't do this, by the time user space is running other drivers are above the disk.  At best you can make your functions become pass through. 

    2 - How to insert the filter to the correct position , between the lower PDO and Windows Disk Cache

        The caching occurs at the file system layer.  If you are a disk filter just install yourself as an upper disk filter. 

    3 - When any desktop app use CreateFile with FILE_FLAG_NO_BUFFERING , how myfilter.sys detect that ?

        Setup file object callbacks using WdfDeviceInitSetFileObjectConfig the flag is in the options of request parameters.  But, at this level you are handling file system requests which are not going to use many of the flags.

    4 - In myfilter.sys code , can it call CreateFile/ReadFile/WriteFile ?

    5 - If #4 is OK , How to determine whether the IRQ is sent when myfilter.sys call CreateFile/ReadFile/WriteFile ?
    (To avoid some recursive/block problems.)

    6 - Can myfilter.sys code execute the lower PDO directy without CreateFile/ReadFile/WriteFile ?
    (Create an new IRQ and wait for the result ?)

         It sounds like from these questions you are thinking files.  You can use ZwCreateFile and similar to open files but you can't avoid the recursion since you at the disk level don't know about files.  If you are trying to access portions of the disk below you you can create requests to directly feed to the disk driver.  Note: these are IRP's not IRQ's.

    7 - Shall I create a new temp device and make a symlink on this device to communicate with desktop app ?

        You create a device, this is known as a control device.

    8 - In myfilter.sys , how to get the special information of a disk

        You create and issue requests to the lower driver.  Your example makes no sense, but there is a lot of information you can get, look at the disk driver sample (which is the actual windows disk driver) for details of what is below you.

    9 - I plan to support XP later , shall I go with WDM directly instead of the KMDF

         XP and for that matter Windows 2000 support KMDF, so it has nothing to do with you design.  Just check the functions you are using to ensure they all are supported by the operating systems you want to support.

        


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

    Wednesday, May 1, 2013 11:43 AM

All replies

  • As to the questions:

    1 - How can a desktop app install/uninstall the filter without reboot ?

        You can't do this, by the time user space is running other drivers are above the disk.  At best you can make your functions become pass through. 

    2 - How to insert the filter to the correct position , between the lower PDO and Windows Disk Cache

        The caching occurs at the file system layer.  If you are a disk filter just install yourself as an upper disk filter. 

    3 - When any desktop app use CreateFile with FILE_FLAG_NO_BUFFERING , how myfilter.sys detect that ?

        Setup file object callbacks using WdfDeviceInitSetFileObjectConfig the flag is in the options of request parameters.  But, at this level you are handling file system requests which are not going to use many of the flags.

    4 - In myfilter.sys code , can it call CreateFile/ReadFile/WriteFile ?

    5 - If #4 is OK , How to determine whether the IRQ is sent when myfilter.sys call CreateFile/ReadFile/WriteFile ?
    (To avoid some recursive/block problems.)

    6 - Can myfilter.sys code execute the lower PDO directy without CreateFile/ReadFile/WriteFile ?
    (Create an new IRQ and wait for the result ?)

         It sounds like from these questions you are thinking files.  You can use ZwCreateFile and similar to open files but you can't avoid the recursion since you at the disk level don't know about files.  If you are trying to access portions of the disk below you you can create requests to directly feed to the disk driver.  Note: these are IRP's not IRQ's.

    7 - Shall I create a new temp device and make a symlink on this device to communicate with desktop app ?

        You create a device, this is known as a control device.

    8 - In myfilter.sys , how to get the special information of a disk

        You create and issue requests to the lower driver.  Your example makes no sense, but there is a lot of information you can get, look at the disk driver sample (which is the actual windows disk driver) for details of what is below you.

    9 - I plan to support XP later , shall I go with WDM directly instead of the KMDF

         XP and for that matter Windows 2000 support KMDF, so it has nothing to do with you design.  Just check the functions you are using to ensure they all are supported by the operating systems you want to support.

        


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

    Wednesday, May 1, 2013 11:43 AM
  • Don Burn,

    Thank you very much, your info is very helpful for me.

    I can start my filter now.

    Thanks again !!!

    Regards,

    NS

    Thursday, May 2, 2013 9:06 AM