The ZwCreateEnlistment routine creates a new enlistment object for a transaction.
__kernel_entry NTSYSCALLAPI NTSTATUS NtCreateEnlistment( PHANDLE EnlistmentHandle, ACCESS_MASK DesiredAccess, HANDLE ResourceManagerHandle, HANDLE TransactionHandle, POBJECT_ATTRIBUTES ObjectAttributes, ULONG CreateOptions, NOTIFICATION_MASK NotificationMask, PVOID EnlistmentKey );
A pointer to a caller-allocated variable that receives a handle to the new enlistment object if the call to ZwCreateEnlistment succeeds.
An ACCESS_MASK value that specifies the caller's requested access to the enlistment object. In addition to the access rights that are defined for all kinds of objects (see ACCESS_MASK), the caller can specify any of the following access right flags for enlistment objects:
|ACCESS_MASK flag||Allows the caller to|
|ENLISTMENT_QUERY_INFORMATION||Query information about the enlistment (see ZwQueryInformationEnlistment).|
|ENLISTMENT_SET_INFORMATION||Set information for the enlistment (see ZwSetInformationEnlistment).|
|ENLISTMENT_RECOVER||Recover the enlistment (see ZwRecoverEnlistment).|
|ENLISTMENT_SUBORDINATE_RIGHTS||Perform operations that a resource manager that is not superior performs (see ZwRollbackEnlistment, ZwPrePrepareComplete, ZwPrepareComplete, ZwCommitComplete, ZwRollbackComplete, ZwSinglePhaseReject, ZwReadOnlyEnlistment).|
|ENLISTMENT_SUPERIOR_RIGHTS||Perform operations that a superior transaction manager must perform (see ZwPrepareEnlistment, ZwPrePrepareEnlistment, ZwCommitEnlistment).|
Alternatively, you can specify one or more of the following ACCESS_MASK bitmaps. These bitmaps combine the flags from the previous table with the STANDARD_RIGHTS_XXX flags that are described on the ACCESS_MASK reference page. You can also combine these bitmaps together with additional flags from the previous table. The following table shows how the bitmaps correspond to specific access rights.
|Generic access right||Set of specific access rights|
|ENLISTMENT_GENERIC_READ||STANDARD_RIGHTS_READ and ENLISTMENT_QUERY_INFORMATION|
|ENLISTMENT_GENERIC_WRITE||STANDARD_RIGHTS_WRITE, ENLISTMENT_SET_INFORMATION, ENLISTMENT_RECOVER, ENLISTMENT_REFERENCE, ENLISTMENT_SUBORDINATE_RIGHTS, and ENLISTMENT_SUPERIOR_RIGHTS|
|ENLISTMENT_GENERIC_EXECUTE||STANDARD_RIGHTS_EXECUTE, ENLISTMENT_RECOVER, ENLISTMENT_SUBORDINATE_RIGHTS, and ENLISTMENT_SUPERIOR_RIGHTS|
|ENLISTMENT_ALL_ACCESS||STANDARD_RIGHTS_REQUIRED, ENLISTMENT_GENERIC_READ, ENLISTMENT_GENERIC_WRITE, and ENLISTMENT_GENERIC_EXECUTE|
A handle to a transaction object that was obtained by a previous call to ZwCreateTransaction or ZwOpenTransaction. KTM adds this transaction to the list of transactions that the calling resource manager is handling.
A pointer to an OBJECT_ATTRIBUTES structure that specifies the object name and other attributes. Use the InitializeObjectAttributes routine to initialize this structure. If the caller is not running in a system thread context, it must set the OBJ_KERNEL_HANDLE attribute when it calls InitializeObjectAttributes. This parameter is optional and can be NULL.
Enlistment option flags. The following table contains the only available flag.
|ENLISTMENT_SUPERIOR||The caller is enlisting as a superior transaction manager for the specified transaction.|
This parameter is optional and can be zero.
A bitwise OR of TRANSACTION_NOTIFY_XXX values that are defined in Ktmtypes.h. This mask specifies the types of transaction notifications that KTM sends to the caller.
A pointer to caller-defined information that uniquely identifies the enlistment. The resource manager receives this pointer when it calls ZwGetNotificationResourceManager or when KTM calls the ResourceManagerNotification callback routine. The resource manager can maintain a reference count for this key by calling TmReferenceEnlistmentKey and TmDereferenceEnlistmentKey. This parameter is optional and can be NULL.
ZwCreateEnlistment returns STATUS_SUCCESS if the operation succeeds. Otherwise, this routine might return one of the following values:
||An object handle is invalid.|
||The CreateOptions or NotificationMask parameter's value is invalid, or KTM could not find the transaction that the TransactionHandle parameter specifies.|
||A memory allocation failed.|
||The enlistment failed because KTM or the resource manager is not in an operational state.|
||The enlistment failed because the transaction that the TransactionHandle parameter specifies is not active.|
||The caller tried to register as a superior transaction manager but a superior transaction manager already exists.|
||The caller is trying to register as a superior transaction manager, but the caller's resource manager object is volatile while the associated transaction manager object is not volatile.|
||The value of the DesiredAccess parameter is invalid.|
The routine might return other NTSTATUS values.
A resource manager calls ZwCreateEnlistment to enlist in a transaction.
Resource managers that are not superior must include the ENLISTMENT_SUBORDINATE_RIGHTS flag in their access mask.
Superior transaction managers must include the ENLISTMENT_SUPERIOR_RIGHTS flag in their access masks. Typically, a superior transaction manager includes code that calls ZwRollbackEnlistment, so it must also include the ENLISTMENT_SUBORDINATE_RIGHTS flag.
A resource manager that calls ZwCreateEnlistment must eventually call ZwClose to close the object handle.
Your resource manager can use the EnlistmentKey parameter to assign a unique value to each enlistment, such as a pointer to a data structure that contains information about the enlistment. For example, if the resource manager stores the enlistment object's handle in the structure, the resource manager can do the following:
Call ZwGetNotificationResourceManager to obtain a notification.
Obtain the enlistment key value from the TRANSACTION_NOTIFICATION structure.
Use the enlistment key to find the stored enlistment object handle.
Call routines that require the enlistment handle as input, such as ZwCommitComplete or ZwRollbackComplete.
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.
|Windows version||Available in Windows Vista and later operating system versions.|
|Header||wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)|
|DDI compliance rules||PowerIrpDDis, HwStorPortProhibitedDDIs|