Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- dlls/kernel32/tests/virtual.c | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index a3b2d365c33..95842c04688 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -51,6 +51,7 @@ static BOOL (WINAPI *pGetProcessDEPPolicy)(HANDLE, LPDWORD, PBOOL); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); static NTSTATUS (WINAPI *pNtProtectVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG, ULONG *); static PVOID (WINAPI *pVirtualAllocFromApp)(PVOID, SIZE_T, DWORD, DWORD); +static BOOL (WINAPI *pPrefetchVirtualMemory)(HANDLE, ULONG_PTR, PWIN32_MEMORY_RANGE_ENTRY, ULONG);
/* ############################### */
@@ -4240,6 +4241,46 @@ static void test_shared_memory_ro(BOOL is_child, DWORD child_access) CloseHandle(mapping); }
+static void test_PrefetchVirtualMemory(void) +{ + WIN32_MEMORY_RANGE_ENTRY entries[2]; + char stackmem[] = "Test stack mem"; + static char testmem[] = "Test memory range data"; + unsigned int page_size = si.dwPageSize; + + if (!pPrefetchVirtualMemory) + { + skip("no PrefetchVirtualMemory in kernelbase\n"); + return; + } + + todo_wine + ok( !pPrefetchVirtualMemory( GetCurrentProcess(), 0, NULL, 0 ), + "PrefetchVirtualMemory unexpected success on 0 entries\n" ); + + entries[0].VirtualAddress = (PVOID)((ULONG_PTR)testmem & -(ULONG_PTR)page_size); + entries[0].NumberOfBytes = page_size; + ok( pPrefetchVirtualMemory( GetCurrentProcess(), 1, entries, 0 ), + "PrefetchVirtualMemory unexpected status on 1 page-aligned entry: %d\n", GetLastError() ); + + entries[0].VirtualAddress = testmem; + entries[0].NumberOfBytes = sizeof(testmem); + ok( pPrefetchVirtualMemory( GetCurrentProcess(), 1, entries, 0 ), + "PrefetchVirtualMemory unexpected status on 1 entry: %d\n", GetLastError() ); + + entries[0].VirtualAddress = NULL; + entries[0].NumberOfBytes = page_size; + ok( pPrefetchVirtualMemory( GetCurrentProcess(), 1, entries, 0 ), + "PrefetchVirtualMemory unexpected status on 1 unmapped entry: %d\n", GetLastError() ); + + entries[0].VirtualAddress = (PVOID)((ULONG_PTR)testmem & -(ULONG_PTR)page_size); + entries[0].NumberOfBytes = page_size; + entries[1].VirtualAddress = (PVOID)((ULONG_PTR)stackmem & -(ULONG_PTR)page_size); + entries[1].NumberOfBytes = page_size; + ok( pPrefetchVirtualMemory( GetCurrentProcess(), 2, entries, 0 ), + "PrefetchVirtualMemory unexpected status on 2 page-aligned entries: %d\n", GetLastError() ); +} + START_TEST(virtual) { int argc; @@ -4295,6 +4336,7 @@ START_TEST(virtual) pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlRemoveVectoredExceptionHandler" ); pNtProtectVirtualMemory = (void *)GetProcAddress( hntdll, "NtProtectVirtualMemory" ); pVirtualAllocFromApp = (void *)GetProcAddress( hkernelbase, "VirtualAllocFromApp" ); + pPrefetchVirtualMemory = (void *)GetProcAddress( hkernelbase, "PrefetchVirtualMemory" );
GetSystemInfo(&si); trace("system page size %#x\n", si.dwPageSize); @@ -4317,6 +4359,7 @@ START_TEST(virtual) test_IsBadWritePtr(); test_IsBadCodePtr(); test_write_watch(); + test_PrefetchVirtualMemory(); #if defined(__i386__) || defined(__x86_64__) test_stack_commit(); #endif