Staging WRITECOPY fix

DodoGTA GT <[email protected]>
Newsgroups gmane.comp.emulators.wine.devel
Message-ID <CAKNqjs1O0TjteKKSAmqTnRr0KbYBA4xB4yVoVpm_BjO3ZrWFzA@mail.gmail.com>
Hello,

I finally managed to submit a regression fix for the ntdll-WRITECOPY
patchset (it's a normal Wine patch so there should be no diff
confusion this time)

Hopefully this can be merged soon because it fixes annoying segfaults
in 3 apps (2 of these have a bug report)

Thanks
0001-STAGING-kernelbase-Handle-NULL-old_prot-parameter-in.patch (text/x-patch, 1.1 KB)
From 5689e8eb607877762b7262abdc79b69b857c9a1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aida=20Jonikien=C4=97?= <[email protected]>
Date: Fri, 26 Jul 2024 20:33:57 +0300
Subject: [PATCH] [STAGING] kernelbase: Handle NULL old_prot parameter in
 VirtualProtect().

This fixes a segfault when launching any game with the EA Desktop application.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56694
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56711
---
 dlls/kernelbase/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c
index 2b0e674bb9b..d1408cf4c0e 100644
--- a/dlls/kernelbase/memory.c
+++ b/dlls/kernelbase/memory.c
@@ -548,7 +548,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH  VirtualLock( void *addr, SIZE_T size )
 BOOL WINAPI DECLSPEC_HOTPATCH VirtualProtect( void *addr, SIZE_T size, DWORD new_prot, DWORD *old_prot )
 {
     BOOL ret = VirtualProtectEx( GetCurrentProcess(), addr, size, new_prot, old_prot );
-    if (*old_prot == PAGE_WRITECOPY) *old_prot = PAGE_READWRITE;
+    if (old_prot && *old_prot == PAGE_WRITECOPY) *old_prot = PAGE_READWRITE;
     return ret;
 }
 
-- 
2.45.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.