Memory Management Functions--内存管理函数

来源:互联网 发布:图论与网络流理论答案 编辑:程序博客网 时间:2024/06/05 21:11

IsBadReadPtr

The IsBadReadPtr function verifies(证实) that the calling process has read access to the specified range of memory.( 调用程序访问的是指定范围的内存):也就是说检查该指针是否有访问权限
原型:
BOOL IsBadReadPtr(
CONST VOID *lp, // address of memory block
UINT ucb // size of block
);

VirtualAllocEx

The VirtualAllocEx function reserves, commits, or both, a region of memory within the virtual address space of a specified process. The function initializes the memory it allocates to zero, unless the MEM_RESET flag is set.
//该函数在指定进程的虚拟地址空间中保留、提交或者保留且提交一块内存区域;
并且把这块区域初始化为0,除非指定MEM_RESET参数。

原型:
LPVOID VirtualAllocEx(
HANDLE hProcess, //申请内存所在的进程句柄(哪个进程要申请内存)
LPVOID lpAddress, // 保留页面的内存地址;一般用NULL自动分配 。
DWORD dwSize, //欲分配的内存大小,字节单位;注意实际分 配的内存大小是页内存大小的整数倍
DWORD flAllocationType,// 分配类型 详见MSDN
DWORD flProtect // 访问保护类型 详见MSDN
);
返回值:
执行成功就返回分配内存的首地址,不成功就是NULL。

0 0