LPVOID VirtualAlloc(
LPVOID lpAddress, //指定内存地址,一般填NULL
DWORD dwSize, //分配内存大小 0x1000为1个物理页
DWORD flAllocationType, //分配类型 MEM_COMMIT地址空间和物理页都分 MEM_RESERVE只分地址空间
DWORD flProtect //访问保护类型
);
BOOL VirtualFree(
LPVOID lpAddress, //申请内存返回的指针
DWORD dwSize, //释放内存大小
DWORD dwFreeType //释放类型 MEM_DECOMMIT释放物理页 MEM_RELEASE空间地址和物理页都释放 不过大小要填0
);
// VirtualAlloc.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <WINDOWS.H>
int main(int argc, char* argv[])
{
LPVOID p = VirtualAlloc(NULL,0x1000,MEM_COMMIT,PAGE_READWRITE);
VirtualFree(p,0x1000,MEM_DECOMMIT);
return 0;
}