Click or drag to resize
Xcalibur Systems LLC Logo

MemoryProtections Enumeration

The following are the memory-protection options; you must specify one of the following values when allocating or protecting a page in memory. Protection attributes cannot be assigned to a portion of a page; they can only be assigned to a whole page.

Memory Protection Constants


Namespace: Xcalibur.NativeMethods.V2.Memory
Assembly: Xcalibur.NativeMethods.V2 (in Xcalibur.NativeMethods.V2.dll) Version: 1.0.1.0
Syntax
[FlagsAttribute]
public enum MemoryProtections
Members
Member nameValueDescription
NoAccess1 Disables all access to the committed region of pages. An attempt to read from, write to, or execute the committed region results in an access violation.
ReadOnly2 Enables read-only access to the committed region of pages. An attempt to write to the committed region results in an access violation. If Data Execution Prevention is enabled, an attempt to execute code in the committed region results in an access violation.
ReadWrite4 Enables read-only or read/write access to the committed region of pages. If Data Execution Prevention is enabled, attempting to execute code in the committed region results in an access violation.
WriteCopy8 Enables read-only or copy-on-write access to a mapped view of a file mapping object. An attempt to write to a committed copy-on-write page results in a private copy of the page being made for the process. The private page is marked as , and the change is written to the new page. If Data Execution Prevention is enabled, attempting to execute code in the committed region results in an access violation.
Execute16 Enables execute access to the committed region of pages. An attempt to write to the committed region results in an access violation.
ExecuteRead32 Enables execute or read-only access to the committed region of pages. An attempt to write to the committed region results in an access violation.
ExecuteReadWrite64 Enables execute, read-only, or read/write access to the committed region of pages.
ExecuteWriteCopy128 Enables execute, read-only, or copy-on-write access to a mapped view of a file mapping object. An attempt to write to a committed copy-on-write page results in a private copy of the page being made for the process. The private page is marked as , and the change is written to the new page.
Guard256 Pages in the region become guard pages. Any attempt to access a guard page causes the system to raise a STATUS_GUARD_PAGE_VIOLATION exception and turn off the guard page status. Guard pages thus act as a one-time access alarm. For more information, see Creating Guard Pages. When an access attempt leads the system to turn off guard page status, the underlying page protection takes over. If a guard page exception occurs during a system service, the service typically returns a failure status indicator.
NoCache512 Sets all pages to be non-cachable. Applications should not use this attribute except when explicitly required for a device. Using the interlocked functions with memory that is mapped with SEC_NOCACHE can result in an EXCEPTION_ILLEGAL_INSTRUCTION exception. The PageNoCache flag cannot be used with the , , or flags. The PageNoCache flag can be used only when allocating private memory with the VirtualAlloc, VirtualAllocEx, or VirtualAllocExNuma functions.To enable non-cached memory access for shared memory, specify the SEC_NOCACHE flag when calling the CreateFileMapping function.
WriteCombine1,024 Sets all pages to be write-combined. Applications should not use this attribute except when explicitly required for a device. Using the interlocked functions with memory that is mapped as write-combined can result in an EXCEPTION_ILLEGAL_INSTRUCTION exception. The flag cannot be specified with the , , and flags. The flag can be used only when allocating private memory with the VirtualAlloc, VirtualAllocEx, or VirtualAllocExNuma functions.To enable write-combined memory access for shared memory, specify the SEC_WRITECOMBINE flag when calling the CreateFileMapping function.
TargetsInvalid1,073,741,824 Sets all locations in the pages as invalid targets for CFG. Used along with any execute page protection like , , and . Any indirect call to locations in those pages will fail CFG checks and the process will be terminated. The default behavior for executable pages allocated is to be marked valid call targets for CFG.
TargetsNoUpdate1,073,741,824 Pages in the region will not have their CFG information updated while the protection changes for VirtualProtect. For example, if the pages in the region was allocated using PAGE_TARGETS_INVALID, then the invalid information will be maintained while the page protection changes. This flag is only valid when the protection changes to an executable type like , , and . The default behavior for VirtualProtect protection change to executable is to mark all locations as valid call targets for CFG.
See Also