#ifndef _NTTMAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
NtOpenEnlistment(
_Out_ PHANDLE EnlistmentHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_ HANDLE ResourceManagerHandle,
_In_ LPGUID EnlistmentGuid,
_In_opt_ POBJECT_ATTRIBUTES ObjectAttributes
);
View code on GitHub#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwOpenEnlistment(
_Out_ PHANDLE EnlistmentHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_ HANDLE ResourceManagerHandle,
_In_ LPGUID EnlistmentGuid,
_In_opt_ POBJECT_ATTRIBUTES ObjectAttributes
);
View code on GitHub// wdm.h
__kernel_entry NTSYSCALLAPI NTSTATUS NtOpenEnlistment(
[out] PHANDLE EnlistmentHandle,
[in] ACCESS_MASK DesiredAccess,
[in] HANDLE ResourceManagerHandle,
[in] LPGUID EnlistmentGuid,
[in, optional] POBJECT_ATTRIBUTES ObjectAttributes
);
View the official Windows Driver Kit DDI reference// wdm.h
NTSYSCALLAPI NTSTATUS ZwOpenEnlistment(
[out] PHANDLE EnlistmentHandle,
[in] ACCESS_MASK DesiredAccess,
[in] HANDLE RmHandle,
[in] LPGUID EnlistmentGuid,
[in, optional] POBJECT_ATTRIBUTES ObjectAttributes
);
View the official Windows Driver Kit DDI referenceThe ZwOpenEnlistment routine obtains a handle to an existing enlistment object.
EnlistmentHandle [out]A pointer to a caller-allocated variable that receives a handle to an enlistment object if the call to ZwOpenEnlistment succeeds.
DesiredAccess [in]An ACCESS_MASK-typed value that specifies the requested access to the enlistment object. For more information about how to specify this parameter, see the DesiredAccess parameter of ZwCreateEnlistment. This parameter cannot be zero.
ResourceManagerHandle [in]A handle to a resource manager object that was obtained by a previous call to ZwCreateResourceManager or ZwOpenResourceManager.
EnlistmentGuid [in]A pointer to a GUID that identifies the enlistment. For more information, see the following Remarks section.
ObjectAttributes [in, optional]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. This parameter is optional and can be NULL.
ZwOpenEnlistment returns STATUS_SUCCESS if the operation succeeds. Otherwise, this routine might return one of the following values:
| Return code | Description |
|---|---|
| STATUS_INVALID_HANDLE | The object handle is invalid. |
| STATUS_ACCESS_DENIED | The caller does not have appropriate access to the enlistment object. |
| STATUS_INVALID_PARAMETER | The DesiredAccess parameter's value is zero, or the EnlistmentGuid parameter's value is NULL. |
| STATUS_ENLISTMENT_NOT_FOUND | The enlistment that the EnlistmentGuid parameter specifies does not exist for the resource manager that the RmHandle parameter specifies. |
| STATUS_ACCESS_DENIED | The value of the DesiredAccess parameter is invalid. |
The routine might return other NTSTATUS values.
Typically, a TPS component calls ZwOpenEnlistment after it receives an enlistment GUID from another TPS component that had previously called ZwCreateEnlistment. Most TPS designs do not require calling ZwOpenEnlistment.
A resource manager that calls ZwOpenEnlistment must eventually call ZwClose to close the object handle.
For more information about ZwOpenEnlistment, see Enlistment Objects.
NtOpenEnlistment and ZwOpenEnlistment are two versions of the same Windows Native System Services routine.
For calls from kernel-mode drivers, the Nt*Xxx* and Zw*Xxx* 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 Nt*Xxx* and Zw*Xxx* versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.
Using Nt and Zw Versions of the Native System Services Routines
The ZwOpenEnlistment routine obtains a handle to an existing enlistment object.
EnlistmentHandle [out]A pointer to a caller-allocated variable that receives a handle to an enlistment object if the call to ZwOpenEnlistment succeeds.
DesiredAccess [in]An ACCESS_MASK-typed value that specifies the requested access to the enlistment object. For more information about how to specify this parameter, see the DesiredAccess parameter of ZwCreateEnlistment. This parameter cannot be zero.
RmHandle [in]A handle to a resource manager object that was obtained by a previous call to ZwCreateResourceManager or ZwOpenResourceManager.
EnlistmentGuid [in]A pointer to a GUID that identifies the enlistment. For more information, see the following Remarks section.
ObjectAttributes [in, optional]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. This parameter is optional and can be NULL.
ZwOpenEnlistment returns STATUS_SUCCESS if the operation succeeds. Otherwise, this routine might return one of the following values:
| Return code | Description |
|---|---|
| STATUS_INVALID_HANDLE | The object handle is invalid. |
| STATUS_ACCESS_DENIED | The caller does not have appropriate access to the enlistment object. |
| STATUS_INVALID_PARAMETER | The DesiredAccess parameter's value is zero, or the EnlistmentGuid parameter's value is NULL. |
| STATUS_ENLISTMENT_NOT_FOUND | The enlistment that the EnlistmentGuid parameter specifies does not exist for the resource manager that the RmHandle parameter specifies. |
| STATUS_ACCESS_DENIED | The value of the DesiredAccess parameter is invalid. |
The routine might return other NTSTATUS values.
Typically, a TPS component calls ZwOpenEnlistment after it receives an enlistment GUID from another TPS component that had previously called ZwCreateEnlistment. Most TPS designs do not require calling ZwOpenEnlistment.
A resource manager that calls ZwOpenEnlistment must eventually call ZwClose to close the object handle.
For more information about ZwOpenEnlistment, see Enlistment Objects.
NtOpenEnlistment and ZwOpenEnlistment are two versions of the same Windows Native System Services routine.
For calls from kernel-mode drivers, the Nt*Xxx* and Zw*Xxx* 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 Nt*Xxx* and Zw*Xxx* versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.
Using Nt and Zw Versions of the Native System Services Routines