From 7121526c1273da06ea3c20246abe32334b39817e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20M=C3=BCller?= Date: Tue, 16 Feb 2016 06:53:14 +0100 Subject: [PATCH] kernel32: Allow to pass NULL as old protection in VirtualProtect for Win9x compatibility. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Müller Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard (cherry picked from commit 8eb893f185414278dc45b238349c2e87a73381c5) Signed-off-by: Michael Stefaniuc --- dlls/kernel32/virtual.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/kernel32/virtual.c b/dlls/kernel32/virtual.c index 03ef38cc1c6..4bfc6cc76d9 100644 --- a/dlls/kernel32/virtual.c +++ b/dlls/kernel32/virtual.c @@ -235,7 +235,13 @@ 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 prot; + + /* Win9x allows to pass NULL as old_prot while it fails on NT */ + if (!old_prot && (GetVersion() & 0x80000000)) old_prot = &prot; + + status = NtProtectVirtualMemory( process, &addr, &size, new_prot, old_prot ); if (status) SetLastError( RtlNtStatusToDosError(status) ); return !status; } -- 2.11.4.GIT