static int g_n=0;
static int g_y=0;
DWORD dwFlag;
VirtualProtect(&g_n,4,PAGE_READONLY,&dwFlag);
g_y=1;//运行到这里就报错了,VirtualProtect实际的保护内存大小是多少啊?
static int g_y=0;
DWORD dwFlag;
VirtualProtect(&g_n,4,PAGE_READONLY,&dwFlag);
g_y=1;//运行到这里就报错了,VirtualProtect实际的保护内存大小是多少啊?
DWORD dwFlag = 0;dwFlag如果不赋初值,地址不确定。
__in LPVOID lpAddress,
__in SIZE_T dwSize,
__in DWORD flNewProtect,
__out PDWORD lpflOldProtect
);dwSize
The size of the region whose access protection attributes are to be changed, in bytes. 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.