From: Paul Gofman pgofman@codeweavers.com
Based on a patch by Nikolay Sivov. --- dlls/kernelbase/memory.c | 2 ++ dlls/kernelbase/tests/process.c | 2 +- dlls/ntdll/tests/virtual.c | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c index 4188eebf181..19381e00b31 100644 --- a/dlls/kernelbase/memory.c +++ b/dlls/kernelbase/memory.c @@ -265,6 +265,8 @@ LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFile3( HANDLE handle, HANDLE process, P LARGE_INTEGER off; void *addr;
+ if (!process) process = GetCurrentProcess(); + addr = baseaddr; off.QuadPart = offset; if (!set_ntstatus( NtMapViewOfSectionEx( handle, process, &addr, &off, &size, alloc_type, protection, diff --git a/dlls/kernelbase/tests/process.c b/dlls/kernelbase/tests/process.c index 2979af39551..14eed7d8fe9 100644 --- a/dlls/kernelbase/tests/process.c +++ b/dlls/kernelbase/tests/process.c @@ -123,7 +123,7 @@ static void test_MapViewOfFile3(void) ok( mapping != 0, "CreateFileMapping error %lu\n", GetLastError() );
SetLastError(0xdeadbeef); - ptr = pMapViewOfFile3( mapping, GetCurrentProcess(), NULL, 0, 4096, 0, PAGE_READONLY, NULL, 0); + ptr = pMapViewOfFile3( mapping, NULL, NULL, 0, 4096, 0, PAGE_READONLY, NULL, 0); ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() ); UnmapViewOfFile( ptr );
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 5dd53c55f54..2c8b1614b84 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -1146,6 +1146,12 @@ static void test_NtMapViewOfSection(void) process = create_target_process("sleep"); ok(process != NULL, "Can't start process\n");
+ ptr = NULL; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, NULL, &ptr, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_INVALID_HANDLE, "NtMapViewOfSection returned %08lx\n", status); + ptr = NULL; size = 0; offset.QuadPart = 0; @@ -1419,6 +1425,12 @@ static void test_NtMapViewOfSectionEx(void) process = create_target_process("sleep"); ok(process != NULL, "Can't start process\n");
+ ptr = NULL; + size = 0x1000; + offset.QuadPart = 0; + status = pNtMapViewOfSectionEx(mapping, NULL, &ptr, &offset, &size, 0, PAGE_READWRITE, NULL, 0); + ok(status == STATUS_INVALID_HANDLE, "Unexpected status %08lx\n", status); + ptr = NULL; size = 0x1000; offset.QuadPart = 0;