Added patch to allow to pass NULL as old protection in VirtualProtect for Win9X.

This commit is contained in:
Sebastian Lackner 2016-02-06 21:40:54 +01:00
parent 6d4294d7e5
commit 9c77e0bb82
3 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,33 @@
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

View File

@ -0,0 +1 @@
Fixes: Allow to pass NULL as old protection in VirtualProtect for Win9X

View File

@ -173,6 +173,7 @@ patch_enable_all ()
enable_kernel32_SetFileInformationByHandle="$1"
enable_kernel32_TimezoneInformation_Registry="$1"
enable_kernel32_VerifyVersionInfo="$1"
enable_kernel32_VirtualProtect="$1"
enable_libs_Debug_Channel="$1"
enable_libs_Unicode_Collation="$1"
enable_makedep_PARENTSPEC="$1"
@ -663,6 +664,9 @@ patch_enable ()
kernel32-VerifyVersionInfo)
enable_kernel32_VerifyVersionInfo="$2"
;;
kernel32-VirtualProtect)
enable_kernel32_VirtualProtect="$2"
;;
libs-Debug_Channel)
enable_libs_Debug_Channel="$2"
;;
@ -4141,6 +4145,18 @@ if test "$enable_kernel32_VerifyVersionInfo" -eq 1; then
) >> "$patchlist"
fi
# Patchset kernel32-VirtualProtect
# |
# | Modified files:
# | * dlls/kernel32/virtual.c
# |
if test "$enable_kernel32_VirtualProtect" -eq 1; then
patch_apply kernel32-VirtualProtect/0001-kernel32-Allow-to-pass-NULL-as-old-protection-in-Vir.patch
(
echo '+ { "Michael Müller", "kernel32: Allow to pass NULL as old protection in VirtualProtect for Win9X.", 1 },';
) >> "$patchlist"
fi
# Patchset libs-Debug_Channel
# |
# | Modified files: