ZwOpenTransaction function (wdm.h)

The ZwOpenTransaction routine obtains a handle to an existing transaction object.


  [out]          PHANDLE            TransactionHandle,
  [in]           ACCESS_MASK        DesiredAccess,
  [in, optional] POBJECT_ATTRIBUTES ObjectAttributes,
  [in]           LPGUID             Uow,
  [in, optional] HANDLE             TmHandle


[out] TransactionHandle

A pointer to a caller-allocated variable that receives a handle to the transaction object if ZwOpenTransaction returns STATUS_SUCCESS.

[in] DesiredAccess

An ACCESS_MASK value that specifies the caller's requested access to the transaction object. For information about how to specify this parameter, see the DesiredAccess parameter of ZwCreateTransaction.

[in, optional] ObjectAttributes

A pointer to an OBJECT_ATTRIBUTES structure that specifies the object's attributes. Use the InitializeObjectAttributes routine to initialize this structure, but specify only that routine's InitializedAttributes and Attributes parameters. If the caller is not running in a system thread context, it must set the OBJ_KERNEL_HANDLE flag in the Attributes parameter. The ObjectAttributes parameter is optional and can be NULL.

[in] Uow

A pointer to a GUID that is a transaction object's unit of work (UOW) identifier. This GUID identifies the transaction object to open.

[in, optional] TmHandle

A handle to a transaction manager object. If this parameter is not NULL, KTM searches only for transaction objects that belong to the specified transaction manager object. If this parameter is NULL, KTM searches all transaction objects.

Return value

ZwCreateTransaction returns STATUS_SUCCESS if the operation succeeds. Otherwise, this routine might return one of the following values:

Return code Description
The DesiredAccess or Uow parameter was zero.
The specified handle is not a handle to a transaction object.
An object handle is invalid.
KTM could not find the transaction object.
The value of the DesiredAccess parameter is invalid.

The routine might return other NTSTATUS values.


Typically, a resource manager calls ZwOpenTransaction after it receives a transaction UOW from a transactional client that had previously called ZwCreateTransaction.

For more information about ZwOpenTransaction, see Creating a Resource Manager.

NtOpenTransaction and ZwOpenTransaction are two versions of the same Windows Native System Services routine.

For calls from kernel-mode drivers, the NtXxx and ZwXxx versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the NtXxx and ZwXxx versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.


Requirement Value
Minimum supported client Available in Windows Vista and later operating system versions.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
DDI compliance rules HwStorPortProhibitedDDIs(storport), PowerIrpDDis(wdm)

See also




Using Nt and Zw Versions of the Native System Services Routines