diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index d66644b576d..7366ef17384 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -400,7 +400,6 @@ static void test_VirtualAlloc(void) addr2 = NULL; status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 22, &size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); - todo_wine ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status); if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); @@ -1168,7 +1167,6 @@ static void test_NtMapViewOfSection(void) ptr2 = NULL; size = 0; status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 22, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - todo_wine ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status ); if (status == STATUS_SUCCESS) { diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index e826fa03c0c..ee9c8d0195d 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -279,6 +279,7 @@ static inline UINT_PTR get_mask( ULONG zero_bits ) { if (!zero_bits) return 0xffff; /* allocations are aligned to 64K by default */ if (zero_bits < page_shift) zero_bits = page_shift; + if (zero_bits > 21) return 0; return (1 << zero_bits) - 1; } @@ -1885,6 +1886,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_ TRACE("%p %p %08lx %x %08x\n", process, *ret, size, type, protect ); if (!size) return STATUS_INVALID_PARAMETER; + if (!mask) return STATUS_INVALID_PARAMETER_3; if (process != NtCurrentProcess()) { @@ -2550,7 +2552,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p /* Check parameters */ - if (*addr_ptr && zero_bits) + if ((*addr_ptr && zero_bits) || !mask) return STATUS_INVALID_PARAMETER_4; #ifndef _WIN64