As before I have a full FSD and not a filter driver. I am running mmap tests which succeed when run against the file system directly, but fail when run through SRV2. I have traced this failure to CcFlushCache, which does not seem to flush anything.
The specific test scenario, is as follows:
H = CreateFileW(“file0”, CREATE_ALWAYS, FILE_FLAG_NO_BUFFERING);
// notice the FILE_FLAG_NO_BUFFERING, it work without it! --+
M = CreateFileMappingW(H);
P = MapViewOfFile(M);
// fill buffer at P with random data
UnmapViewOfFile(P);
P = MapViewOfFile(M);
// test that buffer contains the expected random data
UnmapViewOfFile(M);
CloseHandle(M);
CloseHandle(H);
H = CreateFileW(“file0”, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING);
// notice the FILE_FLAG_NO_BUFFERING, it work without it! --+
M = CreateFileMappingW(H);
P = MapViewOfFile(M);
// test that buffer contains the expected random data <– FAILURE HERE UNDER SRV2!
UnmapViewOfFile(M);
CloseHandle(M);
CloseHandle(H);
I run this test under the debugger (1) directly against the file system and (2) through SRV2. In case (1) I see IRP_MJ_WRITE IRP’s and the test works correctly. In case (2) I never see IRP_MJ_WRITE IRP’s and the test fails.
I have added CcFlushCache in a couple of places trying to resolve this issue. I find that in case (1) the CcFlushCache will always generate IRP_MJ_WRITE IRP’s and that in case (2) it never will. I have traced into CcFlushCache and have seen it call my AcquireForCcFlush and ReleaseForCcFlush. I have also seen it enter the internal Mm routine MiFlushSectionInternal, but this does *not* result in any WRITE IRP’s sent to my FSD. It is as if MiFlushSectionInternal determines that there is nothing to flush!
[Needless to say the test passes on NTFS (via SRV2). So my FSD is at fault.]
The Cc and Mm are a big black box for me and it is unclear how to troubleshoot this further. Your wisdom always appreciated.
Bill