ZwMapViewOfSection
NTSTATUS
ZwMapViewOfSection(
IN HANDLE SectionHandle,
IN HANDLE ProcessHandle,
IN OUT PVOID *BaseAddress,
IN ULONG ZeroBits,
IN ULONG CommitSize,
IN OUT PLARGE_INTEGER SectionOffset, /* optional */
IN OUT PULONG ViewSize,
IN SECTION_INHERIT InheritDisposition,
IN ULONG AllocationType,
IN ULONG Protect
);
ZwMapViewOfSection maps a view of a section into the virtual address
space of a subject process.
Parameters
-
SectionHandle
-
Is the handle returned by a successful call to ZwOpenSection.
-
ProcessHandle
-
Is the handle of an opened process object, representing the process for which
the view should be mapped.
-
BaseAddress
-
Points to a variable that will receive the base address of the view. If the
initial value of this argument is nonNULL, the view is allocated starting at
the specified virtual address rounded down to the next 64-kilobyte address
boundary.
-
ZeroBits
-
Specifies the number of high-order address bits that must be zero in the base
address of the section view. The value of this argument must be less than 21
and is used only when the operating system determines where to allocate the
view, as when BaseAddress is NULL.
-
CommitSize
-
Specifies the size, in bytes, of the initially committed region of the view. CommitSize
is only meaningful for page-file backed sections. For mapped sections, both
data and image are always committed at section creation time. This parameter
is ignored for mapped files. This value is rounded up to the next
host-page-size boundary.
-
SectionOffset
-
Points to the offset, in bytes, from the beginning of the section to the view.
If this pointer is nonNULL, the given value is rounded down to the next
allocation granularity size boundary.
-
ViewSize
-
Points to a variable that will receive the actual size, in bytes, of the view.
If the value of this parameter is zero, a view of the section will be mapped
starting at the specified section offset and continuing to the end of the
section. Otherwise, the initial value of this argument specifies the size of
the view, in bytes, and is rounded up to the next host page-size boundary.
-
InheritDispostion
-
Specifies how the view is to be shared by a child process created with a
create process operation. Device and intermediate drivers should set this
parameter to zero.
-
AllocationType
-
A set of flags that describes the type of allocation to be performed for the
specified region of pages.
-
Protect
-
Specifies the protection for the region of initially committed pages. Device
and intermediate drivers should set this value to PAGE_READWRITE.
Return Value
ZwMapViewOfSection can return one of the following values:
STATUS_SUCCESS
STATUS_ACCESS_DENIED
STATUS_INVALID_HANDLE
Comments
Several different views of a section can be concurrently mapped into the
virtual address space of a process. Likewise, several different views of a
section can be concurrently mapped into the virtual address space of several
processes.
If the specified section does not exist or the access requested is not
allowed, ZwMapViewOfSection returns an error.
Callers of ZwMapViewOfSection must be running at IRQL PASSIVE_LEVEL.
See Also
ZwOpenSection, ZwUnmapViewOfSection