Commit 8eb893f1 authored by Michael Müller's avatar Michael Müller Committed by Alexandre Julliard

kernel32: Allow to pass NULL as old protection in VirtualProtect for Win9x compatibility.

parent b5f210dd
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment