unsigned get_write_watch(unsigned flags,
                         void* base_address,
                         ulong region_size,
                         void* addresses,
                         ulong* count,
                         unsigned* granularity);

This function obtains the addresses of the pages that are written to in a region of virtual memory.


unsigned flags

This flag indicates whether the function resets the write-tracking state. To reset the write-tracking state, set this parameter to memory_flag::WriteWatchFlagReset. If this parameter is 0, get_write_watch does not reset the write-tracking state. For more information, see the notes section of this topic.

void* base_address

The base address of the memory region for which write-tracking information is obtained. This address must be in a memory region that is allocated by the function allocate_memory using option memory_write_watch.

ulong* region_size

The size (in bytes) of the memory region for which to retrieve write-tracking information.

void* addresses

A pointer to an array of page addresses in the memory region.

ulong* count

On input, this variable indicates the size (in array elements) of the array Addresses. On output, the variable receives the number of page addresses that are returned in the array.

unsigned* granularity

A pointer to a variable that receives the page size (in bytes).



If the function succeeds, the return value is 0. If the function fails, the return value is nonzero.


When the function allocate_memory is called to reserve or commit memory, the flag memory_flag::WriteWatch may be specified. This causes the system to keep track of the pages that are written to in the committed memory region. This function may be called to retrieve the addresses of the pages that have been written to since the region has been allocated or the write-tracking state has been reset.

To reset the write-tracking state, set the flag memory_flag::write_watch_flag_reset in the flags parameter. Alternatively, the function reset_write_watch may be called to reset the write-tracking state. However, if reset_write_watch is used, no threads should write to the region during the interval between the get_write_watch and reset_write_watch calls. Otherwise, there may be written pages that are not detected.