VirtualQuery
A version of this page is also available for
4/8/2010
This function provides information about a range of pages in the virtual address space of the calling process.
Syntax
DWORD VirtualQuery(
LPCVOID lpAddress,
PMEMORY_BASIC_INFORMATION lpBuffer,
DWORD dwLength
);
Parameters
lpAddress
[in] 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 the GetSystemInfo function.
- lpBuffer
[out] Pointer to a MEMORY_BASIC_INFORMATION structure in which information about the specified page range is returned.
- dwLength
[in] Specifies the size, in bytes, of the buffer pointed to by the lpBuffer parameter.
Return Value
The number of bytes returned in the information buffer indicates success.
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 as the MEM_COMMIT, MEM_RESERVE, MEM_FREE, MEM_PRIVATE, MEM_MAPPED, or MEM_IMAGE flags.
- If the initial page is not free, all pages in the region are part of the same initial allocation of pages reserved by a call to the VirtualAlloc function.
- The access of all pages is the same as the PAGE_READONLY, PAGE_READWRITE, PAGE_NOACCESS, PAGE_WRITECOPY, PAGE_EXECUTE, PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, PAGE_EXECUTE_WRITECOPY, PAGE_GUARD, or PAGE_NOCACHE flags.
The VirtualQuery 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, in bytes, of the region of pages with matching attributes. For example, if there is a 20 MB region of free memory and VirtualQuery is called on a page that is 10 MB into the region, the function obtains a state of MEM_FREE and a size of 10 MB.
Requirements
Header | winbase.h |
Library | coredll.lib |
Windows Embedded CE | Windows CE 1.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
See Also
Reference
Memory Management Functions
GetSystemInfo
VirtualAlloc
MEMORY_BASIC_INFORMATION