Commit 376bd69c authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ntdll: Handle NULL process handle in MapViewOfFile3().

Based on a patch by Nikolay Sivov.
parent 35b198c5
......@@ -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,
......
......@@ -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 );
......
......@@ -1149,6 +1149,12 @@ static void test_NtMapViewOfSection(void)
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;
status = NtMapViewOfSection(mapping, process, &ptr, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE);
ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned %08lx\n", status);
ok(!((ULONG_PTR)ptr & 0xffff), "returned memory %p is not aligned to 64k\n", ptr);
......@@ -1422,6 +1428,12 @@ static void test_NtMapViewOfSectionEx(void)
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;
status = pNtMapViewOfSectionEx(mapping, process, &ptr, &offset, &size, 0, PAGE_READWRITE, NULL, 0);
ok(status == STATUS_SUCCESS, "Unexpected status %08lx\n", status);
ok(!((ULONG_PTR)ptr & 0xffff), "returned memory %p is not aligned to 64k\n", ptr);
......
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