Hi all
I modified the minispy minifilter driver to display a DbgPrint log whenever an IRP_MJ_READ is sent to the filesystem. I have 2 test programs: the first program opens a file, mmaps it and closes the file; the second opens a file, reads some data using ReadFile, and closes the file.
(Minifilter FLT_OPERATION_REGISTRATION flag for READ IRP is 0)
Observations after running the first program with minispy attached to the volume in which the file exists:
- The very first time the test program is run, I see an IRP_MJ_READ for that file in the minispy logs (confirmed by using procmon as well). Subsequent runs of the test do not show any IRP_MJ_READ calls.
- I rebooted the system and ran the test. Again, the first run of the test generated an IRP_MJ_READ.
The whole file is read irrespective of what parameter I pass to MapViewOfFile.
Observations after running the second program with minispy attached to the volume in which the file exists:
- Every ReadFile request triggers IRP_MJ_READ.
The number of bytes in FLT_PARAMETERS for IRP_MJ_READ is equal to the number of bytes requested in ReadFile.
Based on these observations, I have some questions:
-
Is there a different cache for mmaped files?
Or in other words, is a mmap request handled by bypassing the file system filter drivers?
(I understand that the filesystem below might be caching data) -
If the above is true, why is it that the first mmap request triggers a READ IRP?
-
If I have a file mmaped by process A, and if process B tries to mmap the same file, will that trigger a READ IRP?
I have gone through related threads on osr, but I m still not clear on how to handle READ IRP. As you can see, I have lots of things in my mind right now.
I am new to minifilter coding, so feel free to correct any mistakes.
Thanks