Thanks again for helping me. Now I am able to update the data of the MDL.
I referred Disk Performance monitor to develop my filter driver. As I sad I want to encrypt the data while writing and decrypt the data on reading. I observed driver is trapping the read and write request to the disk. Problem is there is some inconsistency between the read and write request.
Suppose I want to open a file from a drive on the very first time driver gets read request, but next time if I want to open the same file it is not getting any request. But every time I want to save the file, driver gets the write request. How can I eliminate this inconsistency , which is creating a great problem for doing encryption and decryption properly.
I had written a small filter driver. Which is attached to all the partitions of the hard disk. Driver is receiving all the read and write request to the disk. Now I want to update the use data. I set device object flag to DO_DIRECT_IO. Right now I just want to increase the stored value by one ASCII value. I am doing the following.
StoreUserMdl = Irp -> MdlAddress;
while ( StoreUserMdl != NULL )
UserData = (PCHAR) ( * (PCHAR) StoreUserMdl -> StartVa + StoreUserMdl -> ByteOffset );
if ( irpStack -> MajorFunction == IRP_MJ_WRITE )
for ( Count = 0; Count <= StoreUserMdl -> ByteCount; Count ++ )
++ * ( UserData + Count );
StoreUserMdl = StoreUserMdl -> Next;
On loading driver page fault occurs. I think it is because of some page locks. I am not very clear about the MDL mechanism, and also not very confident with my approach. Is it a correct way of accessing the user data? or I have to do some thing else.