Trying to find if a file is in a transaction and if so, to enlist in
transaction, so…
If I obtain “transaction GUID” by sending FSCTL_TXFS_GET_METADATA_INFO
to a file. How do I translate this guid to PKTRANSACTION so that I can
enlist in the transaction and receive notifications?
Thanks in advance.
I don’t know why messages take soooo long to apear on the list.
I found a partial answer, from the fileobject we can get
pKtransaction. But I still haven’t found a way to link the guid back
to pktransaction directly …
cheers.
On Wed, Nov 5, 2008 at 2:21 PM, Kamran Tavakoli
wrote:
> Trying to find if a file is in a transaction and if so, to enlist in
> transaction, so…
>
> If I obtain “transaction GUID” by sending FSCTL_TXFS_GET_METADATA_INFO
> to a file. How do I translate this guid to PKTRANSACTION so that I can
> enlist in the transaction and receive notifications?
>
> Thanks in advance.
>
Hi Kamran,
The way to get from a GUID to a transaction is to use ZwOpenTransaction, which will return a handle. Then you can use that handle and the an object will be your KTRANSACTION. This is complicated by the fact that you can have one GUID associated with multiple KTRANSACTION objects, one for each Transaction Manager. So in order to get the right PKTRANSACTION you would need the HANDLE to fltmgr’s Transaction Manager to pass in as the last parameter in ZwOpenTransaction.
Unfortunately there is no way to get that handle from a filter.
One workaround might be to watch the FILE_OBJECT of interest and when an operation happens in filter manager with that FILE_OBJECT in a transaction, you could look at FLT_RELATED_OBJECTS and get the PKTRANSACTION (since a file can only be enlisted in one transaction at one time). Unfortunately, this approach won’t work in some cases (what if there is no IO on that file object ? what if the transaction commits and there is a new transaction using the same FO ? etc…) so you’ll probably need to tell us a bit more about what your minifilter is trying to do.
There is this thread https://www.osronline.com/ShowThread.cfm?link=137460 where we discussed some transaction issues and it seemed that the only reliable way to work with transactions is for the filter to monitor the trans-locked state of the files. Again, we probably need to know more about what you’re trying to do.
Another thing we can do is add an API along the lines of “FltEnlistInTrasactionWithGUID” which would allow you to specify a GUID instead of the PKTRANSACTION. Unfortunately this is in the future so it won’t help with your minifilter but it’s still something to think about…
Regards,
Alex.
This posting is provided “AS IS” with no warranties, and confers no rights.
AFAIK, impossible.
“Kamran Tavakoli” wrote in message
news:xxxxx@ntfsd…
> Trying to find if a file is in a transaction and if so, to enlist in
> transaction, so…
>
> If I obtain “transaction GUID” by sending FSCTL_TXFS_GET_METADATA_INFO
> to a file. How do I translate this guid to PKTRANSACTION so that I can
> enlist in the transaction and receive notifications?
>
> Thanks in advance.
>
One thing I forgot to mention is the IoGetTransactionParameterBlock API which takes a FILE_OBJECT and returns this structure:
typedef struct _TXN_PARAMETER_BLOCK {
USHORT Length;
USHORT TxFsContext;
PVOID TransactionObject;
} TXN_PARAMETER_BLOCK, *PTXN_PARAMETER_BLOCK;
The last parameter, TransactionObject is actually a referenced pointer to the KTRANSACTION object. You need to de-reference it (ObDereferenceObjectDeferDelete ) when you’re done with it.
This won’t exactly help you with the GUID->PKTRANSACTION translation but might come in handy anyway.
Regards,
Alex.
This posting is provided “AS IS” with no warranties, and confers no rights.