NtDllNtCreateSection(IntPtr, UInt32, ObjectAttributes, UInt64, MemoryProtectionOptions, SectionAttributes, SafeFileHandle) Method
Creates a section object.
A section object represents a section of memory that can be shared.
A process can use a section object to share parts of its memory address space (memory sections) with other processes.
Section objects also provide the mechanism by which a process can map a file into its memory address space.
Each memory section has one or more corresponding views.
A view of a section is a part of the section that is actually visible to a process.
The act of creating a view for a section is known as mapping a view of the section.
Each process that is manipulating the contents of a section has its own view;
a process can also have multiple views (to the same or different sections).
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 NtCreateSection(
ref IntPtr refSection,
uint desiredAccess,
ObjectAttributes objectAttributes,
ref ulong refMaxSize,
MemoryProtectionOptions pageProtection,
SectionAttributes allocationAttributes,
SafeFileHandle hFile
)
<DllImportAttribute("NtDll.dll", CallingConvention := CallingConvention.StdCall>]
Public Shared Function NtCreateSection (
ByRef refSection As IntPtr,
desiredAccess As UInteger,
objectAttributes As ObjectAttributes,
ByRef refMaxSize As ULong,
pageProtection As MemoryProtectionOptions,
allocationAttributes As SectionAttributes,
hFile As SafeFileHandle
) As NTStatus
Dim refSection As IntPtr
Dim desiredAccess As UInteger
Dim objectAttributes As ObjectAttributes
Dim refMaxSize As ULong
Dim pageProtection As MemoryProtectionOptions
Dim allocationAttributes As SectionAttributes
Dim hFile As SafeFileHandle
Dim returnValue As NTStatus
returnValue = NtDll.NtCreateSection(refSection,
desiredAccess, objectAttributes,
refMaxSize, pageProtection, allocationAttributes,
hFile)
public:
[DllImportAttribute(L"NtDll.dll", CallingConvention = CallingConvention::StdCall)]
static NTStatus NtCreateSection(
IntPtr% refSection,
unsigned int desiredAccess,
ObjectAttributes objectAttributes,
unsigned long long% refMaxSize,
MemoryProtectionOptions pageProtection,
SectionAttributes allocationAttributes,
SafeFileHandle^ hFile
)
[<DllImportAttribute("NtDll.dll", CallingConvention = CallingConvention.StdCall)>]
static member NtCreateSection :
refSection : IntPtr byref *
desiredAccess : uint32 *
objectAttributes : ObjectAttributes *
refMaxSize : uint64 byref *
pageProtection : MemoryProtectionOptions *
allocationAttributes : SectionAttributes *
hFile : SafeFileHandle -> NTStatus
No code example is currently available or this language may not be supported.
- refSection IntPtr
-
Pointer to a handle that receives a handle to the section object.
- desiredAccess UInt32
-
Specifies the requested access to the section object.
- objectAttributes ObjectAttributes
-
Pointer to an ObjectAttributes 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 KernelHandle attribute when it calls InitializeObjectAttributes.
- refMaxSize UInt64
-
Specifies the maximum size, in bytes, of the section.
NtCreateSection(IntPtr, GenericAccessRights, ObjectAttributes, UInt64, MemoryProtectionOptions, SectionAttributes, SafeFileHandle) rounds this value up to the nearest multiple of PAGE_SIZE.
If the section is backed by the paging file,
refMaxSize specifies the actual size of the section.
If the section is backed by an ordinary file,
refMaxSize specifies the maximum size that the file can be extended or mapped to.
- pageProtection MemoryProtectionOptions
-
Specifies the protection to place on each page in the section.
Use one of the following four values:
ReadOnly,
ReadWrite,
Execute,
or WriteCopy.
- allocationAttributes SectionAttributes
-
Flags that determines the allocation attributes of the section.
- hFile SafeFileHandle
-
Optionally specifies a handle for an open file object.
If the value of hFile is Zero, the section is backed by the paging file.
Otherwise, the section is backed by the specified file.
NTStatus
Returns
SUCCESS on success, or the appropriate
NTStatus error code on failure.