获取内存中块的信息(VirtualQuery)
来源:互联网 发布:360浏览器使用js脚本 编辑:程序博客网 时间:2024/06/05 20:17
Retrieves information about a range of pages in the virtual address space of the calling process.
To retrieve information about a range of pages in the address space of another process, use theVirtualQueryEx function.
Syntax
SIZE_T WINAPI VirtualQuery( _In_opt_ LPCVOID lpAddress, _Out_ PMEMORY_BASIC_INFORMATION lpBuffer, _In_ SIZE_T dwLength);
Parameters
- lpAddress [in, optional]
A pointer to the base address of the region of pages to be queried. This value is rounded down to the next page boundary. To determine the size of a page on the host computer, use theGetSystemInfo function.
If lpAddress specifies an address above the highest memory address accessible to the process, the function fails withERROR_INVALID_PARAMETER.
- lpBuffer [out]
A pointer to a MEMORY_BASIC_INFORMATION structure in which information about the specified page range is returned.
- dwLength [in]
The size of the buffer pointed to by the lpBuffer parameter, in bytes.
Return value
The return value is the actual number of bytes returned in the information buffer.
If the function fails, the return value is zero. To get extended error information, callGetLastError. Possible error values include ERROR_INVALID_PARAMETER.
Remarks
VirtualQuery provides information about a region of consecutive pages beginning at a specified address that share the following attributes:
- The state of all pages is the same (MEM_COMMIT, MEM_RESERVE,MEM_FREE, MEM_PRIVATE, MEM_MAPPED, orMEM_IMAGE).
- If the initial page is not free, all pages in the region are part of the same initial allocation of pages created by a single call toVirtualAlloc, MapViewOfFile, or one of the following extended versions of these functions:VirtualAllocEx, VirtualAllocExNuma, MapViewOfFileEx, MapViewOfFileExNuma.
- The access granted to all pages is the same (PAGE_READONLY, PAGE_READWRITE, PAGE_NOACCESS, PAGE_WRITECOPY,PAGE_EXECUTE, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE,PAGE_EXECUTE_WRITECOPY, PAGE_GUARD, or PAGE_NOCACHE).
The function determines the attributes of the first page in the region and then scans subsequent pages until it scans the entire range of pages or until it encounters a page with a nonmatching set of attributes. The function returns the attributes and the size of the region of pages with matching attributes, in bytes. For example, if there is a 40 megabyte (MB) region of free memory, andVirtualQuery is called on a page that is 10 MB into the region, the function will obtain a state ofMEM_FREE and a size of 30 MB.
If a shared copy-on-write page is modified, it becomes private to the process that modified the page. However, theVirtualQuery function will continue to report such pages as MEM_MAPPED (for data views) or MEM_IMAGE (for executable image views) rather thanMEM_PRIVATE. To detect whether copy-on-write has occurred for a specific page, either access the page or lock it using theVirtualLock function to make sure the page is resident in memory, then use theQueryWorkingSetEx function to check the Shared bit in the extended working set information for the page. If theShared bit is clear, the page is private.
This function reports on a region of pages in the memory of the calling process, and theVirtualQueryEx function reports on a region of pages in the memory of a specified process.
Requirements
Minimum supported client
Windows XP [desktop apps | Windows Store apps]
Minimum supported server
Windows Server 2003 [desktop apps | Windows Store apps]
Minimum supported phone
Windows Phone 8
Header
- WinBase.h (include Windows.h)
Library
- Kernel32.lib
DLL
- Kernel32.dll
See also
- GetSystemInfo
- MapViewOfFile
- Memory Management Functions
- MEMORY_BASIC_INFORMATION
- Virtual Memory Functions
- VirtualQueryEx
- 获取内存中块的信息(VirtualQuery)
- 使用VirtualQuery查看内存页面信息
- 使用VirtualQuery查看内存页面信息
- 通过VirtualQuery获取当前模块的句柄
- 内存池中如何保存内存块大小信息
- Sigar获取内存的信息
- asp.net中获取本机的相关信息!(CPU、内存、硬盘序列号等)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一) .
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用
- 使用Spring Data操作mongoDB
- 解决spring使用动态代理类型转换失败的问题--java.lang.ClassCastException: com.sun.proxy.$Proxy$ cannot be cast to ...今天
- TCP连接TIME-WAIT
- 简单滑动门js代码
- Sqoop1.4.6安装与使用(二)
- 获取内存中块的信息(VirtualQuery)
- 创建 OpenStack云主机 [六]
- Android应用程序消息处理机制(Looper、Handler)分析
- 使用jspatch进行热修复的实战总结
- 理解性能的奥秘——应用程序中慢,SSMS中快(6)——SQL Server如何编译动态SQL
- iOS中UILabel显示不同的字体和颜色
- list_entry()
- 使用WebUploader上传图片
- crond定时任务