首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > windows >

VirtualProtect函数失败,该如何处理

2012-03-24 
VirtualProtect函数失败用malloc函数申请了一块内存地址,返回指针为pbyteMemory,通过VirtualProtect函数更

VirtualProtect函数失败
用malloc函数申请了一块内存地址,返回指针为pbyteMemory,通过VirtualProtect函数更改,申请的这一块儿内存为可读可写属性,但是,函数执行失败,返GetLastError函数返回值0x3E6。求解……

[解决办法]
GetLastError函数返回值0x3E6 : 998 Invalid access to memory location. ERROR_NOACCESS 


VirtualProtect
The VirtualProtect function changes the access protection on a region of committed pages in the virtual address space of the calling process. This function differs from VirtualProtectEx, which changes the access protection of any process.

BOOL VirtualProtect(
LPVOID lpAddress, // address of region of committed pages
DWORD dwSize, // size of the region
DWORD flNewProtect, // desired access protection
PDWORD lpflOldProtect 
// address of variable to get old protection
);
 
Parameters
lpAddress 
Pointer 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. 

热点排行