please dont rip this site Prev Next

VirtualProtectEx info  Overview  Group

The VirtualProtectEx function changes the access protection on a region of committed pages in the virtual address space of a specified process. Note that this function differs from VirtualProtect, which changes the access protection on the calling process only.

BOOL VirtualProtectEx(

    HANDLE hProcess,

// handle of process

    LPVOID lpAddress,

// address of region of committed pages

    DWORD dwSize,

// size of region

    DWORD flNewProtect,

// desired access protection

    PDWORD lpflOldProtect 

// address of variable to get old protection

   );

Parameters

hProcess
Identifies the process whose memory protection is to be changed. The handle must have PROCESS_VM_OPERATION access. For more information on PROCESS_VM_OPERATION, see OpenProcess.
lpAddress
Points to the base address of the region of pages whose access protection attributes are to be changed.

All pages in the specified region must have been allocated in a single call to the VirtualAlloc or VirtualAllocEx function. The pages cannot span adjacent regions that were allocated by separate calls to VirtualAlloc or VirtualAllocEx.

dwSize
Specifies the size, in bytes, of the region whose access protection attributes are changed. The region of affected pages includes all pages containing one or more bytes in the range from the lpAddress parameter to (lpAddress+dwSize). This means that a 2-byte range straddling a page boundary causes the protection attributes of both pages to be changed.
flNewProtect
Specifies the new access protection. Any one of the following flags can be specified, along with the PAGE_GUARD and PAGE_NOCACHE protection modifier flags, as desired:

Value

Meaning

PAGE_READONLY

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

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

PAGE_WRITECOPY

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

PAGE_EXECUTE

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

PAGE_EXECUTE_READ

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

PAGE_EXECUTE_READWRITE

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

PAGE_EXECUTE_WRITECOPY

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

PAGE_GUARD

Pages in the region become guard pages. Any attempt to read from or write to a guard page causes the operating system to raise a STATUS_GUARD_PAGE exception, and turn off the guard page status. Guard pages thus act as a one-shot access alarm.

The PAGE_GUARD flag is a page protection modifier. An application uses it with one of the other page protection flags, with one exception: it cannot be used with PAGE_NOACCESS. When an access attempt leads the operating 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.

PAGE_NOACCESS

Disables all access to the committed region of pages. An attempt to read from, write to, or execute in the committed region results in an access violation exception, called a general protection (GP) fault.

PAGE_NOCACHE

Allows no caching of the committed regions of pages. The hardware attributes for the physical memory should be set to “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 flag is a page protection modifier, only valid when used with one of the page protections other than PAGE_NOACCESS.

lpflOldProtect
Points to a variable that receives the previous access protection of the first page in the specified region of pages. If this parameter is NULL or does not point to a valid variable, the function fails.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The access protection value can be set only on committed pages. If the state of any page in the specified region is not committed, the function fails and returns without modifying the access protection of any pages in the specified region.

VirtualProtectEx is identical to the VirtualProtect function except that it changes the access protection of memory in a specified process.

The PAGE_GUARD protection modifier flag establishes guard pages. Guard pages act as one-shot access alarms. See Guard Pages. for further discussion of guard pages.

See Also

VirtualAlloc, VirtualProtect, VirtualQueryEx 


file: /Techref/os/win/api/win32/func/src/f90_14.htm, 8KB, , updated: 2000/4/7 11:19, local time: 2024/12/23 01:00,
TOP NEW HELP FIND: 
18.117.254.202:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.ecomorder.com/Techref/os/win/api/win32/func/src/f90_14.htm"> VirtualProtectEx</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .