Commit 94872cc8 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Fix access rights checks for mapping objects.

parent fcd7d440
......@@ -3710,16 +3710,16 @@ static DWORD map_prot_to_access(DWORD prot)
switch (prot)
{
case PAGE_READWRITE:
return SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE | SECTION_QUERY;
return SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_QUERY;
case PAGE_EXECUTE_READWRITE:
return SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE | SECTION_MAP_EXECUTE_EXPLICIT | SECTION_QUERY;
return SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE | SECTION_QUERY;
case PAGE_READONLY:
case PAGE_WRITECOPY:
return SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_QUERY;
return SECTION_MAP_READ | SECTION_QUERY;
case PAGE_EXECUTE:
case PAGE_EXECUTE_READ:
case PAGE_EXECUTE_WRITECOPY:
return SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_MAP_EXECUTE_EXPLICIT | SECTION_QUERY;
return SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_QUERY;
default:
return 0;
}
......@@ -3909,17 +3909,11 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
/* FILE_MAP_EXECUTE | FILE_MAP_COPY broken on XP */
if (base != NULL && view[j].access == (FILE_MAP_EXECUTE | FILE_MAP_COPY))
{
todo_wine
ok( broken(base != NULL), "%d: MapViewOfFile(%04x/%04x) should fail\n",
j, page_prot[i], view[j].access);
UnmapViewOfFile( base );
}
else todo_wine_if ((page_prot[i] == PAGE_READONLY &&
is_compatible_access( PAGE_EXECUTE_READ, view[j].access )) ||
(page_prot[i] == PAGE_READWRITE &&
is_compatible_access( PAGE_EXECUTE_READWRITE, view[j].access )) ||
(page_prot[i] == PAGE_WRITECOPY &&
is_compatible_access( PAGE_EXECUTE_WRITECOPY, view[j].access )))
else
{
ok(!base, "%d: MapViewOfFile(%04x/%04x) should fail\n",
j, page_prot[i], view[j].access);
......
......@@ -1842,7 +1842,8 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
TRACE("Trying native dll %s\n", debugstr_w(name));
size.QuadPart = 0;
status = NtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ,
status = NtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
SECTION_MAP_READ | SECTION_MAP_EXECUTE,
NULL, &size, PAGE_EXECUTE_READ, SEC_IMAGE, file );
if (status != STATUS_SUCCESS) return status;
......
......@@ -2750,18 +2750,20 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
switch(protect)
{
case PAGE_NOACCESS:
case PAGE_READONLY:
case PAGE_WRITECOPY:
access = SECTION_MAP_READ;
break;
case PAGE_READWRITE:
case PAGE_EXECUTE_READWRITE:
access = SECTION_MAP_WRITE;
break;
case PAGE_READONLY:
case PAGE_WRITECOPY:
case PAGE_EXECUTE:
case PAGE_EXECUTE_READ:
case PAGE_EXECUTE_WRITECOPY:
access = SECTION_MAP_READ;
access = SECTION_MAP_READ | SECTION_MAP_EXECUTE;
break;
case PAGE_EXECUTE_READWRITE:
access = SECTION_MAP_WRITE | SECTION_MAP_EXECUTE;
break;
default:
return STATUS_INVALID_PAGE_PROTECTION;
......
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