Rebase against 48020f4846cca1a02f4e1dc037e2cc2068df5e9c.

This commit is contained in:
Zebediah Figura
2020-06-02 18:20:16 -05:00
parent 676f261e5e
commit a4d98c48f9
27 changed files with 312 additions and 335 deletions

View File

@@ -1,4 +1,4 @@
From 5ea68740395cd0ae34fb4d74d540b30170645ac3 Mon Sep 17 00:00:00 2001
From 78a7689c0360fbf9ab6e494cc7113da5f73510fe Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 4 Oct 2014 02:35:44 +0200
Subject: [PATCH] ntdll: Trigger write watches before passing userdata pointer
@@ -6,8 +6,8 @@ Subject: [PATCH] ntdll: Trigger write watches before passing userdata pointer
---
dlls/advapi32/tests/security.c | 1 -
dlls/ntdll/server.c | 9 +++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
dlls/ntdll/unix/server.c | 8 ++++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 825f8451904..b414401634a 100644
@@ -21,16 +21,18 @@ index 825f8451904..b414401634a 100644
ok(Access == 0x1abe11ed && AccessStatus == 0x1abe11ed,
"Access and/or AccessStatus were changed!\n");
diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c
index ed4e3f25531..921dec86c82 100644
--- a/dlls/ntdll/server.c
+++ b/dlls/ntdll/server.c
@@ -166,6 +166,15 @@ static DECLSPEC_NORETURN void server_protocol_perror( const char *err )
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index 17b23e58d28..91155a1663d 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -304,9 +304,17 @@ unsigned int server_call_unlocked( void *req_ptr )
*/
unsigned int CDECL wine_server_call( void *req_ptr )
{
+ struct __server_request_info * const req = req_ptr;
+
sigset_t old_set;
unsigned int ret;
+ /* trigger write watches, otherwise read() might return EFAULT */
+ if (req->u.req.request_header.reply_size &&
+ !virtual_check_buffer_for_write( req->reply_data, req->u.req.request_header.reply_size ))
@@ -38,9 +40,9 @@ index ed4e3f25531..921dec86c82 100644
+ return STATUS_ACCESS_VIOLATION;
+ }
+
return unix_funcs->server_call( req_ptr );
}
pthread_sigmask( SIG_BLOCK, &server_block_set, &old_set );
ret = server_call_unlocked( req_ptr );
pthread_sigmask( SIG_SETMASK, &old_set, NULL );
--
2.26.2

View File

