Does ::GetWriteWatch always give an up to date list of modified pages? Or is it possible, because of processor caches, that some pages are still considered unmodified because cached writes have not been flushed to main memory?
Consider the following snippet of C++ code:
auto ptr = ::VirtualAlloc(NULL, 8192, MEM_COMMIT | MEM_RESERVE, MEM_WRITE_WATCH);
auto num = new (ptr) int{};
::ResetWriteWatch(ptr, 8192);
// ... calculations that involve writing to 'num' ...
::GetWriteWatch(/* ... */);
This should reserve and commit two pages of virtual memory, modify the first page, and finally request all modified pages.
Is it guaranteed that the first page is listed as modified by the call to ::GetWriteWatch?