Platform SDK: Memory |
The GetWriteWatch function retrieves the addresses of the pages that have been written to in a region of virtual memory.
UINT GetWriteWatch( DWORD dwFlags, // write-tracking state PVOID lpBaseAddress, // base address of region SIZE_T dwRegionSize, // size of region PVOID *lpAddresses, // array of page addresses PULONG_PTR lpdwCount, // number of addresses returned PULONG lpdwGranularity // page size );
If the function succeeds, the return value is zero.
If the function fails, the return value is a nonzero value.
When you call the VirtualAlloc function to reserve or commit memory, you can specify MEM_WRITE_WATCH. This value causes the system to keep track of the pages in the committed memory region that have been written to. You can then call the GetWriteWatch function to retrieve the addresses of the pages that have been written to since the region was allocated or the write-tracking state was reset.
To reset the write-tracking state, set the WRITE_WATCH_FLAG_RESET value in the dwFlags parameter. Alternatively, you can call the ResetWriteWatch function to reset the write-tracking state. If you use ResetWriteWatch, however, you must ensure that no threads write to the region during the interval between the GetWriteWatch and ResetWriteWatch calls. Otherwise, there may be written pages that you fail to detect.
The GetWriteWatch function can be useful to profilers, debugging tools, or garbage collectors.
Windows NT/2000: Unsupported.
Windows 95/98: Requires Windows 98.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Memory Management Overview, Memory Management Functions, ResetWriteWatch, VirtualAlloc