Hi, All:
I am working on a project of minifilter. The minifilter driver is running
on the file server (win2003 or win2008). The file server has a share folder
which is accessed by a read-only user from remote client. The reparse-point
file(stub) in the share folder is opened by the user (double click). The
stub open is redirected to another file (with the real contents of the stub
file) in the same folder.
I have the following questions:
-
Is it possible to delete the content file when the user closes the file?
The user has read-only permissions(share permissions set by windows
explorer) for the share folder. -
I tried the following within the postcreate function, it seems the
content file can be deleted even if the user has the read-only permission
FltCreateFile(HSMData.Filter, FltObjects->Instance, &FileHandle,
FILE_WRITE_ATTRIBUTES|STANDARD_RIGHTS_ALL, &ObjectAttributes,
&IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, FILE_COMPLETE_IF_OPLOCKED,
NULL, 0, IO_IGNORE_SHARE_ACCESS_CHECK);
FltClose(FileHandle);
-
But I won’t delete the content file in the postcreate function, because
I need the file for stub redirection. So I wonder how could I delete the
content file? I am thinking of putting the delete in precleanup(), but not
sure how to generate IRP_MJ_CLEANUP within the driver. -
within the postcreate() function, after replacing the filename for stub
redirection, I change the following settings for the new file (content
file). Data in the following is the FLT_CALLBACK_DATA
Data->Iopb->Parameters.Create.SecurityContext->DesiredAccess |= DELETE;
Data->Iopb->Parameters.Create.FileAttributes |= FILE_ATTRIBUTE_NORMAL;
Data->Iopb->Parameters.Create.ShareAccess |=
(FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE);
Data->Iopb->Parameters.Create.Options |= FILE_DELETE_ON_CLOSE;
Data->IoStatus.Status = STATUS_REPARSE;
Data->IoStatus.Information = IO_REPARSE;
I don’t know whether my settings are right for file delete, why it is not
working (the content file is not deleted after the file is closed)
-
Should I set Data->Iopb->TargetFileObject (DeletePending, DeleteAccess,
and SharedDelete) instead of the Data->Iopb->Parameters.Create ? what is
the difference ? -
The pseudo code of precleanup() function is like the following, the
corresponding FltSetStreamHandleContext( ) is called within postcreate()
FLT_PREOP_CALLBACK_STATUS
PreCleanup (
IN OUT PFLT_CALLBACK_DATA Data,
IN PCFLT_RELATED_OBJECTS FltObjects,
OUT PVOID *CompletionContext
)
{
status = FltGetStreamHandleContext(
FltObjects->Instance, FltObjects->FileObject, &context );
FltReleaseContext(context);
return FLT_PREOP_SUCCESS_NO_CALLBACK;
}
Thank you