NtOpenSection - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTMMAPI_H
//
// Sections
//
#if (PHNT_MODE != PHNT_MODE_KERNEL)

/**
 * The NtOpenSection routine opens a handle for an existing section object.
 *
 * \param SectionHandle Handle to a process object that was previously passed to NtMapViewOfSection.
 * \param DesiredAccess The access mask that specifies the requested access to the section object.
 * \param ObjectAttributes Pointer to an OBJECT_ATTRIBUTES structure that specifies the object name and other attributes.
 * \return NTSTATUS Successful or errant status.
 * \sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-zwopensection
 */
NTSYSCALLAPI
NTSTATUS
NTAPI
NtOpenSection(
    _Out_ PHANDLE SectionHandle,
    _In_ ACCESS_MASK DesiredAccess,
    _In_ PCOBJECT_ATTRIBUTES ObjectAttributes
    );

#endif
#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwOpenSection(
    _Out_ PHANDLE SectionHandle,
    _In_ ACCESS_MASK DesiredAccess,
    _In_ PCOBJECT_ATTRIBUTES ObjectAttributes
    );

#endif

View code on GitHub
// wdm.h

NTSYSAPI NTSTATUS ZwOpenSection(
  [out] PHANDLE            SectionHandle,
  [in]  ACCESS_MASK        DesiredAccess,
  [in]  POBJECT_ATTRIBUTES ObjectAttributes
);
View the official Windows Driver Kit DDI reference

NtDoc

No description available.

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

Description

The ZwOpenSection routine opens a handle for an existing section object.

Parameters

SectionHandle [out]

Pointer to a HANDLE variable that receives a handle to the section object.

DesiredAccess [in]

Specifies an ACCESS_MASK value that determines the requested access to the object. For more information, see the DesiredAccess parameter of ZwCreateSection.

ObjectAttributes [in]

Pointer to an OBJECT_ATTRIBUTES structure that specifies the object name and other attributes. Use InitializeObjectAttributes 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.

Return value

ZwOpenSection returns STATUS_SUCCESS on success, or the appropriate error code on failure. Possible return values include:

Remarks

If the section does not exist or the system did not grant the requested access, the operation fails.

Once the handle pointed to by SectionHandle is no longer in use, the driver must call ZwClose to close it.

If the caller is not running in a system thread context, it must ensure that any handles it creates are private handles. Otherwise, the handle can be accessed by the process in whose context the driver is running. For more information, see Object Handles.

If the call to this function occurs in user mode, you should use the name "NtOpenSection" instead of "ZwOpenSection".

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

Using Nt and Zw Versions of the Native System Services Routines

ZwCreateSection

ZwMapViewOfSection

ZwUnmapViewOfSection


NTinternals.net (undocumented.ntinternals.net)

This function is documented in Windows Driver Kit.


See also