Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/kernel32/tests/virtual.c | 72 ++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 34 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 0b718606d0e..e72192477c8 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -73,6 +73,30 @@ static HANDLE create_target_process(const char *arg) return pi.hProcess; }
+static inline UINT_PTR get_zero_bits(UINT_PTR p) +{ + UINT_PTR z; + + if (p == 0) + return 32; +#ifdef __x86_64__ + if (p > 0xffffffff) + return (~(UINT_PTR)0) >> get_zero_bits(p >> 32); +#endif + +#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) + z = __builtin_clz((UINT32)p); +#else + z = 31; + if (p >> 16) { z -= 16; p >>= 16; } + if (p >> 8) { z -= 8; p >>= 8; } + if (p >> 4) { z -= 4; p >>= 4; } + if (p >> 2) { z -= 2; p >>= 2; } + if (p >> 1) z -= 1; +#endif + return z; +} + static void test_VirtualAllocEx(void) { const unsigned int alloc_size = 1<<15; @@ -1260,24 +1284,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,7 +1300,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 ); + ok( status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PARAMETER, + "NtMapViewOfSection returned %x\n", status ); if (status == STATUS_SUCCESS) { status = pNtUnmapViewOfSection( hProcess, ptr2 ); @@ -1323,30 +1336,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 +1412,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 );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/kernel32/tests/virtual.c | 213 ------------------------------ dlls/ntdll/tests/virtual.c | 240 ++++++++++++++++++++++++++++++++++ 2 files changed, 240 insertions(+), 213 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index e72192477c8..402ab6b0b58 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -73,30 +73,6 @@ static HANDLE create_target_process(const char *arg) return pi.hProcess; }
-static inline UINT_PTR get_zero_bits(UINT_PTR p) -{ - UINT_PTR z; - - if (p == 0) - return 32; -#ifdef __x86_64__ - if (p > 0xffffffff) - return (~(UINT_PTR)0) >> get_zero_bits(p >> 32); -#endif - -#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) - z = __builtin_clz((UINT32)p); -#else - z = 31; - if (p >> 16) { z -= 16; p >>= 16; } - if (p >> 8) { z -= 8; p >>= 8; } - if (p >> 4) { z -= 4; p >>= 4; } - if (p >> 2) { z -= 2; p >>= 2; } - if (p >> 1) z -= 1; -#endif - return z; -} - static void test_VirtualAllocEx(void) { const unsigned int alloc_size = 1<<15; @@ -1238,194 +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 ); - if (status == STATUS_SUCCESS) - { - status = pNtUnmapViewOfSection( hProcess, ptr2 ); - ok( !status, "NtUnmapViewOfSection failed status %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) { @@ -4410,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 ff10508a604..65b884f55f9 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -28,6 +28,48 @@
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 inline UINT_PTR get_zero_bits(UINT_PTR p) +{ + UINT_PTR z; + + if (p == 0) + return 32; +#ifdef __x86_64__ + if (p > 0xffffffff) + return (~(UINT_PTR)0) >> get_zero_bits(p >> 32); +#endif + +#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) + z = __builtin_clz((UINT32)p); +#else + z = 31; + if (p >> 16) { z -= 16; p >>= 16; } + if (p >> 8) { z -= 8; p >>= 8; } + if (p >> 4) { z -= 4; p >>= 4; } + if (p >> 2) { z -= 2; p >>= 2; } + if (p >> 1) z -= 1; +#endif + return z; +} + static void test_AllocateVirtualMemory(void) { void *addr1, *addr2; @@ -167,6 +209,203 @@ static void test_AllocateVirtualMemory(void) ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory failed\n"); }
+static void test_MapViewOfSection(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"); + + /* for some unknown reason NtMapViewOfSection fails with STATUS_NO_MEMORY when zero_bits != 0 ? */ + ptr2 = NULL; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 12, 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); + } + + ptr2 = NULL; + size = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 16, 0, &offset, &size, 1, 0, PAGE_READWRITE); + todo_wine + ok(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); + if (status == STATUS_SUCCESS) + { + status = NtUnmapViewOfSection(process, ptr2); + ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection 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; @@ -179,4 +418,5 @@ START_TEST(virtual) trace("system page size %#x\n", sbi.PageSize);
test_AllocateVirtualMemory(); + test_MapViewOfSection(); }
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=53837
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 Task: Patch failed to apply
On Tue, Jun 18, 2019 at 06:39:26PM +0200, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/kernel32/tests/virtual.c | 213 ------------------------------ dlls/ntdll/tests/virtual.c | 240 ++++++++++++++++++++++++++++++++++ 2 files changed, 240 insertions(+), 213 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index ff10508a604..65b884f55f9 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -28,6 +28,48 @@
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;
+}
This can't work. You also need the code inside START_TEST(virtual) to parse the command line and actually do the sleeping.
Huw.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 65b884f55f9..852146202b0 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -109,7 +109,7 @@ static void test_AllocateVirtualMemory(void) 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 */,
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=53838
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 Task: Patch failed to apply
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 66 +++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 852146202b0..a0570481bb8 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -248,37 +248,93 @@ static void test_MapViewOfSection(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 ? */ + /* 1 zero bits should zero 63-31 upper bits */ ptr2 = NULL; size = 0; + zero_bits = 1; offset.QuadPart = 0; - status = NtMapViewOfSection(mapping, process, &ptr2, 12, 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); }
+ 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; - status = NtMapViewOfSection(mapping, process, &ptr2, 16, 0, &offset, &size, 1, 0, PAGE_READWRITE); + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 21, 0, &offset, &size, 1, 0, PAGE_READWRITE); todo_wine - ok(status == STATUS_NO_MEMORY, "NtMapViewOfSection returned %08x\n", status); + ok(status == STATUS_NO_MEMORY || status == STATUS_INVALID_PARAMETER, + "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 */ + /* 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;
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=53839
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 Task: Patch failed to apply
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 a0570481bb8..2248a59fb6e 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -321,7 +321,6 @@ static void test_MapViewOfSection(void) } else { - todo_wine ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, "NtMapViewOfSection returned %08x\n", status); if (status == STATUS_SUCCESS) @@ -377,7 +376,6 @@ static void test_MapViewOfSection(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 86377af0a8c..3bd295780c2 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 ); @@ -3098,7 +3099,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;
@@ -3108,8 +3109,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
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=53840
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 Task: Patch failed to apply
Instead of mask, this function takes top_down, zero_bits and alignment (resp. high bits and low bits alignment constraints) parameters.
The map_view function is now just a wrapper around it with default alignment values.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/virtual.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 3bd295780c2..cf3e597ab2f 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1077,16 +1077,17 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot ) }
/*********************************************************************** - * map_view + * map_view_aligned * * 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, - int top_down, unsigned int vprot, size_t zero_bits ) +static NTSTATUS map_view_aligned( struct file_view **view_ret, void *base, size_t size, unsigned int vprot, + int top_down, size_t zero_bits, size_t alignment ) { void *ptr; NTSTATUS status; + size_t mask = get_mask( alignment );
if (base) { @@ -1137,6 +1138,15 @@ done: return status; }
+/*********************************************************************** + * map_view + * + * Same as map_view_aligned but without alignment constraints. + */ +static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, unsigned int vprot ) +{ + return map_view_aligned( view_ret, base, size, vprot, FALSE, 0, 0 ); +}
/*********************************************************************** * map_file_into_view @@ -1287,7 +1297,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, vprot ); } }
@@ -1390,12 +1400,14 @@ 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 | - VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, zero_bits ); + status = map_view_aligned( &view, base, total_size, + SEC_IMAGE | SEC_FILE | VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, + FALSE, zero_bits, 0 );
if (status != STATUS_SUCCESS) - 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 ); + status = map_view_aligned( &view, NULL, total_size, + SEC_IMAGE | SEC_FILE | VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, + FALSE, zero_bits, 0 );
if (status != STATUS_SUCCESS) goto error;
@@ -1717,7 +1729,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_aligned( &view, *addr_ptr, size, vprot, FALSE, zero_bits, 0 ); if (res) { server_leave_uninterrupted_section( &csVirtual, &sigset ); @@ -1949,8 +1961,8 @@ NTSTATUS virtual_alloc_thread_stack( TEB *teb, SIZE_T reserve_size, SIZE_T commi
server_enter_uninterrupted_section( &csVirtual, &sigset );
- if ((status = map_view( &view, NULL, size + extra_size, 0xffff, 0, - VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, 0 )) != STATUS_SUCCESS) + if ((status = map_view( &view, NULL, size + extra_size, + VPROT_READ | VPROT_WRITE | VPROT_COMMITTED )) != STATUS_SUCCESS) goto done;
#ifdef VALGRIND_STACK_REGISTER @@ -2513,7 +2525,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; @@ -2526,7 +2537,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; @@ -2570,7 +2581,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_aligned( &view, base, size, vprot, type & MEM_TOP_DOWN, zero_bits, alignment );
if (status == STATUS_SUCCESS) base = view->base; }
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=53841
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 Task: Patch failed to apply
On Tue, Jun 18, 2019 at 06:39:30PM +0200, Rémi Bernon wrote:
Instead of mask, this function takes top_down, zero_bits and alignment (resp. high bits and low bits alignment constraints) parameters.
The map_view function is now just a wrapper around it with default alignment values.
I don't think having two functions makes things clearer, especially as map_view() itself is now only called twice. Just swap mask for alignment in map_view() and you're done.
To avoid spamming the list too much, could you just resend these first six patches?
Huw.
NtMapViewOfSection also accepts the MEM_TOP_DOWN parameter that can be used in combination with zero_bits to map memory on the highest possible address.
This is useful for the next patches so we can consistently fail zero_bits tests.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/loader.c | 2 +- dlls/ntdll/ntdll_misc.h | 2 +- dlls/ntdll/virtual.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 3f422a9c0be..5e5758f3f8b 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -2134,7 +2134,7 @@ static NTSTATUS open_dll_file( UNICODE_STRING *nt_name, WINE_MODREF **pwm, NtUnmapViewOfSection( NtCurrentProcess(), *module ); *module = NULL; } - status = virtual_map_section( mapping, module, 0, 0, NULL, &len, + status = virtual_map_section( mapping, module, 0, 0, 0, NULL, &len, PAGE_EXECUTE_READ, image_info ); if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS; NtClose( mapping ); diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index f8c377e6010..67393b6ba69 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -170,7 +170,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S /* virtual memory */ extern NTSTATUS virtual_alloc_aligned( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr, ULONG type, ULONG protect, ULONG alignment ) DECLSPEC_HIDDEN; -extern NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, SIZE_T commit_size, +extern NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, int top_down, ULONG zero_bits, SIZE_T commit_size, const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG protect, pe_image_info_t *image_info ) DECLSPEC_HIDDEN; extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index cf3e597ab2f..88ea958ccf5 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1370,7 +1370,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 zero_bits, +static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, int top_down, SIZE_T zero_bits, pe_image_info_t *image_info, int shared_fd, BOOL removable, PVOID *addr_ptr ) { IMAGE_DOS_HEADER *dos; @@ -1402,12 +1402,12 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T z if (base >= (char *)address_space_start) /* make sure the DOS area remains free */ status = map_view_aligned( &view, base, total_size, SEC_IMAGE | SEC_FILE | VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, - FALSE, zero_bits, 0 ); + top_down, zero_bits, 0 );
if (status != STATUS_SUCCESS) status = map_view_aligned( &view, NULL, total_size, SEC_IMAGE | SEC_FILE | VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, - FALSE, zero_bits, 0 ); + top_down, zero_bits, 0 );
if (status != STATUS_SUCCESS) goto error;
@@ -1622,7 +1622,7 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T z * * Map a file section into memory. */ -NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, SIZE_T commit_size, +NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, int top_down, ULONG zero_bits, SIZE_T commit_size, const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG protect, pe_image_info_t *image_info ) { @@ -1684,14 +1684,14 @@ 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, zero_bits, image_info, + res = map_image( handle, access, unix_handle, top_down, 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, zero_bits, image_info, + res = map_image( handle, access, unix_handle, top_down, zero_bits, image_info, -1, needs_close, addr_ptr ); } if (needs_close) close( unix_handle ); @@ -1729,7 +1729,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_aligned( &view, *addr_ptr, size, vprot, FALSE, zero_bits, 0 ); + res = map_view_aligned( &view, *addr_ptr, size, vprot, top_down, zero_bits, 0 ); if (res) { server_leave_uninterrupted_section( &csVirtual, &sigset ); @@ -3170,7 +3170,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p return result.map_view.status; }
- return virtual_map_section( handle, addr_ptr, zero_bits, commit_size, + return virtual_map_section( handle, addr_ptr, alloc_type & MEM_TOP_DOWN, zero_bits, commit_size, offset_ptr, size_ptr, protect, &image_info ); }
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=53842
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 Task: Patch failed to apply
This is in order to use todo_wine_if(is_win64) in next patch.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 2248a59fb6e..6fe4828095e 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -27,6 +27,7 @@ #include "wine/test.h"
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); +static const BOOL is_win64 = sizeof(void*) > sizeof(int);
static HANDLE create_target_process(const char *arg) { @@ -78,6 +79,8 @@ static void test_AllocateVirtualMemory(void) ULONG zero_bits; BOOL is_wow64;
+ if (!pIsWow64Process || !pIsWow64Process(NtCurrentProcess(), &is_wow64)) is_wow64 = FALSE; + /* simple allocation should success */ size = 0x1000; addr1 = NULL; @@ -175,8 +178,7 @@ static void test_AllocateVirtualMemory(void) status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, zero_bits, &size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
- if (sizeof(void *) == sizeof(int) && (!pIsWow64Process || - !pIsWow64Process(NtCurrentProcess(), &is_wow64) || !is_wow64)) + if (!is_win64 && !is_wow64) { ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status); } @@ -222,6 +224,8 @@ static void test_MapViewOfSection(void) LARGE_INTEGER offset; ULONG zero_bits;
+ if (!pIsWow64Process || !pIsWow64Process(NtCurrentProcess(), &is_wow64)) is_wow64 = FALSE; + 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); @@ -314,8 +318,7 @@ static void test_MapViewOfSection(void) 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)) + if (!is_win64 && !is_wow64) { ok(status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %08x\n", status); } @@ -378,8 +381,7 @@ static void test_MapViewOfSection(void) status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); ok(status == STATUS_MAPPED_ALIGNMENT, "NtMapViewOfSection returned %08x\n", status);
- if (sizeof(void *) == sizeof(int) && (!pIsWow64Process || - !pIsWow64Process(NtCurrentProcess(), &is_wow64) || !is_wow64)) + if (!is_win64 && !is_wow64) { /* new memory region conflicts with previous mapping */ ptr2 = 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=53843
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 error: patch failed: dlls/ntdll/tests/virtual.c:27 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 error: patch failed: dlls/ntdll/tests/virtual.c:27 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 error: patch failed: dlls/ntdll/tests/virtual.c:27 Task: Patch failed to apply
The todo_wine_if made the tests not really test anything, and one test was succeeding when it shouldn't. Now we can actually remove the todo when 1 zero_bits handling is implemented.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 6fe4828095e..c892e4aa4e0 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -113,12 +113,14 @@ static void test_AllocateVirtualMemory(void) addr2 = NULL; zero_bits = 1; status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, zero_bits, &size, - MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE); ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY || broken(status == STATUS_INVALID_PARAMETER_3) /* winxp */, "NtAllocateVirtualMemory returned %08x\n", status); if (status == STATUS_SUCCESS) { + todo_wine_if(is_win64) ok(((UINT_PTR)addr2 >> (32 - zero_bits)) == 0, "NtAllocateVirtualMemory returned address: %p\n", addr2);
@@ -132,13 +134,14 @@ static void test_AllocateVirtualMemory(void) size = 0x1000; addr2 = NULL; status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, zero_bits, &size, - MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE); ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY || broken(zero_bits == 20 && status == STATUS_CONFLICTING_ADDRESSES) /* w1064v1809 */, "NtAllocateVirtualMemory with %d zero_bits returned %08x\n", zero_bits, status); if (status == STATUS_SUCCESS) { - todo_wine_if((UINT_PTR)addr2 >> (32 - zero_bits)) + todo_wine ok(((UINT_PTR)addr2 >> (32 - zero_bits)) == 0, "NtAllocateVirtualMemory with %d zero_bits returned address %p\n", zero_bits, addr2);
@@ -176,7 +179,8 @@ static void test_AllocateVirtualMemory(void) addr2 = NULL; zero_bits = 0x1fffffff; status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr2, zero_bits, &size, - MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE);
if (!is_win64 && !is_wow64) { @@ -188,7 +192,7 @@ static void test_AllocateVirtualMemory(void) "NtAllocateVirtualMemory returned %08x\n", status); if (status == STATUS_SUCCESS) { - todo_wine_if((UINT_PTR)addr2 & ~zero_bits) + todo_wine ok(((UINT_PTR)addr2 & ~zero_bits) == 0, "NtAllocateVirtualMemory returned address %p\n", addr2);
@@ -257,12 +261,12 @@ static void test_MapViewOfSection(void) size = 0; zero_bits = 1; offset.QuadPart = 0; - status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); + status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, MEM_TOP_DOWN, 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)) + todo_wine_if(is_win64) ok(((UINT_PTR)ptr2 >> (32 - zero_bits)) == 0, "NtMapViewOfSection returned address: %p\n", ptr2);
@@ -275,12 +279,12 @@ static void test_MapViewOfSection(void) ptr2 = NULL; size = 0; offset.QuadPart = 0; - status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); + status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, MEM_TOP_DOWN, 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)) + todo_wine ok(((UINT_PTR)ptr2 >> (32 - zero_bits)) == 0, "NtMapViewOfSection with %d zero_bits returned address %p\n", zero_bits, ptr2);
@@ -316,7 +320,7 @@ static void test_MapViewOfSection(void) size = 0; zero_bits = 0x1fffffff; offset.QuadPart = 0; - status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, 0, PAGE_READWRITE); + status = NtMapViewOfSection(mapping, process, &ptr2, zero_bits, 0, &offset, &size, 1, MEM_TOP_DOWN, PAGE_READWRITE);
if (!is_win64 && !is_wow64) { @@ -328,7 +332,7 @@ static void test_MapViewOfSection(void) "NtMapViewOfSection returned %08x\n", status); if (status == STATUS_SUCCESS) { - todo_wine_if((UINT_PTR)ptr2 & ~zero_bits) + todo_wine ok(((UINT_PTR)ptr2 & ~zero_bits) == 0, "NtMapViewOfSection returned address %p\n", ptr2);
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=53844
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 error: patch failed: dlls/ntdll/tests/virtual.c:27 error: patch failed: dlls/ntdll/tests/virtual.c:176 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 error: patch failed: dlls/ntdll/tests/virtual.c:27 error: patch failed: dlls/ntdll/tests/virtual.c:176 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 error: patch failed: dlls/ntdll/tests/virtual.c:27 error: patch failed: dlls/ntdll/tests/virtual.c:176 Task: Patch failed to apply
Implement the correct zero_bits behavior for this single case: * Limit the search in reserved areas to the lower 2G range, * Pass the MAP_32BIT flag to mmap as a fallback.
LuaJIT <= v2.0.5 for example, when running in 64bit, allocates its memory in the lower 2GB memory region by using the zero_bits parameter.
This will fix this particular scenario, while trying to minimize the changes on all the other cases.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 2 -- dlls/ntdll/virtual.c | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index c892e4aa4e0..0b80d840f52 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -120,7 +120,6 @@ static void test_AllocateVirtualMemory(void) "NtAllocateVirtualMemory returned %08x\n", status); if (status == STATUS_SUCCESS) { - todo_wine_if(is_win64) ok(((UINT_PTR)addr2 >> (32 - zero_bits)) == 0, "NtAllocateVirtualMemory returned address: %p\n", addr2);
@@ -266,7 +265,6 @@ static void test_MapViewOfSection(void) "NtMapViewOfSection returned %08x\n", status); if (status == STATUS_SUCCESS) { - todo_wine_if(is_win64) ok(((UINT_PTR)ptr2 >> (32 - zero_bits)) == 0, "NtMapViewOfSection returned address: %p\n", ptr2);
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 88ea958ccf5..7af1a1cff60 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1101,14 +1101,34 @@ static NTSTATUS map_view_aligned( struct file_view **view_ret, void *base, size_ { size_t view_size = size + mask + 1; struct alloc_area alloc; + int flags = 0;
+#if defined(__x86_64__) && !defined(MAP_32BIT) if (zero_bits) +#else + if (zero_bits > 1) +#endif + { FIXME("Unimplemented zero_bits parameter value\n"); + }
alloc.size = size; alloc.mask = mask; alloc.top_down = top_down; alloc.limit = user_space_limit; + +#if defined(__x86_64__) && defined(MAP_32BIT) + /* HACK: only works for zero_bits == 1, this is a simple workaround + * for some 64bit code that tries to allocate memory in the lower + * 2GB segment using zero_bits parameter. + */ + if (zero_bits == 1) + { + alloc.limit = (void*)(((~(UINT_PTR)0) >> (32 + zero_bits)) & ~0xffff); + flags = MAP_32BIT; + } +#endif + if (wine_mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down )) { ptr = alloc.result; @@ -1120,7 +1140,7 @@ static NTSTATUS map_view_aligned( struct file_view **view_ret, void *base, size_
for (;;) { - if ((ptr = wine_anon_mmap( NULL, view_size, VIRTUAL_GetUnixProt(vprot), 0 )) == (void *)-1) + if ((ptr = wine_anon_mmap( NULL, view_size, VIRTUAL_GetUnixProt(vprot), flags )) == (void *)-1) { if (errno == ENOMEM) return STATUS_NO_MEMORY; return STATUS_INVALID_PARAMETER;
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=53845
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 error: patch failed: dlls/ntdll/tests/virtual.c:27 error: patch failed: dlls/ntdll/tests/virtual.c:176 error: patch failed: dlls/ntdll/tests/virtual.c:120 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 error: patch failed: dlls/ntdll/tests/virtual.c:27 error: patch failed: dlls/ntdll/tests/virtual.c:176 error: patch failed: dlls/ntdll/tests/virtual.c:120 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/ntdll/tests/virtual.c:28 error: patch failed: dlls/ntdll/tests/virtual.c:248 error: patch failed: dlls/ntdll/tests/virtual.c:321 error: patch failed: dlls/ntdll/tests/virtual.c:27 error: patch failed: dlls/ntdll/tests/virtual.c:176 error: patch failed: dlls/ntdll/tests/virtual.c:120 Task: Patch failed to apply
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=53836
Your paranoid android.
=== wvistau64 (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_zh_CN (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_fr (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_he (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== w2008s64 (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== w7u (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== w7pro64 (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== w8 (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== w8adm (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== w864 (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== w1064v1507 (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== w1064v1809 (32 bit report) ===
kernel32: virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 0, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2854: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2868: 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:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2993: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3011: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3092: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3116: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2798: Test failed: expected policy flags 1, got 3 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:2897: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2912: 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:2975: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3156: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3181: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2760: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2799: Test failed: expected policy permanent FALSE, got 1 virtual.c:3218: Test failed: NtSetInformationProcess failed with status c0000022
=== debian9 (build log) ===
Task: WineTest did not produce the wow32 report
Looks like some of the patches in the series don't apply anymore, I can do a resend if needed.
On Tue, Jun 18, 2019 at 06:39:25PM +0200, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/kernel32/tests/virtual.c | 72 ++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 34 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 0b718606d0e..e72192477c8 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -73,6 +73,30 @@ static HANDLE create_target_process(const char *arg) return pi.hProcess; }
+static inline UINT_PTR get_zero_bits(UINT_PTR p) +{
- UINT_PTR z;
- if (p == 0)
return 32;
+#ifdef __x86_64__
- if (p > 0xffffffff)
return (~(UINT_PTR)0) >> get_zero_bits(p >> 32);
+#endif
+#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
- z = __builtin_clz((UINT32)p);
+#else
- z = 31;
- if (p >> 16) { z -= 16; p >>= 16; }
- if (p >> 8) { z -= 8; p >>= 8; }
- if (p >> 4) { z -= 4; p >>= 4; }
- if (p >> 2) { z -= 2; p >>= 2; }
- if (p >> 1) z -= 1;
+#endif
- return z;
+}
Since this is just a test, let's go for simplicity over speed. Just loop starting from the high bit until you get a 1.
Huw.