mini filter driver | passing information from pre-operation to post-operation

519 Views Asked by At

I'm tracking changed made to file and would like to "remember" and pass some information from the pre-operation callback to the post-operation callback.

What is the best way to do it?

[Edit: The driver should only support Windows 10 everything else is a bonus]

1

There are 1 best solutions below

0
Gabriel Bercea On

You can simply use the PVOID *CompletionContext in PreOperation to store a pointer to the data you want to pass to the PostOperation. In the PostOperation just use CompletionContext as it will be the data you pointed it to in the PreOperation.

For example: PreOp:

MyPreOpData = ExAllocatePoolWithTag(DATA_SIZE);
FltGetFileNameInformation(&NameInfo);
MyPreData->NameInfo = NameInfo;
MyPreData->OtherData = MyDrvGetOtherData(Params);
*CompletionContext = MyPreData;

PostOp:

if (CompletionContext != NULL)
{
    PMY_DATA MyPreData = (PMY_DATA)CompletionContext;
    // now continue using the data queried in the PreOp
    ...
    // when done free it
    ExFreePoolWithTag(MyPreData);
}

See here for more details.

Good luck,
Gabriel