I developped a filter.In the IRP_MJ_CREATE,I will ZwCreateFile(by Shadow DO),QueryInformation,Read some Data,and ZwClose.
It works well in local system and RDR.
But if it works in win2K3(as the file server),the client save a doc file,it will fail.
I observed these:
if my filter didn’t work,everything is OK.
if my filter worked on the file server(win2K3),the client save a doc file will fail.
the OK case:
System:4 IRP_MJ_CREATE D:\Test\test.doc SUCCESS Options: OverwriteIf Access: All
System:4 IRP_MJ_CREATE D:\Test\test.doc OPLOCK BREAK Options: Open Access: All
System:4 FSCTL_OPLOCK_BREAK_NOTIFY D:\Test\test.doc SUCCESS
System:4 IRP_MJ_CLEANUP D:\Test\test.doc SUCCESS
System:4 IRP_MJ_CLOSE D:\Test\test.doc SUCCESS
the failed case:
System:4 IRP_MJ_CREATE D:\Test\test.doc SUCCESS Options: OverwriteIf Access: All
…the IRP_MJ_CREATE from my filter is to Shadow DO,so can’t see it…
…the IRP_MJ_CLEANUP and IRP_MJ_CLOSE from my filter…
System:4 IRP_MJ_CREATE D:\Test\test.doc SHARING VIOLATION Options: Open Access: All
Any body can explain it?and what should I do?thanks ~~~~
the code frag from my filter described my behavior before original IRP_MJ_CREATE:
…
Status = ZwCreateFile(&hFile, // returned file handle
(SYNCHRONIZE | FILE_READ_ATTRIBUTES), // desired access
&ObjectAttributes, // ptr to object attributes
&IoStatus, // ptr to I/O status block
NULL, // alloc size = none
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL, // eabuffer
0 ); // ealength
if(!NT_SUCCESS(Status)) return;
…ZwQueryInformationFile…
Status=ZwClose(hFile);
…
//
//if (pOriginalIrpStack->Parameters.Create.Options) & FILE_COMPLETE_IF_OPLOCKED ,
//then options=FILE_SYNCHRONOUS_IO_NONALERT | FILE_COMPLETE_IF_OPLOCKED;
//else options=FILE_SYNCHRONOUS_IO_NONALERT;
//
Status = ZwCreateFile(&hFile, // returned file handle
(SYNCHRONIZE | FILE_READ_DATA), // desired access
&ObjectAttributes, // ptr to object attributes
&IoStatus, // ptr to I/O status block
NULL, // alloc size = none
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OPEN,
options, //please see the above comments
NULL, // eabuffer
0 ); // ealength
if(!NT_SUCCESS(Status)) return;
if (Status==STATUS_OPLOCK_BREAK_IN_PROGRESS) return;
…ZwQueryInformationFile and ZwReadFile…
Status=ZwClose(hFile);
…