static void test_ws_functions(void) { PSAPI_WS_WATCH_INFORMATION wswi[4096]; ULONG_PTR pages[4096]; char *addr; unsigned int i; todo_wine w32_err(pEmptyWorkingSet(NULL), ERROR_INVALID_HANDLE); todo_wine w32_err(pEmptyWorkingSet(hpSR), ERROR_ACCESS_DENIED); w32_suc(pEmptyWorkingSet(hpAA)); todo_wine w32_err(pInitializeProcessForWsWatch(NULL), ERROR_INVALID_HANDLE); w32_suc(pInitializeProcessForWsWatch(hpAA)); if(!w32_suc(addr = VirtualAlloc(NULL, 1, MEM_COMMIT, PAGE_READWRITE))) return; if(!VirtualLock(addr, 1)) { trace("locking failed (error=%d) - skipping test\n", GetLastError()); goto free_page; } todo_wine if(w32_suc(pQueryWorkingSet(hpQI, pages, 4096 * sizeof(ULONG_PTR)))) { for(i = 0; i < pages[0]; i++) if((pages[i+1] & ~0xfffL) == (ULONG_PTR)addr) { ok(1, "QueryWorkingSet found our page\n"); goto test_gwsc; } ok(0, "QueryWorkingSet didn't find our page\n"); } test_gwsc: todo_wine if(w32_suc(pGetWsChanges(hpQI, wswi, sizeof(wswi)))) { for(i = 0; wswi[i].FaultingVa; i++) if(((ULONG_PTR)wswi[i].FaultingVa & ~0xfffL) == (ULONG_PTR)addr) { ok(1, "GetWsChanges found our page\n"); goto free_page; } ok(0, "GetWsChanges didn't find our page\n"); } free_page: VirtualFree(addr, 0, MEM_RELEASE); }
static void test_ws_functions(void) { PSAPI_WS_WATCH_INFORMATION wswi[4096]; ULONG_PTR pages[4096]; char *addr; unsigned int i; BOOL ret; SetLastError(0xdeadbeef); pEmptyWorkingSet(NULL); todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE but got %d\n", GetLastError()); SetLastError(0xdeadbeef); pEmptyWorkingSet(hpSR); todo_wine ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED but got %d\n", GetLastError()); SetLastError(0xdeadbeef); ret = pEmptyWorkingSet(hpAA); ok(ret == 1, "failed with %d\n", GetLastError()); SetLastError( 0xdeadbeef ); ret = pInitializeProcessForWsWatch( NULL ); todo_wine ok( !ret, "InitializeProcessForWsWatch succeeded\n" ); if (!ret) { if (GetLastError() == ERROR_INVALID_FUNCTION) /* not supported on xp in wow64 mode */ { trace( "InitializeProcessForWsWatch not supported\n" ); return; } ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() ); } SetLastError(0xdeadbeef); ret = pInitializeProcessForWsWatch(hpAA); ok(ret == 1, "failed with %d\n", GetLastError()); addr = VirtualAlloc(NULL, 1, MEM_COMMIT, PAGE_READWRITE); if(!addr) return; *addr = 0; /* make sure it's paged in (needed on wow64) */ if(!VirtualLock(addr, 1)) { trace("locking failed (error=%d) - skipping test\n", GetLastError()); goto free_page; } SetLastError(0xdeadbeef); ret = pQueryWorkingSet(hpQI, pages, 4096 * sizeof(ULONG_PTR)); todo_wine ok(ret == 1, "failed with %d\n", GetLastError()); if(ret == 1) { for(i = 0; i < pages[0]; i++) if((pages[i+1] & ~0xfffL) == (ULONG_PTR)addr) { todo_wine ok(ret == 1, "QueryWorkingSet found our page\n"); goto test_gwsc; } todo_wine ok(0, "QueryWorkingSet didn't find our page\n"); } test_gwsc: SetLastError(0xdeadbeef); ret = pGetWsChanges(hpQI, wswi, sizeof(wswi)); todo_wine ok(ret == 1, "failed with %d\n", GetLastError()); if(ret == 1) { for(i = 0; wswi[i].FaultingVa; i++) if(((ULONG_PTR)wswi[i].FaultingVa & ~0xfffL) == (ULONG_PTR)addr) { todo_wine ok(ret == 1, "GetWsChanges found our page\n"); goto free_page; } todo_wine ok(0, "GetWsChanges didn't find our page\n"); } free_page: VirtualFree(addr, 0, MEM_RELEASE); }