NtDllNtMapViewOfSection(IntPtr, SafeProcessHandle, IntPtr, IntPtr, IntPtr, Int64, UIntPtr, SectionInherit, MemoryAllocationType, MemoryProtectionOptions) Method
Maps a view of a section into the virtual address space of a subject process.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("NtDll.dll", CallingConvention = CallingConvention.StdCall)]
public static NTStatus NtMapViewOfSection(
IntPtr hSection,
SafeProcessHandle hProcess,
ref IntPtr refBaseAddress,
IntPtr zeroBits,
IntPtr commitSize,
[OptionalAttribute] ref long refSectionOffset,
ref UIntPtr refViewSize,
SectionInherit sectionInherit,
MemoryAllocationType allocationType,
MemoryProtectionOptions protection
)
<DllImportAttribute("NtDll.dll", CallingConvention := CallingConvention.StdCall>]
Public Shared Function NtMapViewOfSection (
hSection As IntPtr,
hProcess As SafeProcessHandle,
ByRef refBaseAddress As IntPtr,
zeroBits As IntPtr,
commitSize As IntPtr,
<OptionalAttribute> ByRef refSectionOffset As Long,
ByRef refViewSize As UIntPtr,
sectionInherit As SectionInherit,
allocationType As MemoryAllocationType,
protection As MemoryProtectionOptions
) As NTStatus
Dim hSection As IntPtr
Dim hProcess As SafeProcessHandle
Dim refBaseAddress As IntPtr
Dim zeroBits As IntPtr
Dim commitSize As IntPtr
Dim refSectionOffset As Long
Dim refViewSize As UIntPtr
Dim sectionInherit As SectionInherit
Dim allocationType As MemoryAllocationType
Dim protection As MemoryProtectionOptions
Dim returnValue As NTStatus
returnValue = NtDll.NtMapViewOfSection(hSection,
hProcess, refBaseAddress, zeroBits,
commitSize, refSectionOffset, refViewSize,
sectionInherit, allocationType,
protection)
public:
[DllImportAttribute(L"NtDll.dll", CallingConvention = CallingConvention::StdCall)]
static NTStatus NtMapViewOfSection(
[InAttribute] IntPtr hSection,
[InAttribute] SafeProcessHandle^ hProcess,
IntPtr% refBaseAddress,
[InAttribute] IntPtr zeroBits,
[InAttribute] IntPtr commitSize,
[OptionalAttribute] long long% refSectionOffset,
UIntPtr% refViewSize,
[InAttribute] SectionInherit sectionInherit,
[InAttribute] MemoryAllocationType allocationType,
[InAttribute] MemoryProtectionOptions protection
)
[<DllImportAttribute("NtDll.dll", CallingConvention = CallingConvention.StdCall)>]
static member NtMapViewOfSection :
hSection : IntPtr *
hProcess : SafeProcessHandle *
refBaseAddress : IntPtr byref *
zeroBits : IntPtr *
commitSize : IntPtr *
[<OptionalAttribute>] refSectionOffset : int64 byref *
refViewSize : UIntPtr byref *
sectionInherit : SectionInherit *
allocationType : MemoryAllocationType *
protection : MemoryProtectionOptions -> NTStatus
No code example is currently available or this language may not be supported.
- hSection IntPtr
-
Handle to a section object.
This handle is created by a successful call to NtCreateSection(IntPtr, GenericAccessRights, ObjectAttributes, UInt64, MemoryProtectionOptions, SectionAttributes, SafeFileHandle)
or NtOpenSection(IntPtr, GenericAccessRights, IntPtr).
- hProcess SafeProcessHandle
-
Handle to the object that represents the process that the view should be mapped into.
The handle must have been opened with VirtualMemoryOperation access.
- refBaseAddress IntPtr
-
Pointer to a variable that receives the base address of the view.
If the value of this parameter is not Zero,
the view is allocated starting at the specified virtual address rounded down to the next 64-kilobyte address boundary.
- zeroBits IntPtr
-
Specifies the number of high-order address bits that must be zero in the base address of the section view.
The value of this parameter must be less than 21 and is used only if
refBaseAddress is NULL—in other words,
when the caller allows the system to determine where to allocate the view.
- commitSize IntPtr
-
Specifies the size, in bytes, of the initially committed region of the view.
commitSize is meaningful only for page-file backed sections
and is rounded up to the nearest multiple of PAGE_SIZE.
(for sections that map files, both the data and the image are committed at section-creation time).
- refSectionOffset Int64 (Optional)
-
A pointer to a variable that receives the offset, in bytes, from the beginning of the section to the view.
If this pointer is not Zero,
the offset is rounded down to the next allocation-granularity size boundary.
- refViewSize UIntPtr
-
A pointer to a SIZE_T variable.
If the initial value of this variable is zero,
NtMapViewOfSection(IntPtr, SafeProcessHandle, IntPtr, IntPtr, IntPtr, Int64, UIntPtr, SectionInherit, MemoryAllocationType, MemoryProtectionOptions) maps a view of the section that starts at
refSectionOffset and continues to the end of the section.
Otherwise, the initial value specifies the view's size, in bytes.
NtMapViewOfSection(IntPtr, SafeProcessHandle, IntPtr, IntPtr, IntPtr, Int64, UIntPtr, SectionInherit, MemoryAllocationType, MemoryProtectionOptions) always rounds this value up to the
nearest multiple of PAGE_SIZE before mapping the view.
On return, the value receives the actual size, in bytes, of the view.
- sectionInherit SectionInherit
-
Specifies how the view is to be shared with child processes.
- allocationType MemoryAllocationType
-
Specifies a set of flags that describes the type of allocation to be performed for the specified region of pages.
The valid flags are LargePages,
Reserve,
and TopDown.
Although Commit is not allowed,
it is implied unless Reserve is specified.
- protection MemoryProtectionOptions
-
Specifies the type of protection for the region of initially committed pages.
Device and intermediate drivers should set this value to ReadWrite.
NTStatus
Returns
SUCCESS on success, or the appropriate
NTStatus error code on failure.