General Memory Functions
The following functions are used in memory management.
Function | Description |
CopyMemory | Copies a block of memory from one location to another.复制内存,第一个参数为目的地址,第二个参数为源地址,第三个参数为复制数据的大小,单位为字节。 |
CreateMemoryResourceNotification | Creates a memory resource notification object. |
FillMemory | Fills a block of memory with a specified value.填充内存,将一段内存填充为同一个值。 |
GetLargePageMinimum | Retrieves the minimum size of a large page. |
GetSystemFileCacheSize | Retrieves the current size limits for the working set of the system cache. |
GetWriteWatch | Retrieves the addresses of the pages that have been written to in a region of virtual memory. |
GlobalMemoryStatus | Obtains information about the system's current usage of both physical and virtual memory. |
GlobalMemoryStatusEx | Obtains information about the system's current usage of both physical and virtual memory. |
MoveMemory | Moves a block of memory from one location to another.功能类是copymemory,不过源地址和目的地址可以相同。 |
QueryMemoryResourceNotification | Retrieves the state of the specified memory resource object. |
ResetWriteWatch | Resets the write-tracking state for a region of virtual memory. |
SecureZeroMemory | Fills a block of memory with zeros. |
SetSystemFileCacheSize | Limits the size of the working set for the file system cache. |
ZeroMemory | Fills a block of memory with zeros.将指定内存区域清零。 |
Data Execution Prevention Functions
The following functions are used with Data Execution Prevention (DEP).
Function | Description |
GetProcessDEPPolicy | Retrieves DEP settings for a process. |
GetSystemDEPPolicy | Retrieves DEP settings for the system. |
SetProcessDEPPolicy | Changes DEP settings for a process. |
File Mapping Functions
The following functions are used in file mapping.
Function | Description |
CreateFileMapping | Creates or opens a named or unnamed file mapping object for a specified file. |
CreateFileMappingNuma | Creates or opens a named or unnamed file mapping object for a specified file, and specifies the NUMA node for the physical memory. |
FlushViewOfFile | Writes to the disk a byte range within a mapped view of a file. |
GetMappedFileName | Checks whether the specified address is within a memory-mapped file in the address space of the specified process. If so, the function returns the name of the memory-mapped file. |
MapViewOfFile | Maps a view of a file mapping into the address space of a calling process. |
MapViewOfFileEx | Maps a view of a file mapping into the address space of a calling process. A caller can optionally specify a suggested memory address for the view. |
MapViewOfFileExNuma | Maps a view of a file mapping into the address space of a calling process, and specifies the NUMA node for the physical memory. |
OpenFileMapping | Opens a named file mapping object. |
UnmapViewOfFile | Unmaps a mapped view of a file from the calling process's address space. |
AWE Functions
The following are the AWE functions.
Function | Description |
AllocateUserPhysicalPages | Allocates physical memory pages to be mapped and unmapped within any AWE region of the process. |
FreeUserPhysicalPages | Frees physical memory pages previously allocated with AllocateUserPhysicalPages. |
MapUserPhysicalPages | Maps previously allocated physical memory pages at the specified address within an AWE region. |
MapUserPhysicalPagesScatter | Maps previously allocated physical memory pages at the specified address within an AWE region. |
Heap Functions
The following are the heap functions.
Function | Description |
GetProcessHeap | Obtains a handle to the heap of the calling process.获取当前进程的一个堆,返回一个堆句柄。 |
GetProcessHeaps | Obtains handles to all of the heaps that are valid for the calling process.获取进程中所有的堆,包括堆的数量和各个堆的句柄。 |
HeapAlloc | Allocates a block of memory from a heap.从指定堆上面分配内存块。 |
HeapCompact | Attempts to compact a specified heap. |
HeapCreate | Creates a heap object.为进程创建堆,返回一个堆句柄。 |
HeapDestroy | Destroys the specified heap object.销毁由heapalloc和heaprealloc所分配的内存 |
HeapFree | Frees a memory block allocated from a heap.释放有heapcreate所分配的内存 |
HeapLock | Attempts to acquire the lock associated with a specified heap.将globalalloc和globrealloc分配的属性为GMEM_MOVEABLE的内存块设为固定 |
HeapQueryInformation | Retrieves information about the specified heap. |
HeapReAlloc | Reallocates a block of memory from a heap.重新分配内存,改变已经分配好了的堆内存块大小。 |
HeapSetInformation | Sets heap information for the specified heap. |
HeapSize | Retrieves the size of a memory block allocated from a heap.获取指定堆的大小,以字节位单位返回堆大小的信息。 |
HeapUnlock | Releases ownership of the lock associated with a specified heap. |
HeapValidate | Attempts to validate a specified heap. |
HeapWalk | Enumerates the memory blocks in a specified heap. |
Virtual Memory Functions
The following are the virtual memory functions.
Function | Description |
VirtualAlloc | Reserves or commits a region of pages in the virtual address space of the calling process.“保留”或“提交”内存页面,将“空闲的”内存页面变为“保留的”或“已提交的”,将“保留的”页面变为“提交的”。 |
VirtualAllocEx | Reserves or commits a region of pages in the virtual address space of the specified process.类似VirtualAlloc功能,不过可以为其他进程分配内存。 |
VirtualAllocExNuma | Reserves or commits a region of memory within the virtual address space of the specified process, and specifies the NUMA node for the physical memory. |
VirtualFree | Releases or decommits a region of pages within the virtual address space of the calling process.将内存状态从“已提交的”变为“保留的”,或将“保留的”变为“空闲的”,或同时进行。 |
VirtualFreeEx | Releases or decommits a region of memory within the virtual address space of a specified process.释放有virtualallocex分配的内存,功能、使用方法和virtualfree类似。 |
VirtualLock | Locks the specified region of the process's virtual address space into physical memory. |
VirtualProtect | Changes the access protection on a region of committed pages in the virtual address space of the calling process.改变指定虚拟内存分页的保护属性。 |
VirtualProtectEx | Changes the access protection on a region of committed pages in the virtual address space of the calling process. |
VirtualQuery | Provides information about a range of pages in the virtual address space of the calling process. |
VirtualQueryEx | Provides information about a range of pages in the virtual address space of the calling process. |
VirtualUnlock | Unlocks a specified range of pages in the virtual address space of a process. |
Global and Local Functions
The following are the global and local functions. These functions are slower than other memory management functions and do not provide as many features. Therefore, new applications should use the heap functions. However, the global functions are still used with DDE and the clipboard functions.
Function | Description |
GlobalAlloc | Allocates the specified number of bytes from the heap. |
GlobalDiscard | Discards the specified global memory block. |
GlobalFlags | Returns information about the specified global memory object. |
GlobalFree | Frees the specified global memory object. |
GlobalHandle | Retrieves the handle associated with the specified pointer to a global memory block. |
GlobalLock | Locks a global memory object and returns a pointer to the first byte of the object's memory block. |
GlobalReAlloc | Changes the size or attributes of a specified global memory object. |
GlobalSize | Retrieves the current size of the specified global memory object. |
GlobalUnlock | Decrements the lock count associated with a memory object. |
LocalAlloc | Allocates the specified number of bytes from the heap. |
LocalDiscard | Discards the specified local memory object. |
LocalFlags | Returns information about the specified local memory object. |
LocalFree | Frees the specified local memory object. |
LocalHandle | Retrieves the handle associated with the specified pointer to a local memory object. |
LocalLock | Locks a local memory object and returns a pointer to the first byte of the object's memory block. |
LocalReAlloc | Changes the size or the attributes of a specified local memory object. |
LocalSize | Returns the current size of the specified local memory object. |
LocalUnlock | Decrements the lock count associated with a memory object. |
Obsolete Functions
The following functions are provided only for compatibility with 16-bit versions of Windows:
· IsBadCodePtr判定调用进程是否拥有对指定地址内存的读操作权限
· IsBadReadPtr判定调用进程是否拥有对指定地址段内存的读操作权限
· IsBadStringPtr判定调用进程是否拥有对指定字符串指针的读取权限
· IsBadWritePtr判断调用进程是否拥有对指定地址段内存的写操作权限
Build date: 8/15/2007
【参考资料 感谢作者】
1、摘自MSDN2008本地