NtResetWriteWatch
Clears the write-tracking state of a MEM_WRITE_WATCH region without retrieving the dirty pages.
Prototype
NTSTATUS NtResetWriteWatch( HANDLE ProcessHandle, PVOID BaseAddress, SIZE_T RegionSize );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| ProcessHandle | HANDLE | in | Handle to the process whose write-watch state is being reset. Usually NtCurrentProcess(). |
| BaseAddress | PVOID | in | Base address of the MEM_WRITE_WATCH region whose dirty bits should be cleared. |
| RegionSize | SIZE_T | in | Size in bytes of the region to reset. Must be within the original allocation. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0x15F | win10-1507 |
| Win10 1607 | 0x166 | win10-1607 |
| Win10 1703 | 0x16C | win10-1703 |
| Win10 1709 | 0x16F | win10-1709 |
| Win10 1803 | 0x171 | win10-1803 |
| Win10 1809 | 0x172 | win10-1809 |
| Win10 1903 | 0x173 | win10-1903 |
| Win10 1909 | 0x173 | win10-1909 |
| Win10 2004 | 0x179 | win10-2004 |
| Win10 20H2 | 0x179 | win10-20h2 |
| Win10 21H1 | 0x179 | win10-21h1 |
| Win10 21H2 | 0x17B | win10-21h2 |
| Win10 22H2 | 0x17B | win10-22h2 |
| Win11 21H2 | 0x183 | win11-21h2 |
| Win11 22H2 | 0x186 | win11-22h2 |
| Win11 23H2 | 0x186 | win11-23h2 |
| Win11 24H2 | 0x188 | win11-24h2 |
| Server 2016 | 0x166 | winserver-2016 |
| Server 2019 | 0x172 | winserver-2019 |
| Server 2022 | 0x181 | winserver-2022 |
| Server 2025 | 0x188 | winserver-2025 |
Kernel module
Related APIs
Syscall stub
4C 8B D1 mov r10, rcx B8 88 01 00 00 mov eax, 0x188 F6 04 25 08 03 FE 7F 01 test byte ptr [0x7FFE0308], 1 75 03 jne short +3 0F 05 syscall C3 ret CD 2E int 2Eh C3 ret
Undocumented notes
NtResetWriteWatch is the standalone reset companion to NtGetWriteWatch. Most callers prefer the atomic form `NtGetWriteWatch(WRITE_WATCH_FLAG_RESET, ...)` because it eliminates the race window between query and reset. The separate syscall is useful when the caller wants to discard dirty information entirely (e.g. after a full re-encryption pass) without paying for the array copy-out of NtGetWriteWatch. The kernel implementation walks the same PTE-level dirty bits cleared by `MiResetWriteWatch`.
Common malware usage
Used by sleep-mask implants that perform a full memory re-encrypt at startup or after a configuration update — the implant doesn't care which pages were dirty, it's encrypting everything anyway, but it still needs to reset the watch state so the *next* incremental encryption pass sees only the truly-dirty pages from the next awake window. Less commonly used standalone than NtGetWriteWatch since the atomic-reset flag exists, but appears in some early-generation sleep masks (pre-Ekko) that decoupled the two phases. Forensic analysis of a paused implant snapshot can sometimes catch the reset call mid-cycle when the dirty bits are momentarily clean.
Detection opportunities
Same kernel-level signal as NtGetWriteWatch — the VAD's `VadWriteWatch` flag is the prerequisite for either syscall to do anything meaningful. NtResetWriteWatch without a preceding (or pending) NtGetWriteWatch on the same range is unusual outside of the .NET GC's start-of-cycle reset path. EDRs with VAD-walk capability can flag any user-mode process holding a sizeable MEM_WRITE_WATCH region with PAGE_EXECUTE_READ or PAGE_EXECUTE_READWRITE protection — that combination is essentially never seen in benign software and is a hallmark of dirty-page-aware sleep masks.
Direct syscall examples
cStandalone reset after a full pass
// After a full memory rescan / full re-encrypt, drop the dirty bits without
// the cost of copying out the dirty-page array.
#include <windows.h>
void reset_tracking(PVOID region, SIZE_T size) {
// ResetWriteWatch is the documented Win32 wrapper around NtResetWriteWatch.
if (ResetWriteWatch(region, size) != 0) {
// Region was not allocated with MEM_WRITE_WATCH.
}
}asmx64 direct stub (Win11 24H2, SSN 0x188)
NtResetWriteWatch PROC
mov r10, rcx
mov eax, 188h
syscall
ret
NtResetWriteWatch ENDPcTwo-phase sleep mask (pre-Ekko style)
// Phase 1: encrypt every page (full pass), then reset the watch state.
// Phase 2 (next cycle): NtGetWriteWatch reports only newly dirtied pages.
void full_encrypt_and_reset(PVOID region, SIZE_T size) {
encrypt_full(region, size);
ResetWriteWatch(region, size); // ntdll!NtResetWriteWatch under the hood
}MITRE ATT&CK mappings
Last verified: 2026-05-20