Dumb question for Thursday…
How does one detect the creation of a new directory? I chase through the
various structures and find several flags that may indicate ‘create’ vs.
‘open existing’ but none of them ever react in response to a WIN32
CreateDirectory().
I see all sorts of access to existing directories.
Also, is there a foolproof way to determine ‘this is a write operation’
for any file create situation? Generally speaking, my filter doesn’t
care about read activity but it does care about the creation of new
things - directories, files, registry keys, etc.
Some of the stuff I’ve attempted to check…
FLT_PREOP_CALLBACK_STATUS PreCreateCallback (
PFLT_CALLBACK_DATA Data,
PCFLT_RELATED_OBJECTS FltObjects,
PVOID *CompletionContext)
{
PFLT_IO_PARAMETER_BLOCK IopbPtr = Data->Iopb;
ULONG IrpFlags = IopbPtr->IrpFlags;
PFILE_OBJECT TargetFileObjectPtr = IopbPtr->TargetFileObject;
PFLT_PARAMETERS Parameters = &IopbPtr->Parameters;
PIO_SECURITY_CONTEXT SecurityContext =
Parameters->Create.SecurityContext;
ACCESS_MASK DesiredAccess = SecurityContext->DesiredAccess;
CreateOptions = Parameters->Create.Options & 0x00FFFFFF;
ThisIsADirectoryOperation = ((CreateOptions & FILE_DIRECTORY_FILE)
!= 0);
[or FltIsDirectory(…, &ThisIsADirectoryOperation)]
[followed by a test open of the file to see if it really is a directory]
Regards,
Mickey.