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