Hi,
In my mini filter while saving a file I need to add a header to that
file (not a tail). I have handled the callbacks for the IRPS (Query
Information, Directory control) to fake the file size. The solution is
working fine when I am using editors like notepad, textpad.exe.
Problem is specifically seen with Visual Studio 2003 editor
(Devenv.exe). Let’s say the size of my header is 125 bytes and size of the
actual contents is 7 bytes. When the file is being read I skip the header.
Thus the above mentioned editor sees only 7 bytes. Now I type some more
characters (less then 125) in the file and save the file. In my callback for
the Write operation I see only writes with IRP_NOCACHE and IRP_PAGING_IO
flags set. I have performed the buffer swapping correctly and added my
header to the new buffer that I allocate. However, when the file is written
to the disk I can see 7 bytes of my header being written. I understand this
is because file size cannot be extended in paging I/O path. Please correct
me if I am wrong. (I also tried modifying the ValidDataLength member if the
FileObject->FsContext).
If however, the number of characters typed by me is greater then 125, I
get the IRP_MJ_SET_INFORMATION call in the mini filter where I set the end
of file information correctly and all works well. My problem is when the
number of characters typed is less then 125.
Thanks in advance,
Vishal
Hi,
Consider this simple scenario where the Visual Studio 2003 editor is
creating a new file. In this new file I type characters “abc” and save the
file as Test.txt. In my pre-write call (This is a write with the IRP_NOCACHE
and IRP_PAGING_IO flags set. I verified this using the FileMon utility) I
swap the buffers and set the contents of the new buffer as “HEADERabc”.
However, when the file is saved to the disk I can only see the characters
“abc”. I do not receive any non paging write or set information calls
(verified this with FileMon).
I am definitely missing something over here. Kindly help me with this.
Thanks,
Vishal
From: Vishal Pai [mailto:xxxxx@persistent.co.in]
Sent: Friday, April 21, 2006 1:02 AM
To: ‘xxxxx@lists.osr.com’
Subject: Adding a header to the file while it is being written.
Hi,
In my mini filter while saving a file I need to add a header to that
file (not a tail). I have handled the callbacks for the IRPS (Query
Information, Directory control) to fake the file size. The solution is
working fine when I am using editors like notepad, textpad.exe.
Problem is specifically seen with Visual Studio 2003 editor
(Devenv.exe). Let’s say the size of my header is 125 bytes and size of the
actual contents is 7 bytes. When the file is being read I skip the header.
Thus the above mentioned editor sees only 7 bytes. Now I type some more
characters (less then 125) in the file and save the file. In my callback for
the Write operation I see only writes with IRP_NOCACHE and IRP_PAGING_IO
flags set. I have performed the buffer swapping correctly and added my
header to the new buffer that I allocate. However, when the file is written
to the disk I can see 7 bytes of my header being written. I understand this
is because file size cannot be extended in paging I/O path. Please correct
me if I am wrong. (I also tried modifying the ValidDataLength member if the
FileObject->FsContext).
If however, the number of characters typed by me is greater then 125, I
get the IRP_MJ_SET_INFORMATION call in the mini filter where I set the end
of file information correctly and all works well. My problem is when the
number of characters typed is less then 125.
Thanks in advance,
Vishal