The ZwOpenSection routine opens a handle for an existing section object.
NTSTATUS
ZwOpenSection(
OUT PHANDLE SectionHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
);
| DesiredAccess Flags | Meaning |
|---|---|
| SECTION_MAP_WRITE | A mapped view can be written. |
| SECTION_MAP_READ | A mapped view can be read. |
A caller can specify SECTION_ALL_ACCESS, which sets all of the defined flags ORed with the system-defined STANDARD_RIGHTS_REQUIRED.
Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.
ZwOpenSection returns STATUS_SUCCESS on success, or the appropriate error code on failure. Possible return values include:
STATUS_SUCCESS
STATUS_ACCESS_DENIED
STATUS_INVALID_HANDLE
If the specified section does not exist or the access requested is not allowed, the operation fails.
Driver routines that run in a process context other than that of the system process must set the OBJ_KERNEL_HANDLE attribute for the ObjectAttributes parameter of ZwOpenSection. This restricts the use of the handle returned by ZwOpenSection to processes running only in kernel mode. Otherwise, the handle can be accessed by the process in whose context the driver is running. Drivers can call InitializeObjectAttributes to set the OBJ_KERNEL_HANDLE attribute as follows.
InitializeObjectAttributes(&ObjectAttributes, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
Callers of ZwOpenSection must be running at IRQL = PASSIVE_LEVEL.
ACCESS_MASK, InitializeObjectAttributes, ZwCreateSection, ZwMapViewOfSection, ZwUnmapViewOfSection