Retrieves information about a range of pages within the virtual address space of a specified process.
SyntaxSIZE_T VirtualQueryEx(
[in] HANDLE hProcess,
[in, optional] LPCVOID lpAddress,
[out] PMEMORY_BASIC_INFORMATION lpBuffer,
[in] SIZE_T dwLength
);
Parameters
[in] hProcess
A handle to the process whose memory information is queried. The handle must have been opened with the PROCESS_QUERY_INFORMATION access right, which enables using the handle to read information from the process object. For more information, see Process Security and Access Rights.
[in, optional] lpAddress
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 the GetSystemInfo function.
If lpAddress specifies an address above the highest memory address accessible to the process, the function fails with ERROR_INVALID_PARAMETER.
[out] lpBuffer
A pointer to a MEMORY_BASIC_INFORMATION structure in which information about the specified page range is returned.
[in] dwLength
The size of the buffer pointed to by the lpBuffer parameter, in bytes.
Return valueThe 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, call GetLastError. Possible error values include ERROR_INVALID_PARAMETER.
VirtualQueryEx provides information about a region of consecutive pages beginning at a specified address that share the following attributes:
The
VirtualQueryExfunction 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, and
VirtualQueryExis called on a page that is 10 MB into the region, the function will obtain a state of
MEM_FREEand 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, the VirtualQueryEx function will continue to report such pages as MEM_MAPPED (for data views) or MEM_IMAGE (for executable image views) rather than MEM_PRIVATE. To detect whether copy-on-write has occurred for a specific page, either access the page or lock it using the VirtualLock function to make sure the page is resident in memory, then use the QueryWorkingSet or QueryWorkingSetEx function to check the Shared bit in the extended working set information for the page. If the Shared bit is clear, the page is private.
Requirements Requirement Value Minimum supported client Windows XP [desktop apps | UWP apps] Minimum supported server Windows Server 2003 [desktop apps | UWP apps] Target Platform Windows Header memoryapi.h (include Windows.h, Memoryapi.h) Library onecore.lib DLL Kernel32.dll See alsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4