Some of the cases which you need to handle are 1) During a cached write,
if the write is an extending write then you need to call into the file
system and either extend the file size via a setfileinfo() call or write
out encrypted zeroes to extend the file size. These IOs must be
non-cached writes so they don’t effect the cache. 2) During a
setfileinfo() call, you need to add your header size onto this. If this
new size extends the file size then you need to, again, extend the file
on disk. You can do this by writing out encrypted zeros or by simply
setting the size passed down to the extended size. Note that in either
case above, if you don’t write out encrypted zeros when extending the
file then you need to internally track what part of the file is actually
encrypted so if a read is processed for a non-encrypted region you do
not decrypt a zero filled buffer. 3) Non-cached, non-paging writes are
another area but since they can extend the file length they are handled
as a non-cached write request.
Finally, when a paging write is being processed, the file size in the
file system;i.e. on disk, must already be large enough to accommodate
the write adjusted for your header length. You will run into too many
problems if you attempt to extend the file at the time of the paging
write, such as an asynchronous request, etc.
Pete
On 7/18/2014 12:23 AM, xxxxx@gmail.com wrote:
Thanks Peter.
I processed IRP_MJ_QUERY_INFORMATION for returning modified length,
but I didn’t change FSRTL_COMMON_FCB_HEADER.AllocationSize/FileSize/ValidDataLength.
For a encrypted file, these values are the encrypted file real size,
and so in CM, the file cache size is also the encrypted file real size.
File in Disk: XXXX(FileHeader,4K) DDDD(FileEncryptedData,4K)
File in Cache: DDDD(FilePlainData, 4K) ???(4K)
FCB_HEADER is used in NT and FSD, so i think i shouldn’t change AllocationSize/FileSize/ValidDataLength in FSRTL_COMMON_FCB_HEADER.
am I wrong?? In CM the file size should be modified size or real size?? i am a little confused.
> You need to have the file sizes adjusted correctly…
Sorry, I not quite understand how to adjust the file size correct,
in my example, CcZeroData is invoked by FSD and i don’t have chance to adjust the file size.
NTFSD is sponsored by OSR
OSR is hiring!! Info at http://www.osr.com/careers
For our schedule of debugging and file system 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
–
Kernel Drivers
Windows File System and Device Driver Consulting
www.KernelDrivers.com
866.263.9295