From: Sebastian Lackner Subject: [3/4] ntdll: Fix handling of page fault if a guard page and write watch is triggered at the same time. Message-Id: <542F5159.9040200@fds-team.de> Date: Sat, 04 Oct 2014 03:46:01 +0200 From: Michael Müller See subject - unlikely, but in this case the user app wouldn't get any STATUS_GUARD_PAGE_VIOLATION exception. --- dlls/ntdll/virtual.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) From e01c439ea2f8af11a0ebefd23cabf59e0864c142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 4 Oct 2014 02:48:16 +0200 Subject: ntdll: Fix handling of page fault if a guard page and write watch is triggered at the same time. --- dlls/ntdll/virtual.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 4819d2d..f8a5dd3 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1522,11 +1522,6 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err ) { void *page = ROUND_ADDR( addr, page_mask ); BYTE *vprot = &view->prot[((const char *)page - (const char *)view->base) >> page_shift]; - if (*vprot & VPROT_GUARD) - { - VIRTUAL_SetProt( view, page, page_size, *vprot & ~VPROT_GUARD ); - ret = STATUS_GUARD_PAGE_VIOLATION; - } if ((err & EXCEPTION_WRITE_FAULT) && (view->protect & VPROT_WRITEWATCH)) { if (*vprot & VPROT_WRITEWATCH) @@ -1537,6 +1532,11 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err ) /* ignore fault if page is writable now */ if (VIRTUAL_GetUnixProt( *vprot ) & PROT_WRITE) ret = STATUS_SUCCESS; } + if (*vprot & VPROT_GUARD) + { + VIRTUAL_SetProt( view, page, page_size, *vprot & ~VPROT_GUARD ); + ret = STATUS_GUARD_PAGE_VIOLATION; + } } server_leave_uninterrupted_section( &csVirtual, &sigset ); return ret; -- 2.1.1