From 3d29cd7c6feabae6c5ae5941f49c663b1fb78ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 4 Oct 2014 03:22:09 +0200 Subject: ntdll: Only enable true WRITECOPY protection when a special environment variable is set. --- dlls/ntdll/virtual.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 36d8836..0c7ae29 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -166,6 +166,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot ) return buffer; } +/* This might look like a hack, but it actually isn't - the 'experimental' version + * is correct, but it already has revealed a couple of additional Wine bugs, which + * were not triggered before, and there are probably some more. + * To avoid breaking Wine for everyone, the new correct implementation has to be + * manually enabled, until it is tested a bit more. */ +static inline BOOL experimental_WRITECOPY( void ) +{ + static int enabled = -1; + if (enabled == -1) + { + const char *str = getenv("STAGING_WRITECOPY"); + enabled = str && (atoi(str) != 0); + } + return enabled; +} /*********************************************************************** * VIRTUAL_GetUnixProt @@ -181,7 +196,13 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ; if (vprot & VPROT_EXEC) prot |= PROT_EXEC | PROT_READ; #if defined(__i386__) - if (vprot & VPROT_WRITECOPY) prot = (prot & ~PROT_WRITE) | PROT_READ; + if (vprot & VPROT_WRITECOPY) + { + if (experimental_WRITECOPY()) + prot = (prot & ~PROT_WRITE) | PROT_READ; + else + prot |= PROT_WRITE | PROT_READ; + } #else /* FIXME: Architecture needs implementation of signal_init_early. */ if (vprot & VPROT_WRITECOPY) prot |= PROT_WRITE | PROT_READ; -- 2.2.1