How can I read a file before writing the file?
I want to redirect file A to file B(i.e. an write request for file A will
be redirected to write file B other than file A).
I deal with them by intercepting IRP_MJ_WRITE .
now I define :
BOOLEAN Flag = (Irp->Flags & (IRP_NOCACHE | IRP_PAGING_IO |
IRP_SYNCHRONOUS_PAGING_IO));
Flag==FALSE means IRP DOES NOT write data to disk.
(1)NORMALLY, when writing file A , there are two different IRP containing
IRP_MJ_WRITE:
one’s Flag is FALSE , the other’s Flag is TRUE.
in this case, i can copy the file A to file B by constructing an synchronous
IRP for reading file A and write data to file B when Flag is FALSE.
(2)ABNORMALLY, when writing file A , there are only one IRP containing
IRP_MJ_WRITE:
and its Flag is TRUE. this can happen when FILE_NO_INTERMEDIATE_BUFFERING
and FILE_WRITE_THROUGH is set.
in this case, i cannot construct an synchronous IRP for reading the file A
when Flag is TRUE, it seems like file A is locked and os is down.
how can i read file A in this case?