@@ -1,4 +1,4 @@
From dcd95cc3f7ef19b34669ebfeb92c29da16ac2387 Mon Sep 17 00:00:00 2001
From 6fa954cc5fd6840c9207abf4f41e53be0dbf8728 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 4 Oct 2014 02:53:22 +0200
Subject: [PATCH] ntdll: Setup a temporary signal handler during process
@@ -15,10 +15,10 @@ Subject: [PATCH] ntdll: Setup a temporary signal handler during process
7 files changed, 79 insertions(+)
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 427cdaad441..562f5ec8d4c 100644
index e9a3230e814..04aee675e55 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -80,6 +80,7 @@ extern LPCSTR debugstr_ObjectAttributes(const OBJECT_ATTRIBUTES *oa) DECLSPEC_HI
@@ -78,6 +78,7 @@ extern LPCSTR debugstr_ObjectAttributes(const OBJECT_ATTRIBUTES *oa) DECLSPEC_HI
extern SIZE_T signal_stack_size DECLSPEC_HIDDEN;
extern SIZE_T signal_stack_mask DECLSPEC_HIDDEN;
extern void signal_init_process(void) DECLSPEC_HIDDEN;
@@ -27,10 +27,10 @@ index 427cdaad441..562f5ec8d4c 100644
extern void signal_start_process( LPTHREAD_START_ROUTINE entry, BOOL suspend ) DECLSPEC_HIDDEN;
extern void version_init(void) DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c
index e66cf922f91..dcfdeaa83ad 100644
index b7e387babf1..bb329f888ce 100644
--- a/dlls/ntdll/signal_arm.c
+++ b/dlls/ntdll/signal_arm.c
@@ -988,6 +988,12 @@ void signal_init_process(void)
@@ -774,6 +774,12 @@ void signal_init_process(void)
exit(1);
}
@@ -44,10 +44,10 @@ index e66cf922f91..dcfdeaa83ad 100644
/***********************************************************************
* RtlUnwind (NTDLL.@)
diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c
index c87f99f0c4c..fed76574dbc 100644
index c2dd129a569..22d4983d5c6 100644
--- a/dlls/ntdll/signal_arm64.c
+++ b/dlls/ntdll/signal_arm64.c
@@ -1303,6 +1303,12 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
@@ -1101,6 +1101,12 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
return 0;
}
@@ -61,10 +61,10 @@ index c87f99f0c4c..fed76574dbc 100644
/**********************************************************************
* signal_init_process
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 2f2db70b57f..12771552a5d 100644
index 78d03f669d7..e3dc2c0d1c8 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -1988,6 +1988,31 @@ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, st
@@ -1737,6 +1737,31 @@ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, st
}
@@ -83,7 +83,7 @@ index 2f2db70b57f..12771552a5d 100644
+ switch(get_trap_code(context))
+ {
+ case TRAP_x86_PAGEFLT: /* Page fault */
+ if (!virtual_handle_fault( siginfo->si_addr, (get_error_code(context) >> 1) & 0x09, TRUE ))
+ if (!unix_funcs->virtual_handle_fault( siginfo->si_addr, (get_error_code(context) >> 1) & 0x09, TRUE ))
+ return;
+ /* fall-through */
+ default:
@@ -96,7 +96,7 @@ index 2f2db70b57f..12771552a5d 100644
/**********************************************************************
* segv_handler
*
@@ -2315,6 +2340,34 @@ void signal_init_process(void)
@@ -2064,6 +2089,34 @@ void signal_init_process(void)
exit(1);
}
@@ -132,10 +132,10 @@ index 2f2db70b57f..12771552a5d 100644
/*******************************************************************
* RtlUnwind (NTDLL.@)
diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c
index a23f6b6e4d5..c3b4b6ffd42 100644
index 75b18e1e933..314a0677d92 100644
--- a/dlls/ntdll/signal_powerpc.c
+++ b/dlls/ntdll/signal_powerpc.c
@@ -1009,6 +1009,12 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
@@ -638,6 +638,12 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
return 0;
}
@@ -149,10 +149,10 @@ index a23f6b6e4d5..c3b4b6ffd42 100644
/**********************************************************************
* signal_init_process
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index d42438f88af..b4c11ed66ed 100644
index 7cefd1403f3..0eb58d3d149 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -3141,6 +3141,12 @@ void signal_init_process(void)
@@ -2850,6 +2850,12 @@ void signal_init_process(void)
exit(1);
}
@@ -166,7 +166,7 @@ index d42438f88af..b4c11ed66ed 100644
static ULONG64 get_int_reg( CONTEXT *context, int reg )
{
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index bb11521cf69..ff18b119232 100644
index f9ea9203ed8..31213614911 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -228,6 +228,7 @@ TEB *thread_init(void)

View File

@@ -1,19 +1,19 @@
From 8c8e2422bea9485bdcda98cea703983bb01f6e41 Mon Sep 17 00:00:00 2001
From f5019b4f92b14ef22e7e96a38442f7f864488b10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 4 Oct 2014 03:22:09 +0200
Subject: [PATCH] ntdll: Properly handle PAGE_WRITECOPY protection. (try 5)
For now, only enable it when a special environment variable is set.
---
dlls/ntdll/virtual.c | 46 +++++++++++++++++++++++++++++++++++++-------
dlls/ntdll/unix/virtual.c | 46 +++++++++++++++++++++++++++++++++------
1 file changed, 39 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 328bc40a92f..3533a087d88 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -321,6 +321,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot )
return buffer;
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 0346d0d9753..5a8ba8bae2a 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -498,6 +498,21 @@ int CDECL mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T si
return ret;
}
+/* This might look like a hack, but it actually isn't - the 'experimental' version
@@ -33,8 +33,8 @@ index 328bc40a92f..3533a087d88 100644
+}
/***********************************************************************
* VIRTUAL_GetUnixProt
@@ -334,8 +349,19 @@ static int VIRTUAL_GetUnixProt( BYTE vprot )
* free_ranges_lower_bound
@@ -799,8 +814,19 @@ static int get_unix_prot( BYTE vprot )
{
if (vprot & VPROT_READ) prot |= PROT_READ;
if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ;
@@ -55,7 +55,7 @@ index 328bc40a92f..3533a087d88 100644
if (vprot & VPROT_WRITEWATCH) prot &= ~PROT_WRITE;
}
if (!prot) prot = PROT_NONE;
@@ -1080,7 +1106,7 @@ static void update_write_watches( void *base, size_t size, size_t accessed_size
@@ -1539,7 +1565,7 @@ static void update_write_watches( void *base, size_t size, size_t accessed_size
{
TRACE( "updating watch %p-%p-%p\n", base, (char *)base + accessed_size, (char *)base + size );
/* clear write watch flag on accessed pages */
@@ -64,12 +64,12 @@ index 328bc40a92f..3533a087d88 100644
/* restore page protections on the entire range */
mprotect_range( base, size, 0, 0 );
}
@@ -2340,12 +2366,13 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack )
@@ -2746,12 +2772,13 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta
set_page_vprot_bits( page, page_size, 0, VPROT_WRITEWATCH );
mprotect_range( page, page_size, 0, 0 );
}
- /* ignore fault if page is writable now */
- if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE)
- if (get_unix_prot( get_page_vprot( page )) & PROT_WRITE)
+ if (vprot & VPROT_WRITECOPY)
{
- if ((vprot & VPROT_WRITEWATCH) || is_write_watch_range( page, page_size ))
@@ -78,11 +78,11 @@ index 328bc40a92f..3533a087d88 100644
+ mprotect_range( page, page_size, 0, 0 );
}
+ /* ignore fault if page is writable now */
+ if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS;
+ if (get_unix_prot( get_page_vprot( page ) ) & PROT_WRITE) ret = STATUS_SUCCESS;
}
server_leave_uninterrupted_section( &csVirtual, &sigset );
return ret;
@@ -2367,11 +2394,16 @@ static NTSTATUS check_write_access( void *base, size_t size, BOOL *has_write_wat
@@ -2773,11 +2800,16 @@ static NTSTATUS check_write_access( void *base, size_t size, BOOL *has_write_wat
{
BYTE vprot = get_page_vprot( addr + i );
if (vprot & VPROT_WRITEWATCH) *has_write_watch = TRUE;
@@ -91,7 +91,7 @@ index 328bc40a92f..3533a087d88 100644
+ vprot = (vprot & ~VPROT_WRITECOPY) | VPROT_WRITE;
+ *has_write_watch = TRUE;
+ }
if (!(VIRTUAL_GetUnixProt( vprot & ~VPROT_WRITEWATCH ) & PROT_WRITE))
if (!(get_unix_prot( vprot & ~VPROT_WRITEWATCH ) & PROT_WRITE))
return STATUS_INVALID_USER_BUFFER;
}
if (*has_write_watch)

View File

@@ -1,4 +1,4 @@
From c38118527458007162f8cbe38bec0dd02b9de6e7 Mon Sep 17 00:00:00 2001
From 6836700fb6d9e0221de770c8b020822b6f4c9b55 Mon Sep 17 00:00:00 2001
From: Andrew Wesie <awesie@gmail.com>
Date: Fri, 24 Apr 2020 14:55:14 -0500
Subject: [PATCH] ntdll: Track if a WRITECOPY page has been modified.
@@ -8,14 +8,14 @@ read-write page.
Signed-off-by: Andrew Wesie <awesie@gmail.com>
---
dlls/ntdll/virtual.c | 25 +++++++++++++++++++------
dlls/ntdll/unix/virtual.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 3533a087d88..75219ae2376 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -85,6 +85,7 @@ struct file_view
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 5a8ba8bae2a..c81104bd266 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -97,6 +97,7 @@ struct file_view
#define VPROT_GUARD 0x10
#define VPROT_COMMITTED 0x20
#define VPROT_WRITEWATCH 0x40
@@ -23,7 +23,7 @@ index 3533a087d88..75219ae2376 100644
/* per-mapping protection flags */
#define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */
@@ -353,7 +354,7 @@ static int VIRTUAL_GetUnixProt( BYTE vprot )
@@ -818,7 +819,7 @@ static int get_unix_prot( BYTE vprot )
#if defined(__i386__)
if (vprot & VPROT_WRITECOPY)
{
@@ -32,9 +32,9 @@ index 3533a087d88..75219ae2376 100644
prot = (prot & ~PROT_WRITE) | PROT_READ;
else
prot |= PROT_WRITE | PROT_READ;
@@ -925,7 +926,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz
@@ -1397,7 +1398,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz
*/
static DWORD VIRTUAL_GetWin32Prot( BYTE vprot, unsigned int map_prot )
static DWORD get_win32_prot( BYTE vprot, unsigned int map_prot )
{
- DWORD ret = VIRTUAL_Win32Flags[vprot & 0x0f];
+ DWORD ret;
@@ -45,7 +45,7 @@ index 3533a087d88..75219ae2376 100644
if (vprot & VPROT_GUARD) ret |= PAGE_GUARD;
if (map_prot & SEC_NOCACHE) ret |= PAGE_NOCACHE;
return ret;
@@ -1049,7 +1054,7 @@ static BOOL VIRTUAL_SetProt( struct file_view *view, /* [in] Pointer to view */
@@ -1508,7 +1513,7 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr
if (view->protect & VPROT_WRITEWATCH)
{
/* each page may need different protections depending on write watch flag */
@@ -54,7 +54,7 @@ index 3533a087d88..75219ae2376 100644
mprotect_range( base, size, 0, 0 );
return TRUE;
}
@@ -1065,10 +1070,18 @@ static BOOL VIRTUAL_SetProt( struct file_view *view, /* [in] Pointer to view */
@@ -1524,10 +1529,18 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr
return TRUE;
}
@@ -74,7 +74,7 @@ index 3533a087d88..75219ae2376 100644
return TRUE;
}
@@ -2368,7 +2381,7 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack )
@@ -2774,7 +2787,7 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta
}
if (vprot & VPROT_WRITECOPY)
{
@@ -83,7 +83,7 @@ index 3533a087d88..75219ae2376 100644
mprotect_range( page, page_size, 0, 0 );
}
/* ignore fault if page is writable now */
@@ -3272,7 +3285,7 @@ static NTSTATUS get_basic_memory_info( HANDLE process, LPCVOID addr,
@@ -3660,7 +3673,7 @@ static NTSTATUS get_basic_memory_info( HANDLE process, LPCVOID addr,
else if (view->protect & (SEC_FILE | SEC_RESERVE | SEC_COMMIT)) info->Type = MEM_MAPPED;
else info->Type = MEM_PRIVATE;
for (ptr = base; ptr < base + range_size; ptr += page_size)

View File

@@ -1,4 +1,4 @@
From d92ad57aa5a51f41f1d01d39e8585e4398770893 Mon Sep 17 00:00:00 2001
From aae6e8d097aaa6665a65ec6f896e37b445c371ea Mon Sep 17 00:00:00 2001
From: Andrew Wesie <awesie@gmail.com>
Date: Fri, 24 Apr 2020 14:55:15 -0500
Subject: [PATCH] ntdll: Support WRITECOPY on x64.
@@ -6,14 +6,14 @@ Subject: [PATCH] ntdll: Support WRITECOPY on x64.
Signed-off-by: Andrew Wesie <awesie@gmail.com>
---
dlls/ntdll/signal_x86_64.c | 40 ++++++++++++++++++++++++++++++++++++++
dlls/ntdll/virtual.c | 2 +-
dlls/ntdll/unix/virtual.c | 2 +-
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 29829bfb1c6..89a8e36410d 100644
index 0eb58d3d149..8fdb800984c 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -2871,6 +2871,29 @@ static inline BOOL handle_interrupt( ucontext_t *sigcontext, struct stack_layout
@@ -2575,6 +2575,29 @@ static inline BOOL handle_interrupt( ucontext_t *sigcontext, struct stack_layout
}
@@ -30,7 +30,7 @@ index 29829bfb1c6..89a8e36410d 100644
+ switch(TRAP_sig(ucontext))
+ {
+ case TRAP_x86_PAGEFLT: /* Page fault */
+ if (!virtual_handle_fault( siginfo->si_addr, (ERROR_sig(ucontext) >> 1) & 0x09, TRUE ))
+ if (!unix_funcs->virtual_handle_fault( siginfo->si_addr, (ERROR_sig(ucontext) >> 1) & 0x09, TRUE ))
+ return;
+ /* fall-through */
+ default:
@@ -43,7 +43,7 @@ index 29829bfb1c6..89a8e36410d 100644
/**********************************************************************
* segv_handler
*
@@ -3291,6 +3314,23 @@ void signal_init_process(void)
@@ -2855,6 +2878,23 @@ void signal_init_process(void)
*/
void signal_init_early(void)
{
@@ -67,11 +67,11 @@ index 29829bfb1c6..89a8e36410d 100644
}
static ULONG64 get_int_reg( CONTEXT *context, int reg )
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 75219ae2376..df77f55a9e7 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -351,7 +351,7 @@ static int VIRTUAL_GetUnixProt( BYTE vprot )
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index c81104bd266..1072907ffdd 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -816,7 +816,7 @@ static int get_unix_prot( BYTE vprot )
if (vprot & VPROT_READ) prot |= PROT_READ;
if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ;
if (vprot & VPROT_EXEC) prot |= PROT_EXEC | PROT_READ;

View File

@@ -1,4 +1,4 @@
From b2ce2a421031982e0e0923d84bdbe767b14747b9 Mon Sep 17 00:00:00 2001
From 262cfe702345c97ebb32a651cef272fe74e98322 Mon Sep 17 00:00:00 2001
From: Andrew Wesie <awesie@gmail.com>
Date: Fri, 24 Apr 2020 14:55:17 -0500
Subject: [PATCH] ntdll: Report unmodified WRITECOPY pages as shared.
@@ -9,14 +9,14 @@ match the behavior of Windows.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48665
Signed-off-by: Andrew Wesie <awesie@gmail.com>
---
dlls/ntdll/virtual.c | 4 +++-
dlls/ntdll/unix/virtual.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index df77f55a9e7..b329a9024d8 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1737,6 +1737,8 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, int top_
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 1072907ffdd..9a576de4930 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -2188,6 +2188,8 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, int top_
ptr + sec->VirtualAddress + file_size,
ptr + sec->VirtualAddress + end );
memset( ptr + sec->VirtualAddress + file_size, 0, end - file_size );
@@ -25,7 +25,7 @@ index df77f55a9e7..b329a9024d8 100644
}
}
@@ -3336,7 +3338,7 @@ static NTSTATUS get_working_set_ex( HANDLE process, LPCVOID addr,
@@ -3724,7 +3726,7 @@ static NTSTATUS get_working_set_ex( HANDLE process, LPCVOID addr,
(vprot & VPROT_COMMITTED))
{
p->VirtualAttributes.Valid = !(vprot & VPROT_GUARD) && (vprot & 0x0f) && (pagemap >> 63);

View File

@@ -1,4 +1,4 @@
From e7d46415e6361015c969027ade253a03e620cd66 Mon Sep 17 00:00:00 2001
From 560a608432d8d4df920370e4bd50113c1db87b1f Mon Sep 17 00:00:00 2001
From: Andrew Wesie <awesie@gmail.com>
Date: Tue, 28 Apr 2020 03:27:16 -0500
Subject: [PATCH] ntdll: Fallback to copy pages for WRITECOPY.
@@ -12,14 +12,14 @@ then copy the contents to the new page.
Signed-off-by: Andrew Wesie <awesie@gmail.com>
---
dlls/ntdll/virtual.c | 25 +++++++++++++++++++++----
dlls/ntdll/unix/virtual.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index b329a9024d8..e68ca274ca4 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1070,8 +1070,9 @@ static BOOL VIRTUAL_SetProt( struct file_view *view, /* [in] Pointer to view */
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 9a576de4930..e824b9ced25 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1529,8 +1529,9 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr
return TRUE;
}
@@ -31,14 +31,14 @@ index b329a9024d8..e68ca274ca4 100644
unix_prot |= PROT_WRITE;
if (mprotect_exec( base, size, unix_prot )) /* FIXME: last error */
@@ -2381,10 +2382,26 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack )
@@ -2787,10 +2788,26 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta
set_page_vprot_bits( page, page_size, 0, VPROT_WRITEWATCH );
mprotect_range( page, page_size, 0, 0 );
}
- if (vprot & VPROT_WRITECOPY)
+ if ((vprot & VPROT_WRITECOPY) && (vprot & VPROT_COMMITTED))
{
+ struct file_view *view = VIRTUAL_FindView( page, 0 );
+ struct file_view *view = find_view( page, 0 );
+
set_page_vprot_bits( page, page_size, VPROT_WRITE | VPROT_WRITTEN, VPROT_WRITECOPY );
- mprotect_range( page, page_size, 0, 0 );
@@ -54,12 +54,12 @@ index b329a9024d8..e68ca274ca4 100644
+
+ /* original mapping is shared, replace with a private page */
+ memcpy( temp_page, page, page_size );
+ wine_anon_mmap( page, page_size, VIRTUAL_GetUnixProt(vprot | VPROT_WRITE | VPROT_WRITTEN), MAP_FIXED );
+ wine_anon_mmap( page, page_size, get_unix_prot( vprot | VPROT_WRITE | VPROT_WRITTEN ), MAP_FIXED );
+ memcpy( page, temp_page, page_size );
+ }
}
/* ignore fault if page is writable now */
if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS;
if (get_unix_prot( get_page_vprot( page ) ) & PROT_WRITE) ret = STATUS_SUCCESS;
--
2.26.2