From 68ade392f8befac2ad19b3bb4ee497e705114998 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 7 Jun 2015 23:50:18 +0200 Subject: [PATCH] ntdll-AT_ROUND_TO_PAGE: A couple of minor improvements for kernel32/tests. --- ...dd-tests-for-virtual-memory-align-be.patch | 47 ++++++++++--------- ...t-for-AT_ROUND_TO_PAGE-flag-in-NtMap.patch | 14 +++--- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/patches/ntdll-AT_ROUND_TO_PAGE/0001-kernel32-tests-Add-tests-for-virtual-memory-align-be.patch b/patches/ntdll-AT_ROUND_TO_PAGE/0001-kernel32-tests-Add-tests-for-virtual-memory-align-be.patch index 158a6e35..f4061d40 100644 --- a/patches/ntdll-AT_ROUND_TO_PAGE/0001-kernel32-tests-Add-tests-for-virtual-memory-align-be.patch +++ b/patches/ntdll-AT_ROUND_TO_PAGE/0001-kernel32-tests-Add-tests-for-virtual-memory-align-be.patch @@ -1,15 +1,15 @@ -From ba356b408f62fe5b7e772eb3fff46494e77542e9 Mon Sep 17 00:00:00 2001 +From 2c9bd8d13fbe12697f121e3391d9a477afc58235 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 5 Jun 2015 07:32:40 +0200 Subject: kernel32/tests: Add tests for virtual memory align behaviour. --- - dlls/kernel32/tests/virtual.c | 194 +++++++++++++++++++++++++++++++++++++++++- + dlls/kernel32/tests/virtual.c | 201 +++++++++++++++++++++++++++++++++++++++++- include/winnt.h | 1 + - 2 files changed, 194 insertions(+), 1 deletion(-) + 2 files changed, 200 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c -index 4f50df8..15fa903 100644 +index 4f50df8..497d401 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -47,7 +47,10 @@ static struct _TEB * (WINAPI *pNtCurrentTeb)(void); @@ -75,23 +75,18 @@ index 4f50df8..15fa903 100644 } static void test_MapViewOfFile(void) -@@ -957,11 +998,14 @@ static void test_NtMapViewOfSection(void) +@@ -957,8 +998,8 @@ static void test_NtMapViewOfSection(void) static const char data[] = "test data for NtMapViewOfSection"; char buffer[sizeof(data)]; HANDLE file, mapping; - void *ptr; +- BOOL ret; + void *ptr, *ptr2; - BOOL ret; ++ BOOL is_wow64, ret; DWORD status, written; SIZE_T size, result; LARGE_INTEGER offset; -+#ifdef __i386__ -+ BOOL is_wow64; -+#endif - - if (!pNtMapViewOfSection || !pNtUnmapViewOfSection) - { -@@ -988,12 +1032,157 @@ static void test_NtMapViewOfSection(void) +@@ -988,12 +1029,165 @@ static void test_NtMapViewOfSection(void) offset.QuadPart = 0; status = pNtMapViewOfSection( mapping, hProcess, &ptr, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE ); ok( !status, "NtMapViewOfSection failed status %x\n", status ); @@ -182,8 +177,8 @@ index 4f50df8..15fa903 100644 + ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); + } + -+#ifdef __i386__ -+ if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 ) || !is_wow64) ++ if (sizeof(void *) == sizeof(int) && (!pIsWow64Process || ++ !pIsWow64Process( GetCurrentProcess(), &is_wow64 ) || !is_wow64)) + { + /* new memory region conflicts with previous mapping */ + ptr2 = ptr; @@ -209,7 +204,8 @@ index 4f50df8..15fa903 100644 + &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); + todo_wine + ok( status == STATUS_SUCCESS, "NtMapViewOfSection returned %x\n", status ); -+ ok( (char *)ptr2 == (char *)ptr + 0x1000, "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2 ); ++ ok( (char *)ptr2 == (char *)ptr + 0x1000, ++ "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2 ); + status = pNtUnmapViewOfSection( hProcess, ptr2 ); + todo_wine + ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); @@ -223,7 +219,8 @@ index 4f50df8..15fa903 100644 + todo_wine + ok( status == STATUS_SUCCESS, "NtMapViewOfSection returned %x\n", status ); + todo_wine -+ ok( (char *)ptr2 == (char *)ptr + 0x1000, "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2 ); ++ ok( (char *)ptr2 == (char *)ptr + 0x1000, ++ "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2 ); + status = pNtUnmapViewOfSection( hProcess, ptr2 ); + todo_wine + ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); @@ -235,21 +232,27 @@ index 4f50df8..15fa903 100644 + &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); + todo_wine + ok( status == STATUS_SUCCESS, "NtMapViewOfSection returned %x\n", status ); -+ ok( (char *)ptr2 == (char *)ptr + 0x2000, "expected address %p, got %p\n", (char *)ptr + 0x2000, ptr2 ); ++ ok( (char *)ptr2 == (char *)ptr + 0x2000, ++ "expected address %p, got %p\n", (char *)ptr + 0x2000, ptr2 ); + status = pNtUnmapViewOfSection( hProcess, ptr2 ); + todo_wine + ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); + } + else -+#endif + { -+ skip( "AT_ROUND_TO_PAGE is not available on 64-bit systems\n" ); ++ 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, "NtMapViewOfSection returned %x\n", status ); + } + status = pNtUnmapViewOfSection( hProcess, ptr ); ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); -@@ -3495,6 +3684,7 @@ START_TEST(virtual) +@@ -3495,6 +3689,7 @@ START_TEST(virtual) pGetWriteWatch = (void *) GetProcAddress(hkernel32, "GetWriteWatch"); pResetWriteWatch = (void *) GetProcAddress(hkernel32, "ResetWriteWatch"); pGetProcessDEPPolicy = (void *)GetProcAddress( hkernel32, "GetProcessDEPPolicy" ); @@ -257,7 +260,7 @@ index 4f50df8..15fa903 100644 pNtAreMappedFilesTheSame = (void *)GetProcAddress( hntdll, "NtAreMappedFilesTheSame" ); pNtMapViewOfSection = (void *)GetProcAddress( hntdll, "NtMapViewOfSection" ); pNtUnmapViewOfSection = (void *)GetProcAddress( hntdll, "NtUnmapViewOfSection" ); -@@ -3502,6 +3692,8 @@ START_TEST(virtual) +@@ -3502,6 +3697,8 @@ START_TEST(virtual) pRtlAddVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlAddVectoredExceptionHandler" ); pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlRemoveVectoredExceptionHandler" ); pNtProtectVirtualMemory = (void *)GetProcAddress( hntdll, "NtProtectVirtualMemory" ); diff --git a/patches/ntdll-AT_ROUND_TO_PAGE/0003-ntdll-Add-support-for-AT_ROUND_TO_PAGE-flag-in-NtMap.patch b/patches/ntdll-AT_ROUND_TO_PAGE/0003-ntdll-Add-support-for-AT_ROUND_TO_PAGE-flag-in-NtMap.patch index 4eb773ee..a8d6ad14 100644 --- a/patches/ntdll-AT_ROUND_TO_PAGE/0003-ntdll-Add-support-for-AT_ROUND_TO_PAGE-flag-in-NtMap.patch +++ b/patches/ntdll-AT_ROUND_TO_PAGE/0003-ntdll-Add-support-for-AT_ROUND_TO_PAGE-flag-in-NtMap.patch @@ -1,4 +1,4 @@ -From 2301c43dfcc22112849acf75a90a89cda3137952 Mon Sep 17 00:00:00 2001 +From f595930f5c3bbfed975ddf38173573b56b20838f Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 5 Jun 2015 07:40:44 +0200 Subject: ntdll: Add support for AT_ROUND_TO_PAGE flag in NtMapViewOfSection. @@ -9,28 +9,30 @@ Subject: ntdll: Add support for AT_ROUND_TO_PAGE flag in NtMapViewOfSection. 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c -index 08a34bf..d10d85d 100644 +index 3bcf697..cdd2466 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c -@@ -1141,11 +1141,9 @@ static void test_NtMapViewOfSection(void) +@@ -1138,12 +1138,10 @@ static void test_NtMapViewOfSection(void) offset.QuadPart = 0; status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); - todo_wine ok( status == STATUS_SUCCESS, "NtMapViewOfSection returned %x\n", status ); - ok( (char *)ptr2 == (char *)ptr + 0x1000, "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2 ); + ok( (char *)ptr2 == (char *)ptr + 0x1000, + "expected address %p, got %p\n", (char *)ptr + 0x1000, ptr2 ); status = pNtUnmapViewOfSection( hProcess, ptr2 ); - todo_wine ok( !status, "NtUnmapViewOfSection failed status %x\n", status ); /* the address is rounded down if not on a page boundary */ -@@ -1167,11 +1165,9 @@ static void test_NtMapViewOfSection(void) +@@ -1166,12 +1164,10 @@ static void test_NtMapViewOfSection(void) offset.QuadPart = 0; status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 0, 0, &offset, &size, 1, AT_ROUND_TO_PAGE, PAGE_READWRITE ); - todo_wine ok( status == STATUS_SUCCESS, "NtMapViewOfSection returned %x\n", status ); - ok( (char *)ptr2 == (char *)ptr + 0x2000, "expected address %p, got %p\n", (char *)ptr + 0x2000, ptr2 ); + ok( (char *)ptr2 == (char *)ptr + 0x2000, + "expected address %p, got %p\n", (char *)ptr + 0x2000, ptr2 ); status = pNtUnmapViewOfSection( hProcess, ptr2 ); - todo_wine ok( !status, "NtUnmapViewOfSection failed status %x\n", status );