Removed first patch of series ws2_32_WriteWatches (accepted upstream).

This commit is contained in:
Sebastian Lackner
2015-03-19 20:23:42 +01:00
parent 5fe90fc2e8
commit 42b6978464
16 changed files with 150 additions and 241 deletions

View File

@@ -1,54 +0,0 @@
From 67e51503f973289b85c526eb05d76d78f7bd337e Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 3 Jan 2015 19:11:40 +0100
Subject: ntdll: Handle write watches in virtual_uninterrupted_write_memory.
---
dlls/ntdll/virtual.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 4c4c05d..8823164 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1730,12 +1730,32 @@ SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_
{
if (!(view->protect & VPROT_SYSTEM))
{
- void *page = ROUND_ADDR( addr, page_mask );
- BYTE *p = view->prot + (((const char *)page - (const char *)view->base) >> page_shift);
-
- while (bytes_written < size && (VIRTUAL_GetUnixProt( *p++ ) & PROT_WRITE))
+ while (bytes_written < size)
{
- SIZE_T block_size = min( size, page_size - ((UINT_PTR)addr & page_mask) );
+ void *page = ROUND_ADDR( addr, page_mask );
+ BYTE *p = view->prot + (((const char *)page - (const char *)view->base) >> page_shift);
+ SIZE_T block_size;
+
+ /* If the page is not writeable then check for write watches
+ * before giving up. This can be done without raising a real
+ * exception. Similar to virtual_handle_fault, but we can't
+ * handle guard pages here. */
+ if (!(VIRTUAL_GetUnixProt( *p ) & PROT_WRITE))
+ {
+ if (!(view->protect & VPROT_WRITEWATCH))
+ break;
+
+ if (*p & VPROT_WRITEWATCH)
+ {
+ *p &= ~VPROT_WRITEWATCH;
+ VIRTUAL_SetProt( view, page, page_size, *p );
+ }
+ /* ignore fault if page is writable now */
+ if (!(VIRTUAL_GetUnixProt( *p ) & PROT_WRITE))
+ break;
+ }
+
+ block_size = min( size, page_size - ((UINT_PTR)addr & page_mask) );
memcpy( addr, buffer, block_size );
addr = (void *)((char *)addr + block_size);
--
2.2.1