* Rename the test function for consistency * Remove unneeded if to release memory where allocation never succeeds * Fix a test where the zero_bits variable was used but not passed as parameter
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 183a097f76a..a5477177ce8 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -32,7 +32,7 @@ static NTSTATUS (WINAPI *pRtlCreateUserStack)(SIZE_T, SIZE_T, ULONG, SIZE_T, SIZ static NTSTATUS (WINAPI *pRtlFreeUserStack)(void *); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
-static void test_AllocateVirtualMemory(void) +static void test_NtAllocateVirtualMemory(void) { void *addr1, *addr2; NTSTATUS status; @@ -60,18 +60,12 @@ static void test_AllocateVirtualMemory(void) status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, 12, &size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08x\n", status); - if (status == STATUS_SUCCESS) - { - size = 0; - status = NtFreeVirtualMemory(NtCurrentProcess(), &addr2, &size, MEM_RELEASE); - ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory return %08x, addr2: %p\n", status, addr2); - }
/* 1 zero bits should zero 63-31 upper bits */ size = 0x1000; addr2 = NULL; zero_bits = 1; - status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, 1, &size, + status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, zero_bits, &size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY || broken(status == STATUS_INVALID_PARAMETER_3) /* winxp */, @@ -250,6 +244,6 @@ START_TEST(virtual) trace("system page size %#x\n", sbi.PageSize); page_size = sbi.PageSize;
- test_AllocateVirtualMemory(); + test_NtAllocateVirtualMemory(); test_RtlCreateUserStack(); }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/kernel32/tests/virtual.c | 67 +++++++++++++++-------------------- 1 file changed, 28 insertions(+), 39 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 0b718606d0e..dc013fa2995 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -73,6 +73,20 @@ static HANDLE create_target_process(const char *arg) return pi.hProcess; }
+static UINT_PTR get_zero_bits(UINT_PTR p) +{ + UINT_PTR z = 0; + +#ifdef __x86_64__ + if (p >= 0xffffffff) + return (~(UINT_PTR)0) >> get_zero_bits(p >> 32); +#endif + + if (p == 0) return 32; + while ((p >> (31 - z)) != 1) z++; + return z; +} + static void test_VirtualAllocEx(void) { const unsigned int alloc_size = 1<<15; @@ -1260,24 +1274,12 @@ static void test_NtMapViewOfSection(void) ok( result == sizeof(buffer), "ReadProcessMemory didn't read all data (%lx)\n", result ); ok( !memcmp( buffer, data, sizeof(buffer) ), "Wrong data read\n" );
- /* for some unknown reason NtMapViewOfSection fails with STATUS_NO_MEMORY when zero_bits != 0 ? */ ptr2 = NULL; size = 0; offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 12, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - todo_wine - ok( status == STATUS_NO_MEMORY, "NtMapViewOfSection returned %x\n", status ); - if (status == STATUS_SUCCESS) - { - status = pNtUnmapViewOfSection( hProcess, ptr2 ); - ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); - } - - ptr2 = NULL; - size = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 16, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - todo_wine - ok( status == STATUS_NO_MEMORY, "NtMapViewOfSection returned %x\n", status ); + status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 1, 0, &offset, &size, 1, 0, PAGE_READWRITE ); + ok( status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, + "NtMapViewOfSection returned %x\n", status ); if (status == STATUS_SUCCESS) { status = pNtUnmapViewOfSection( hProcess, ptr2 ); @@ -1288,12 +1290,8 @@ static void test_NtMapViewOfSection(void) ptr2 = NULL; size = 0; status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 22, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status ); - if (status == STATUS_SUCCESS) - { - status = pNtUnmapViewOfSection( hProcess, ptr2 ); - ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); - } + ok( status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PARAMETER, + "NtMapViewOfSection returned %x\n", status );
/* mapping at the same page conflicts */ ptr2 = ptr; @@ -1323,30 +1321,20 @@ static void test_NtMapViewOfSection(void) status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE ); ok( status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %x\n", status );
- /* zero_bits != 0 is not allowed when an address is set */ + /* when an address is passed, it has to satisfy the provided number of zero bits */ ptr2 = (char *)ptr + 0x1000; size = 0; offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 12, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status ); + status = pNtMapViewOfSection( mapping, hProcess, &ptr2, get_zero_bits(((UINT_PTR)ptr2) >> 1), 0, &offset, &size, 1, 0, PAGE_READWRITE ); + ok( status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PARAMETER, + "NtMapViewOfSection returned %x\n", status );
ptr2 = (char *)ptr + 0x1000; size = 0; offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 16, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status ); - - ptr2 = (char *)ptr + 0x1001; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 16, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status ); - - ptr2 = (char *)ptr + 0x1000; - size = 0; - offset.QuadPart = 1; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 16, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status ); + status = pNtMapViewOfSection( mapping, hProcess, &ptr2, get_zero_bits((UINT_PTR)ptr2), 0, &offset, &size, 1, 0, PAGE_READWRITE ); + todo_wine + ok( status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %x\n", status );
if (sizeof(void *) == sizeof(int) && (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 ) || !is_wow64)) @@ -1409,7 +1397,8 @@ static void test_NtMapViewOfSection(void) status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); todo_wine - ok( status == STATUS_INVALID_PARAMETER_9, "NtMapViewOfSection returned %x\n", status ); + ok( status == STATUS_INVALID_PARAMETER_9 || status == STATUS_INVALID_PARAMETER, + "NtMapViewOfSection returned %x\n", status ); }
status = pNtUnmapViewOfSection( hProcess, ptr );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53949
Your paranoid android.
=== wvistau64 (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_zh_CN (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_fr (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_he (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== w2008s64 (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== w7u (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== w7pro64 (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== w8 (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== w8adm (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== w864 (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== w1064v1507 (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
=== w1064v1809 (32 bit report) ===
kernel32: virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 0, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2839: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2853: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2978: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2996: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3077: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3101: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2783: Test failed: expected policy flags 1, got 3 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:2882: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2945: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2960: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3141: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3166: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2745: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2784: Test failed: expected policy permanent FALSE, got 1 virtual.c:3203: Test failed: NtSetInformationProcess failed with status c0000022
Signed-off-by: Huw Davies huw@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/kernel32/tests/virtual.c | 198 ----------------------------- dlls/ntdll/tests/virtual.c | 227 ++++++++++++++++++++++++++++++++++ 2 files changed, 227 insertions(+), 198 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index dc013fa2995..402ab6b0b58 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -73,20 +73,6 @@ static HANDLE create_target_process(const char *arg) return pi.hProcess; }
-static UINT_PTR get_zero_bits(UINT_PTR p) -{ - UINT_PTR z = 0; - -#ifdef __x86_64__ - if (p >= 0xffffffff) - return (~(UINT_PTR)0) >> get_zero_bits(p >> 32); -#endif - - if (p == 0) return 32; - while ((p >> (31 - z)) != 1) z++; - return z; -} - static void test_VirtualAllocEx(void) { const unsigned int alloc_size = 1<<15; @@ -1228,189 +1214,6 @@ static void test_MapViewOfFile(void) DeleteFileA(testfile); }
-static void test_NtMapViewOfSection(void) -{ - HANDLE hProcess; - - static const char testfile[] = "testfile.xxx"; - static const char data[] = "test data for NtMapViewOfSection"; - char buffer[sizeof(data)]; - HANDLE file, mapping; - void *ptr, *ptr2; - BOOL is_wow64, ret; - DWORD status, written; - SIZE_T size, result; - LARGE_INTEGER offset; - - if (!pNtMapViewOfSection || !pNtUnmapViewOfSection) - { - win_skip( "NtMapViewOfSection not available\n" ); - return; - } - - file = CreateFileA( testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 ); - ok( file != INVALID_HANDLE_VALUE, "Failed to create test file\n" ); - WriteFile( file, data, sizeof(data), &written, NULL ); - SetFilePointer( file, 4096, NULL, FILE_BEGIN ); - SetEndOfFile( file ); - - /* read/write mapping */ - - mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL ); - ok( mapping != 0, "CreateFileMapping failed\n" ); - - hProcess = create_target_process("sleep"); - ok(hProcess != NULL, "Can't start process\n"); - - ptr = NULL; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( !status, "NtMapViewOfSection failed status %x\n", status ); - ok( !((ULONG_PTR)ptr & 0xffff), "returned memory %p is not aligned to 64k\n", ptr ); - - ret = ReadProcessMemory( hProcess, ptr, buffer, sizeof(buffer), &result ); - ok( ret, "ReadProcessMemory failed\n" ); - ok( result == sizeof(buffer), "ReadProcessMemory didn't read all data (%lx)\n", result ); - ok( !memcmp( buffer, data, sizeof(buffer) ), "Wrong data read\n" ); - - ptr2 = NULL; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 1, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, - "NtMapViewOfSection returned %x\n", status ); - if (status == STATUS_SUCCESS) - { - status = pNtUnmapViewOfSection( hProcess, ptr2 ); - ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); - } - - /* 22 zero bits isn't acceptable */ - ptr2 = NULL; - size = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 22, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PARAMETER, - "NtMapViewOfSection returned %x\n", status ); - - /* mapping at the same page conflicts */ - ptr2 = ptr; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %x\n", status ); - - /* offset has to be aligned */ - ptr2 = ptr; - size = 0; - offset.QuadPart = 1; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %x\n", status ); - - /* ptr has to be aligned */ - ptr2 = (char *)ptr + 42; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %x\n", status ); - - /* still not 64k aligned */ - ptr2 = (char *)ptr + 0x1000; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %x\n", status ); - - /* when an address is passed, it has to satisfy the provided number of zero bits */ - ptr2 = (char *)ptr + 0x1000; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, get_zero_bits(((UINT_PTR)ptr2) >> 1), 0, &offset, &size, 1, 0, PAGE_READWRITE ); - ok( status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PARAMETER, - "NtMapViewOfSection returned %x\n", status ); - - ptr2 = (char *)ptr + 0x1000; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, get_zero_bits((UINT_PTR)ptr2), 0, &offset, &size, 1, 0, PAGE_READWRITE ); - todo_wine - ok( status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %x\n", status ); - - if (sizeof(void *) == sizeof(int) && (!pIsWow64Process || - !pIsWow64Process( GetCurrentProcess(), &is_wow64 ) || !is_wow64)) - { - /* new memory region conflicts with previous mapping */ - ptr2 = ptr; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, - &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); - ok( status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %x\n", status ); - - ptr2 = (char *)ptr + 42; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, - &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); - ok( status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %x\n", status ); - - /* in contrary to regular NtMapViewOfSection, only 4kb align is enforced */ - ptr2 = (char *)ptr + 0x1000; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, - &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); - 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 ); - ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); - - /* the address is rounded down if not on a page boundary */ - ptr2 = (char *)ptr + 0x1001; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, - &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); - 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 ); - ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); - - ptr2 = (char *)ptr + 0x2000; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, - &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); - 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 ); - ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); - } - else - { - ptr2 = (char *)ptr + 0x1000; - size = 0; - offset.QuadPart = 0; - status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, - &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); - todo_wine - ok( status == STATUS_INVALID_PARAMETER_9 || status == STATUS_INVALID_PARAMETER, - "NtMapViewOfSection returned %x\n", status ); - } - - status = pNtUnmapViewOfSection( hProcess, ptr ); - ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); - - CloseHandle( mapping ); - CloseHandle( file ); - DeleteFileA( testfile ); - - TerminateProcess(hProcess, 0); - CloseHandle(hProcess); -}
static void test_NtAreMappedFilesTheSame(void) { @@ -4395,7 +4198,6 @@ START_TEST(virtual) test_VirtualAllocEx(); test_VirtualAlloc(); test_MapViewOfFile(); - test_NtMapViewOfSection(); test_NtAreMappedFilesTheSame(); test_CreateFileMapping(); test_IsBadReadPtr(); diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index a5477177ce8..5ca73435541 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -32,6 +32,38 @@ static NTSTATUS (WINAPI *pRtlCreateUserStack)(SIZE_T, SIZE_T, ULONG, SIZE_T, SIZ static NTSTATUS (WINAPI *pRtlFreeUserStack)(void *); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
+static HANDLE create_target_process(const char *arg) +{ + char **argv; + char cmdline[MAX_PATH]; + PROCESS_INFORMATION pi; + BOOL ret; + STARTUPINFOA si = { 0 }; + si.cb = sizeof(si); + + winetest_get_mainargs(&argv); + sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg); + ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); + ok(ret, "error: %u\n", GetLastError()); + ret = CloseHandle(pi.hThread); + ok(ret, "error %u\n", GetLastError()); + return pi.hProcess; +} + +static UINT_PTR get_zero_bits(UINT_PTR p) +{ + UINT_PTR z = 0; + +#ifdef __x86_64__ + if (p >= 0xffffffff) + return (~(UINT_PTR)0) >> get_zero_bits(p >> 32); +#endif + + if (p == 0) return 32; + while ((p >> (31 - z)) != 1) z++; + return z; +} + static void test_NtAllocateVirtualMemory(void) { void *addr1, *addr2; @@ -228,11 +260,205 @@ static void test_RtlCreateUserStack(void) ok(ret == STATUS_INVALID_PARAMETER, "got %#x\n", ret); }
+static void test_NtMapViewOfSection(void) +{ + static const char testfile[] = "testfile.xxx"; + static const char data[] = "test data for NtMapViewOfSection"; + char buffer[sizeof(data)]; + HANDLE file, mapping, process; + void *ptr, *ptr2; + BOOL is_wow64, ret; + DWORD status, written; + SIZE_T size, result; + LARGE_INTEGER offset; + ULONG zero_bits; + + file = CreateFileA(testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "Failed to create test file\n"); + WriteFile(file, data, sizeof(data), &written, NULL); + SetFilePointer(file, 4096, NULL, FILE_BEGIN); + SetEndOfFile(file); + + /* read/write mapping */ + + mapping = CreateFileMappingA(file, NULL, PAGE_READWRITE, 0, 4096, NULL); + ok(mapping != 0, "CreateFileMapping failed\n"); + + process = create_target_process("sleep"); + ok(process != NULL, "Can't start process\n"); + + 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 %08x\n", status); + ok(!((ULONG_PTR)ptr & 0xffff), "returned memory %p is not aligned to 64k\n", ptr); + + ret = ReadProcessMemory(process, ptr, buffer, sizeof(buffer), &result); + ok(ret, "ReadProcessMemory failed\n"); + ok(result == sizeof(buffer), "ReadProcessMemory didn't read all data (%lx)\n", result); + ok(!memcmp(buffer, data, sizeof(buffer)), "Wrong data read\n"); + + ptr2 = NULL; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 1, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, + "NtMapViewOfSection returned %08x\n", status); + if (status == STATUS_SUCCESS) + { + status = NtUnmapViewOfSection(process, ptr2); + ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status); + } + + /* 22 zero bits isn't acceptable */ + ptr2 = NULL; + size = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 22, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PARAMETER, + "NtMapViewOfSection returned %08x\n", status); + + /* mapping at the same page conflicts */ + ptr2 = ptr; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %08x\n", status); + + /* offset has to be aligned */ + ptr2 = ptr; + size = 0; + offset.QuadPart = 1; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08x\n", status); + + /* ptr has to be aligned */ + ptr2 = (char *)ptr + 42; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08x\n", status); + + /* still not 64k aligned */ + ptr2 = (char *)ptr + 0x1000; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08x\n", status); + + /* when an address is passed, it has to satisfy the provided number of zero bits */ + ptr2 = (char *)ptr + 0x1000; + size = 0; + offset.QuadPart = 0; + zero_bits = get_zero_bits(((UINT_PTR)ptr2) >> 1); + status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PARAMETER, + "NtMapViewOfSection returned %08x\n", status); + + ptr2 = (char *)ptr + 0x1000; + size = 0; + offset.QuadPart = 0; + zero_bits = get_zero_bits((UINT_PTR)ptr2); + status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); + todo_wine + ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08x\n", status); + + if (sizeof(void *) == sizeof(int) && (!pIsWow64Process || + !pIsWow64Process(NtCurrentProcess(), &is_wow64) || !is_wow64)) + { + /* new memory region conflicts with previous mapping */ + ptr2 = ptr; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, + &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE); + ok(status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %08x\n", status); + + ptr2 = (char *)ptr + 42; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, + &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE); + ok(status == STATUS_CONFLICTING_ADDRESSES, "NtMapViewOfSection returned %08x\n", status); + + /* in contrary to regular NtMapViewOfSection, only 4kb align is enforced */ + ptr2 = (char *)ptr + 0x1000; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, + &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE); + ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned %08x\n", status); + ok((char *)ptr2 == (char *)ptr + 0x1000, + "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2); + status = NtUnmapViewOfSection(process, ptr2); + ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status); + + /* the address is rounded down if not on a page boundary */ + ptr2 = (char *)ptr + 0x1001; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, + &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE); + ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned %08x\n", status); + ok((char *)ptr2 == (char *)ptr + 0x1000, + "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2); + status = NtUnmapViewOfSection(process, ptr2); + ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status); + + ptr2 = (char *)ptr + 0x2000; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, + &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE); + ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned %08x\n", status); + ok((char *)ptr2 == (char *)ptr + 0x2000, + "expected address %p, got %p\n", (char *)ptr + 0x2000, ptr2); + status = NtUnmapViewOfSection(process, ptr2); + ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status); + } + else + { + ptr2 = (char *)ptr + 0x1000; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 0, 0, &offset, + &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE); + todo_wine + ok(status == STATUS_INVALID_PARAMETER_9 || status == STATUS_INVALID_PARAMETER, + "NtMapViewOfSection returned %08x\n", status); + } + + status = NtUnmapViewOfSection(process, ptr); + ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status); + + NtClose(mapping); + + CloseHandle(file); + DeleteFileA(testfile); + + TerminateProcess(process, 0); + CloseHandle(process); +} + START_TEST(virtual) { SYSTEM_BASIC_INFORMATION sbi; HMODULE mod;
+ int argc; + char **argv; + argc = winetest_get_mainargs(&argv); + + if (argc >= 3) + { + if (!strcmp(argv[2], "sleep")) + { + Sleep(5000); /* spawned process runs for at most 5 seconds */ + return; + } + return; + } + mod = GetModuleHandleA("kernel32.dll"); pIsWow64Process = (void *)GetProcAddress(mod, "IsWow64Process");
@@ -246,4 +472,5 @@ START_TEST(virtual)
test_NtAllocateVirtualMemory(); test_RtlCreateUserStack(); + test_NtMapViewOfSection(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53950
Your paranoid android.
=== wvistau64 (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_zh_CN (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_fr (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_he (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== w2008s64 (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== w7u (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== w7pro64 (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== w8 (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== w8adm (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== w864 (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== w1064v1507 (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
=== w1064v1809 (32 bit report) ===
kernel32: virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 0, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2642: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2656: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2781: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2799: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2880: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2904: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2586: Test failed: expected policy flags 1, got 3 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:2685: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2700: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2748: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2763: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2944: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2969: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2548: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2587: Test failed: expected policy permanent FALSE, got 1 virtual.c:3006: Test failed: NtSetInformationProcess failed with status c0000022
Signed-off-by: Huw Davies huw@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 67 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 5ca73435541..7ea4d436e14 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -299,25 +299,88 @@ static void test_NtMapViewOfSection(void) ok(result == sizeof(buffer), "ReadProcessMemory didn't read all data (%lx)\n", result); ok(!memcmp(buffer, data, sizeof(buffer)), "Wrong data read\n");
+ /* 1 zero bits should zero 63-31 upper bits */ ptr2 = NULL; size = 0; + zero_bits = 1; offset.QuadPart = 0; - status = NtMapViewOfSection(mapping, process, &ptr2, 1, 0, &offset, &size, 1, 0, PAGE_READWRITE); + status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, "NtMapViewOfSection returned %08x\n", status); if (status == STATUS_SUCCESS) { + todo_wine_if((UINT_PTR)ptr2 >> (32 - zero_bits)) + ok(((UINT_PTR)ptr2 >> (32 - zero_bits)) == 0, + "NtMapViewOfSection returned address: %p\n", ptr2); + status = NtUnmapViewOfSection(process, ptr2); ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status); }
- /* 22 zero bits isn't acceptable */ + for (zero_bits = 2; zero_bits <= 20; zero_bits++) + { + ptr2 = NULL; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, + "NtMapViewOfSection with %d zero_bits returned %08x\n", zero_bits, status); + if (status == STATUS_SUCCESS) + { + todo_wine_if((UINT_PTR)ptr2 >> (32 - zero_bits)) + ok(((UINT_PTR)ptr2 >> (32 - zero_bits)) == 0, + "NtMapViewOfSection with %d zero_bits returned address %p\n", zero_bits, ptr2); + + status = NtUnmapViewOfSection(process, ptr2); + ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status); + } + } + + /* 21 zero bits never succeeds */ + ptr2 = NULL; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 21, 0, &offset, &size, 1, 0, PAGE_READWRITE); + todo_wine + ok(status == STATUS_NO_MEMORY || status == STATUS_INVALID_PARAMETER, + "NtMapViewOfSection returned %08x\n", status); + + /* 22 zero bits is invalid */ ptr2 = NULL; size = 0; + offset.QuadPart = 0; status = NtMapViewOfSection(mapping, process, &ptr2, 22, 0, &offset, &size, 1, 0, PAGE_READWRITE); ok(status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PARAMETER, "NtMapViewOfSection returned %08x\n", status);
+ /* zero bits > 31 should be considered as bitmask on 64bit and WoW64 */ + ptr2 = NULL; + size = 0; + zero_bits = 0x1fffffff; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); + + if (sizeof(void *) == sizeof(int) && (!pIsWow64Process || + !pIsWow64Process(NtCurrentProcess(), &is_wow64) || !is_wow64)) + { + ok(status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %08x\n", status); + } + else + { + todo_wine + ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, + "NtMapViewOfSection returned %08x\n", status); + if (status == STATUS_SUCCESS) + { + todo_wine_if((UINT_PTR)ptr2 & ~zero_bits) + ok(((UINT_PTR)ptr2 & ~zero_bits) == 0, + "NtMapViewOfSection returned address %p\n", ptr2); + + status = NtUnmapViewOfSection(process, ptr2); + ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection returned %08x\n", status); + } + } + /* mapping at the same page conflicts */ ptr2 = ptr; size = 0;
Signed-off-by: Huw Davies huw@codeweavers.com
See 00451d5edf9a13fd8f414a0d06869e38cf66b754
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 2 -- dlls/ntdll/virtual.c | 42 +++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 7ea4d436e14..ba1b6436525 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -367,7 +367,6 @@ static void test_NtMapViewOfSection(void) } else { - todo_wine ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, "NtMapViewOfSection returned %08x\n", status); if (status == STATUS_SUCCESS) @@ -423,7 +422,6 @@ static void test_NtMapViewOfSection(void) offset.QuadPart = 0; zero_bits = get_zero_bits((UINT_PTR)ptr2); status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); - todo_wine ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08x\n", status);
if (sizeof(void *) == sizeof(int) && (!pIsWow64Process || diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 5c12d87d297..380c638b208 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -409,12 +409,12 @@ static struct file_view *VIRTUAL_FindView( const void *addr, size_t size ) /*********************************************************************** * get_mask */ -static inline UINT_PTR get_mask( ULONG zero_bits ) +static inline UINT_PTR get_mask( ULONG alignment ) { - 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; + if (!alignment) return 0xffff; /* allocations are aligned to 64K by default */ + if (alignment < page_shift) alignment = page_shift; + if (alignment > 21) return 0; + return (1 << alignment) - 1; }
@@ -1360,7 +1360,7 @@ static NTSTATUS map_pe_header( void *ptr, size_t size, int fd, BOOL *removable ) * * Map an executable (PE format) image into memory. */ -static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T mask, +static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T zero_bits, pe_image_info_t *image_info, int shared_fd, BOOL removable, PVOID *addr_ptr ) { IMAGE_DOS_HEADER *dos; @@ -1390,12 +1390,12 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T m server_enter_uninterrupted_section( &csVirtual, &sigset );
if (base >= (char *)address_space_start) /* make sure the DOS area remains free */ - status = map_view( &view, base, total_size, mask, FALSE, SEC_IMAGE | SEC_FILE | - VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, 0 ); + status = map_view( &view, base, total_size, get_mask( 0 ), FALSE, SEC_IMAGE | SEC_FILE | + VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, zero_bits );
if (status != STATUS_SUCCESS) - status = map_view( &view, NULL, total_size, mask, FALSE, SEC_IMAGE | SEC_FILE | - VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, 0 ); + status = map_view( &view, NULL, total_size, get_mask( 0 ), FALSE, SEC_IMAGE | SEC_FILE | + VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, zero_bits );
if (status != STATUS_SUCCESS) goto error;
@@ -1617,7 +1617,7 @@ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, S NTSTATUS res; mem_size_t full_size; ACCESS_MASK access; - SIZE_T size, mask = get_mask( zero_bits ); + SIZE_T size; int unix_handle = -1, needs_close; unsigned int vprot, sec_flags; struct file_view *view; @@ -1672,14 +1672,15 @@ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, S
if ((res = server_get_unix_fd( shared_file, FILE_READ_DATA|FILE_WRITE_DATA, &shared_fd, &shared_needs_close, NULL, NULL ))) goto done; - res = map_image( handle, access, unix_handle, mask, image_info, + res = map_image( handle, access, unix_handle, zero_bits, image_info, shared_fd, needs_close, addr_ptr ); if (shared_needs_close) close( shared_fd ); close_handle( shared_file ); } else { - res = map_image( handle, access, unix_handle, mask, image_info, -1, needs_close, addr_ptr ); + res = map_image( handle, access, unix_handle, zero_bits, image_info, + -1, needs_close, addr_ptr ); } if (needs_close) close( unix_handle ); if (res >= 0) *size_ptr = image_info->map_size; @@ -1716,7 +1717,7 @@ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, S get_vprot_flags( protect, &vprot, sec_flags & SEC_IMAGE ); vprot |= sec_flags; if (!(sec_flags & SEC_RESERVE)) vprot |= VPROT_COMMITTED; - res = map_view( &view, *addr_ptr, size, mask, FALSE, vprot, 0 ); + res = map_view( &view, *addr_ptr, size, get_mask( 0 ), FALSE, vprot, zero_bits ); if (res) { server_leave_uninterrupted_section( &csVirtual, &sigset ); @@ -3136,7 +3137,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p SECTION_INHERIT inherit, ULONG alloc_type, ULONG protect ) { NTSTATUS res; - SIZE_T mask = get_mask( zero_bits ); + SIZE_T mask = get_mask( 0 ); pe_image_info_t image_info; LARGE_INTEGER offset;
@@ -3146,8 +3147,17 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p handle, process, *addr_ptr, offset.u.HighPart, offset.u.LowPart, *size_ptr, protect );
/* Check parameters */ + if (zero_bits > 21 && zero_bits < 32) + return STATUS_INVALID_PARAMETER_4; + if (!is_win64 && !is_wow64 && zero_bits >= 32) + return STATUS_INVALID_PARAMETER_4;
- if ((*addr_ptr && zero_bits) || !mask) + /* If both addr_ptr and zero_bits are passed, they have match */ + if (*addr_ptr && zero_bits && zero_bits < 32 && + (((UINT_PTR)*addr_ptr) >> (32 - zero_bits))) + return STATUS_INVALID_PARAMETER_4; + if (*addr_ptr && zero_bits >= 32 && + (((UINT_PTR)*addr_ptr) & ~zero_bits)) return STATUS_INVALID_PARAMETER_4;
#ifndef _WIN64
Signed-off-by: Huw Davies huw@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/virtual.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 380c638b208..6196a4e3ee1 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1082,11 +1082,12 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot ) * Create a view and mmap the corresponding memory area. * The csVirtual section must be held by caller. */ -static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, size_t mask, +static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, size_t alignment, int top_down, unsigned int vprot, size_t zero_bits ) { void *ptr; NTSTATUS status; + size_t mask = get_mask( alignment );
if (base) { @@ -1287,7 +1288,7 @@ static NTSTATUS allocate_dos_memory( struct file_view **view, unsigned int vprot if (addr != low_64k) { if (addr != (void *)-1) munmap( addr, dosmem_size - 0x10000 ); - return map_view( view, NULL, dosmem_size, 0xffff, 0, vprot, 0 ); + return map_view( view, NULL, dosmem_size, 0, FALSE, vprot, 0 ); } }
@@ -1390,11 +1391,11 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T z server_enter_uninterrupted_section( &csVirtual, &sigset );
if (base >= (char *)address_space_start) /* make sure the DOS area remains free */ - status = map_view( &view, base, total_size, get_mask( 0 ), FALSE, SEC_IMAGE | SEC_FILE | + status = map_view( &view, base, total_size, 0, FALSE, SEC_IMAGE | SEC_FILE | VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, zero_bits );
if (status != STATUS_SUCCESS) - status = map_view( &view, NULL, total_size, get_mask( 0 ), FALSE, SEC_IMAGE | SEC_FILE | + status = map_view( &view, NULL, total_size, 0, FALSE, SEC_IMAGE | SEC_FILE | VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, zero_bits );
if (status != STATUS_SUCCESS) goto error; @@ -1717,7 +1718,7 @@ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, S get_vprot_flags( protect, &vprot, sec_flags & SEC_IMAGE ); vprot |= sec_flags; if (!(sec_flags & SEC_RESERVE)) vprot |= VPROT_COMMITTED; - res = map_view( &view, *addr_ptr, size, get_mask( 0 ), FALSE, vprot, zero_bits ); + res = map_view( &view, *addr_ptr, size, 0, FALSE, vprot, zero_bits ); if (res) { server_leave_uninterrupted_section( &csVirtual, &sigset ); @@ -1949,7 +1950,7 @@ NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SI
server_enter_uninterrupted_section( &csVirtual, &sigset );
- if ((status = map_view( &view, NULL, size + extra_size, 0xffff, 0, + if ((status = map_view( &view, NULL, size + extra_size, 0, FALSE, VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, 0 )) != STATUS_SUCCESS) goto done;
@@ -2551,7 +2552,6 @@ NTSTATUS virtual_alloc_aligned( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr, void *base; unsigned int vprot; SIZE_T size = *size_ptr; - SIZE_T mask = get_mask( alignment ); NTSTATUS status = STATUS_SUCCESS; BOOL is_dos_memory = FALSE; struct file_view *view; @@ -2564,7 +2564,7 @@ NTSTATUS virtual_alloc_aligned( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr, if (*ret) { if (type & MEM_RESERVE) /* Round down to 64k boundary */ - base = ROUND_ADDR( *ret, mask ); + base = ROUND_ADDR( *ret, get_mask( alignment ) ); else base = ROUND_ADDR( *ret, page_mask ); size = (((UINT_PTR)*ret + size + page_mask) & ~page_mask) - (UINT_PTR)base; @@ -2608,7 +2608,7 @@ NTSTATUS virtual_alloc_aligned( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr,
if (vprot & VPROT_WRITECOPY) status = STATUS_INVALID_PAGE_PROTECTION; else if (is_dos_memory) status = allocate_dos_memory( &view, vprot ); - else status = map_view( &view, base, size, mask, type & MEM_TOP_DOWN, vprot, zero_bits ); + else status = map_view( &view, base, size, alignment, type & MEM_TOP_DOWN, vprot, zero_bits );
if (status == STATUS_SUCCESS) base = view->base; }
Signed-off-by: Huw Davies huw@codeweavers.com