Hi all
Since it seems that I cannot post a message in the ntfsd forum on
osronline.com (even after registration) I will submit my problem in this
mail.
I’m working on a project that needs to do a real time image of an ntfs
volume.
For this when the backup process is started I need to “filter” the writes on
the volume and retrieve the data from the location where the write operation
will operate and then allowing for the write to continue because I want to
have consistent data in the final image.
I did write a driver that uses the Filter Manager in order to do this and
registered for the IRP_MJ_WRITE a PreWriteCallback.
Since I want to postpone (pend) the write operation from what I have read
from the IFS DDK documentation the sequence of operations is the following :
- Allocate a work item with FltAllocateDeferredWorkItem in the
PreWriteCallback - Queue the Item to a WorkRoutine using FltQueueDeferredWorkItem in the
PreWriteCallback - Return in the PreWriteCallback FLT_PREOP_PENDING
- In the worker routine after I do the operations needed I call
FltCompletePendedPreOperation and setting the CallBack status to
FLT_PREOP_SUCCESS_NO_CALLBACK
Well the problem is that almost all my calls to FltAllocateDeferredWorkItem
seem to fail because it returns STATUS_NOT_SAFE_TO_POST_OPERATION and I
cannot post
to the worker routine.
From what I have read this is happening because IoGetTopLevelIrp does not
return NULL.
The question is how can I process this writes in a worker routine after
pending them in the PreWriteCallback ? Is this possible ? I want to do the
processing in a worker routine because sometimes I need to wait on a kernel
event before proceeding.
Is my approach for the problem wrong and there is another solution ?
P.S.1 : Before trying to do the above operations in the PreWriteCallback i’m
checking if it is an Irp-based I/O operation using FLT_IS_OPERATION_DATA
P.S.2 : Another strange problem is that everytime I check in the
PreWriteCallback the Data->Iopb->Parameters.Write.Length it seems to be 0 !