wine-staging/patches/kernel32-VirtualProtect/0001-kernel32-Allow-to-pass-NULL-as-old-protection-in-Vir.patch

34 lines
1.2 KiB
Diff

From d14a5ed33cdc95ff03c64f6fa574d07da5515825 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 6 Feb 2016 21:23:10 +0100
Subject: kernel32: Allow to pass NULL as old protection in VirtualProtect for
Win9X.
---
dlls/kernel32/virtual.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/virtual.c b/dlls/kernel32/virtual.c
index 03ef38c..e164151 100644
--- a/dlls/kernel32/virtual.c
+++ b/dlls/kernel32/virtual.c
@@ -235,7 +235,14 @@ BOOL WINAPI VirtualProtect( LPVOID addr, SIZE_T size, DWORD new_prot, LPDWORD ol
BOOL WINAPI VirtualProtectEx( HANDLE process, LPVOID addr, SIZE_T size,
DWORD new_prot, LPDWORD old_prot )
{
- NTSTATUS status = NtProtectVirtualMemory( process, &addr, &size, new_prot, old_prot );
+ NTSTATUS status;
+ DWORD dummy;
+
+ /* Win9x allows to pass NULL as old_prot while it fails on NT */
+ if (!old_prot && (GetVersion() & 0x80000000))
+ old_prot = &dummy;
+
+ status = NtProtectVirtualMemory( process, &addr, &size, new_prot, old_prot );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}
--
2.7.0