Click to Rate and Give Feedback
MSDN
MSDN Library
System Services
Memory Management
 Memory Protection Constants
Memory Protection Constants

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. Protection attributes specified when protecting a page cannot conflict with those specified when allocating a page.

Constant/value Description

PAGE_EXECUTE
0x10

Enables execute access to the committed region of pages. An attempt to read or write to the committed region results in an access violation.

This flag is not supported by the CreateFileMapping function.

PAGE_EXECUTE_READ
0x20

Enables execute and read access to the committed region of pages. An attempt to write to the committed region results in an access violation.

Windows Server 2003 and Windows XP:  This attribute is not supported by the CreateFileMapping function until Windows XP SP2 and Windows Server 2003 SP1.

PAGE_EXECUTE_READWRITE
0x40

Enables execute, read, and write access to the committed region of pages.

Windows Server 2003 and Windows XP:  This attribute is not supported by the CreateFileMapping function until Windows XP SP2 and Windows Server 2003 SP1.

PAGE_EXECUTE_WRITECOPY
0x80

Enables execute, read, and write access to the committed region of image file code pages. The pages are shared read-on-write and copy-on-write.

This flag is not supported by the VirtualAlloc, VirtualAllocEx, or CreateFileMapping functions.

PAGE_NOACCESS
0x01

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 exception, called a general protection (GP) fault.

This flag is not supported by the CreateFileMapping function.

PAGE_READONLY
0x02

Enables read access to the committed region of pages. An attempt to write to the committed region results in an access violation. If the system differentiates between read-only access and execute access, an attempt to execute code in the committed region results in an access violation.

PAGE_READWRITE
0x04

Enables both read and write access to the committed region of pages.

PAGE_WRITECOPY
0x08

Gives copy-on-write protection to the committed region of pages.

This flag is not supported by the VirtualAlloc or VirtualAllocEx functions.

The following are modifiers that can be used in addition to the options provided in the previous table, except as noted.

Constant/value Description

PAGE_GUARD
0x100

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.

This value cannot be used with PAGE_NOACCESS.

This flag is not supported by the CreateFileMapping function.

PAGE_NOCACHE
0x200

Does not allow caching of the committed regions of pages in the CPU cache. The hardware attributes for the physical memory should be specified as "no cache." This is not recommended for general usage. It is useful for device drivers, for example, mapping a video frame buffer with no caching.

This value cannot be used with PAGE_NOACCESS.

This flag is not supported by the CreateFileMapping function.

PAGE_WRITECOMBINE
0x400

Enables write-combined memory accesses. When enabled, the processor caches memory write requests to optimize performance. Thus, if two requests are made to write to the same memory address, only the more recent write may occur.

Note that the PAGE_GUARD and PAGE_NOCACHE flags cannot be specified with PAGE_WRITECOMBINE. If an attempt is made to do so, the SYSTEM_INVALID_PAGE_PROTECTION NT error code is returned by the function.

This flag is not supported by the CreateFileMapping function.

Requirements

ClientRequires Windows Vista, Windows XP, or Windows 2000 Professional.
ServerRequires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Header Declared in WinNT.h; include Windows.h.

See Also

CreateFileMapping
Memory Protection
VirtualAlloc
VirtualAllocEx


Send comments about this topic to Microsoft

Build date: 8/22/2008

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Cannot change page's attribute to PAGE_READWRITE by using VirtualProtect      Yanjun Wu ... Noelle Mallory - MSFT   |   Edit   |  
Each time I want to change a page to PAGE_READWRITE, it actually changes it to PAGE_WRITECOPY (observed by using VirtualQuery), and the return value of VirtualProtect indicates no error. Could anybody tell me why?

[Noelle Mallory - MSFT] Please post questions to the MSDN Forums at http://forums.microsoft.com/msdn. You will likely get a quicker response through the forum than through the Community Content.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker