Thank you very much Alex,
xxxxx@microsoft.com wrote:
Hello all,
Synchronizing to the original thread does not disable cancellable creates if the proper wait functions are used (see the documentation for FsRtlCancellableWaitForSingleObject for example).
Filter manager guarantees that the in the case of creates (as well as any synchronized operation) the post callback will be called in the same context as the pre callback. If another filter (it would have to be a legacy filter, I don’t see how a minifilter could do this) changes the thread context above filter manager then that’s the context both the pre and post callbacks will be called (if the operation is synchronized). In the thread mentioned above (http://www.osronline.com/showThread.cfm?link=109469), Tony’s filter could change the context above a certain filter manager frame (for the frames above Tony’s filter, if any, it wouldn’t matter) but then both the pre and the post callback for all the minifilters* would still be called in the same context (which is Tony’s filter new context).
So, Sandor, when you say " Yes, in a minifilter I can get the PRE-Create and POST-Create in a different thread " there are two possible interpretations:
- the contexts are different for pre and post (which cannot happen)
- the contexts are the same for pre and post, but it’s not the same thread that issued the original create (which can happen).
I was thinking about interpretation 2 :-).
The same two interpretations apply to the original question:
" Can somebody confirm that a POST-Create callback in a minifilter is always called at PASSIVE_LEVEL and *in the context of the original calling thread*?"
- If by " context of the original calling thread " you mean the thread where the PRE-Create callback was run, than yes, that is correct.
- If by " context of the original calling thread " you mean the thread that issued the original create operation, then no, you can’t assume that. Whether this makes a difference for your application depends on what you’re trying to do.
I was also thinking about case 2, so my assumption was wrong here (but,
after putting all pieces together it was clear to be wrong). However,
one question remains. The DDK states “FltGetRequestorProcessId returns
the process ID for the process associated with the thread that
originally requested the I/O operation.” Until now, I assumed that this
PID is the PID of the original requestor process.
However, now I think that this is generally the case only because the
above filters do not change the thread / process context for a create,
so it remains the same. Am I correct if I say, that in the case a filter
above would change the thread & process context, then I would receive
the new PID and not the original? (This would somehow mean, that the
filter above is plainly broken as it can very easily change the whole
system’s behavior…)
Or, another case: would PsGetCurrentProcessId return the current PID (of
the process context to which the above filter changed) and
FltGetRequestorProcessId the original PID (meaning that my initial
assumption was still right)?
thank you, have a nice day,
Sandor