ntdll: Implement support for AT_ROUND_TO_PAGE flag in NtMapViewOfSection.

This commit is contained in:
Sebastian Lackner 2015-06-26 07:46:43 +02:00 committed by Alexandre Julliard
parent 7a8470ea94
commit d082ea3eab
2 changed files with 8 additions and 8 deletions

View file

@ -1129,7 +1129,6 @@ static void test_NtMapViewOfSection(void)
offset.QuadPart = 0;
status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset,
&size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE );
todo_wine
ok( status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %x\n", status );
/* in contrary to regular NtMapViewOfSection, only 4kb align is enforced */
@ -1138,12 +1137,10 @@ static void test_NtMapViewOfSection(void)
offset.QuadPart = 0;
status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset,
&size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE );
todo_wine
ok( status == STATUS_SUCCESS, "NtMapViewOfSection returned %x\n", status );
ok( (char *)ptr2 == (char *)ptr + 0x1000,
"expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2 );
status = pNtUnmapViewOfSection( hProcess, ptr2 );
todo_wine
ok( !status, "NtUnmapViewOfSection failed status %x\n", status );
/* the address is rounded down if not on a page boundary */
@ -1152,13 +1149,10 @@ static void test_NtMapViewOfSection(void)
offset.QuadPart = 0;
status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset,
&size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE );
todo_wine
ok( status == STATUS_SUCCESS, "NtMapViewOfSection returned %x\n", status );
todo_wine
ok( (char *)ptr2 == (char *)ptr + 0x1000,
"expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2 );
status = pNtUnmapViewOfSection( hProcess, ptr2 );
todo_wine
ok( !status, "NtUnmapViewOfSection failed status %x\n", status );
ptr2 = (char *)ptr + 0x2000;
@ -1166,12 +1160,10 @@ static void test_NtMapViewOfSection(void)
offset.QuadPart = 0;
status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset,
&size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE );
todo_wine
ok( status == STATUS_SUCCESS, "NtMapViewOfSection returned %x\n", status );
ok( (char *)ptr2 == (char *)ptr + 0x2000,
"expected address %p, got %p\n", (char *)ptr + 0x2000, ptr2 );
status = pNtUnmapViewOfSection( hProcess, ptr2 );
todo_wine
ok( !status, "NtUnmapViewOfSection failed status %x\n", status );
}
else

View file

@ -2604,6 +2604,14 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
if (*addr_ptr && zero_bits)
return STATUS_INVALID_PARAMETER_4;
#ifndef _WIN64
if (!is_wow64 && (alloc_type & AT_ROUND_TO_PAGE))
{
*addr_ptr = ROUND_ADDR( *addr_ptr, page_mask );
mask = page_mask;
}
#endif
if ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask)))
return STATUS_MAPPED_ALIGNMENT;