NtOpenEnlistment - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#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
    );

#endif

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
    );

#endif

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 reference

NtDoc

This function is documented in Windows Driver Kit here and here.

Windows Driver Kit DDI reference (nf-wdm-ntopenenlistment)

NtOpenEnlistment function

Description

The ZwOpenEnlistment routine obtains a handle to an existing enlistment object.

Parameters

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.

Return value

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.

Remarks

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.

See also

ACCESS_MASK

InitializeObjectAttributes

OBJECT_ATTRIBUTES

Using Nt and Zw Versions of the Native System Services Routines

ZwClose

ZwCreateEnlistment

ZwCreateResourceManager

ZwOpenResourceManager

ZwQueryInformationEnlistment

ZwSetInformationEnlistment


Windows Driver Kit DDI reference (nf-wdm-zwopenenlistment)

ZwOpenEnlistment function

Description

The ZwOpenEnlistment routine obtains a handle to an existing enlistment object.

Parameters

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.

Return value

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.

Remarks

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.

See also

ACCESS_MASK

InitializeObjectAttributes

OBJECT_ATTRIBUTES

Using Nt and Zw Versions of the Native System Services Routines

ZwClose

ZwCreateEnlistment

ZwCreateResourceManager

ZwOpenResourceManager

ZwQueryInformationEnlistment

ZwSetInformationEnlistment