NtDllNtCreateSection(IntPtr, GenericAccessRights, 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).

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: 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,
	GenericAccessRights desiredAccess,
	ObjectAttributes objectAttributes,
	ref ulong refMaxSize,
	MemoryProtectionOptions pageProtection,
	SectionAttributes allocationAttributes,
	SafeFileHandle hFile
)

Parameters

refSection  IntPtr
Pointer to a handle that receives a handle to the section object.
desiredAccess  GenericAccessRights
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.

Return Value

NTStatus
Returns SUCCESS on success, or the appropriate NTStatus error code on failure.

Remarks

See Also