https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4567e13e3e5f0d0028a47…
commit 4567e13e3e5f0d0028a47aa011249f834be3712d
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Sat Feb 2 13:29:37 2019 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sat Feb 2 13:29:37 2019 +0100
[PSAPI_WINETEST] Sync with Wine Staging 4.0. CORE-15682
---
modules/rostests/winetests/psapi/CMakeLists.txt | 2 +-
modules/rostests/winetests/psapi/psapi_main.c | 342 +++++++++++++-----------
2 files changed, 189 insertions(+), 155 deletions(-)
diff --git a/modules/rostests/winetests/psapi/CMakeLists.txt
b/modules/rostests/winetests/psapi/CMakeLists.txt
index 638c93f7e7..bbb295b4f0 100644
--- a/modules/rostests/winetests/psapi/CMakeLists.txt
+++ b/modules/rostests/winetests/psapi/CMakeLists.txt
@@ -2,5 +2,5 @@
add_definitions(-D__WINESRC__)
add_executable(psapi_winetest psapi_main.c testlist.c)
set_module_type(psapi_winetest win32cui)
-add_importlibs(psapi_winetest msvcrt kernel32)
+add_importlibs(psapi_winetest psapi user32 msvcrt kernel32)
add_rostests_file(TARGET psapi_winetest)
diff --git a/modules/rostests/winetests/psapi/psapi_main.c
b/modules/rostests/winetests/psapi/psapi_main.c
index a03605b173..9285334859 100644
--- a/modules/rostests/winetests/psapi/psapi_main.c
+++ b/modules/rostests/winetests/psapi/psapi_main.c
@@ -35,64 +35,30 @@
#include "winnt.h"
#include "wine/winternl.h"
#include "winnls.h"
+#include "winuser.h"
+#define PSAPI_VERSION 1
#include "psapi.h"
#include "wine/test.h"
-#define PSAPI_GET_PROC(func) \
- p ## func = (void*)GetProcAddress(hpsapi, #func); \
- if(!p ## func) { \
- ok(0, "GetProcAddress(%s) failed\n", #func); \
- FreeLibrary(hpsapi); \
- return FALSE; \
- }
-
-static BOOL (WINAPI *pEmptyWorkingSet)(HANDLE);
-static BOOL (WINAPI *pEnumProcesses)(DWORD*, DWORD, DWORD*);
-static BOOL (WINAPI *pEnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD);
-static DWORD (WINAPI *pGetModuleBaseNameA)(HANDLE, HMODULE, LPSTR, DWORD);
-static DWORD (WINAPI *pGetModuleFileNameExA)(HANDLE, HMODULE, LPSTR, DWORD);
-static DWORD (WINAPI *pGetModuleFileNameExW)(HANDLE, HMODULE, LPWSTR, DWORD);
-static BOOL (WINAPI *pGetModuleInformation)(HANDLE, HMODULE, LPMODULEINFO, DWORD);
-static DWORD (WINAPI *pGetMappedFileNameA)(HANDLE, LPVOID, LPSTR, DWORD);
-static DWORD (WINAPI *pGetMappedFileNameW)(HANDLE, LPVOID, LPWSTR, DWORD);
-static BOOL (WINAPI *pGetPerformanceInfo)(PPERFORMANCE_INFORMATION, DWORD);
-static DWORD (WINAPI *pGetProcessImageFileNameA)(HANDLE, LPSTR, DWORD);
-static DWORD (WINAPI *pGetProcessImageFileNameW)(HANDLE, LPWSTR, DWORD);
-static BOOL (WINAPI *pGetProcessMemoryInfo)(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD);
-static BOOL (WINAPI *pGetWsChanges)(HANDLE, PPSAPI_WS_WATCH_INFORMATION, DWORD);
-static BOOL (WINAPI *pInitializeProcessForWsWatch)(HANDLE);
-static BOOL (WINAPI *pQueryWorkingSet)(HANDLE, PVOID, DWORD);
static NTSTATUS (WINAPI *pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID,
ULONG, PULONG);
static NTSTATUS (WINAPI *pNtQueryVirtualMemory)(HANDLE, LPCVOID, ULONG, PVOID, SIZE_T,
SIZE_T *);
+static BOOL (WINAPI *pIsWow64Process)(HANDLE, BOOL *);
+static BOOL (WINAPI *pWow64DisableWow64FsRedirection)(void **);
+static BOOL (WINAPI *pWow64RevertWow64FsRedirection)(void *);
+
+static BOOL wow64;
-static BOOL InitFunctionPtrs(HMODULE hpsapi)
+static BOOL init_func_ptrs(void)
{
- PSAPI_GET_PROC(EmptyWorkingSet);
- PSAPI_GET_PROC(EnumProcessModules);
- PSAPI_GET_PROC(EnumProcesses);
- PSAPI_GET_PROC(GetModuleBaseNameA);
- PSAPI_GET_PROC(GetModuleFileNameExA);
- PSAPI_GET_PROC(GetModuleFileNameExW);
- PSAPI_GET_PROC(GetModuleInformation);
- PSAPI_GET_PROC(GetMappedFileNameA);
- PSAPI_GET_PROC(GetMappedFileNameW);
- PSAPI_GET_PROC(GetProcessMemoryInfo);
- PSAPI_GET_PROC(GetWsChanges);
- PSAPI_GET_PROC(InitializeProcessForWsWatch);
- PSAPI_GET_PROC(QueryWorkingSet);
- /* GetProcessImageFileName is not exported on NT4 */
- pGetPerformanceInfo =
- (void *)GetProcAddress(hpsapi, "GetPerformanceInfo");
- pGetProcessImageFileNameA =
- (void *)GetProcAddress(hpsapi, "GetProcessImageFileNameA");
- pGetProcessImageFileNameW =
- (void *)GetProcAddress(hpsapi, "GetProcessImageFileNameW");
pNtQuerySystemInformation = (void
*)GetProcAddress(GetModuleHandleA("ntdll.dll"),
"NtQuerySystemInformation");
pNtQueryVirtualMemory = (void
*)GetProcAddress(GetModuleHandleA("ntdll.dll"),
"NtQueryVirtualMemory");
+ pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"),
"IsWow64Process");
+ pWow64DisableWow64FsRedirection = (void
*)GetProcAddress(GetModuleHandleA("kernel32.dll"),
"Wow64DisableWow64FsRedirection");
+ pWow64RevertWow64FsRedirection = (void
*)GetProcAddress(GetModuleHandleA("kernel32.dll"),
"Wow64RevertWow64FsRedirection");
return TRUE;
}
-static HANDLE hpSR, hpQI, hpVR, hpQV, hpAA;
+static HANDLE hpSR, hpQI, hpVR, hpQV;
static const HANDLE hBad = (HANDLE)0xdeadbeef;
static void test_EnumProcesses(void)
@@ -100,59 +66,133 @@ static void test_EnumProcesses(void)
DWORD pid, ret, cbUsed = 0xdeadbeef;
SetLastError(0xdeadbeef);
- ret = pEnumProcesses(NULL, 0, &cbUsed);
+ ret = EnumProcesses(NULL, 0, &cbUsed);
ok(ret == 1, "failed with %d\n", GetLastError());
ok(cbUsed == 0, "cbUsed=%d\n", cbUsed);
SetLastError(0xdeadbeef);
- ret = pEnumProcesses(&pid, 4, &cbUsed);
+ ret = EnumProcesses(&pid, 4, &cbUsed);
ok(ret == 1, "failed with %d\n", GetLastError());
ok(cbUsed == 4, "cbUsed=%d\n", cbUsed);
}
static void test_EnumProcessModules(void)
{
+ char buffer[200] = "C:\\windows\\system32\\notepad.exe";
+ PROCESS_INFORMATION pi = {0};
+ STARTUPINFOA si = {0};
+ void *cookie;
HMODULE hMod;
DWORD ret, cbNeeded = 0xdeadbeef;
SetLastError(0xdeadbeef);
- pEnumProcessModules(NULL, NULL, 0, &cbNeeded);
+ EnumProcessModules(NULL, NULL, 0, &cbNeeded);
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pEnumProcessModules(hpQI, NULL, 0, &cbNeeded);
+ EnumProcessModules(hpQI, NULL, 0, &cbNeeded);
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
hMod = (void *)0xdeadbeef;
- ret = pEnumProcessModules(hpQI, &hMod, sizeof(HMODULE), NULL);
+ ret = EnumProcessModules(hpQI, &hMod, sizeof(HMODULE), NULL);
ok(!ret, "succeeded\n");
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
hMod = (void *)0xdeadbeef;
- ret = pEnumProcessModules(hpQV, &hMod, sizeof(HMODULE), NULL);
+ ret = EnumProcessModules(hpQV, &hMod, sizeof(HMODULE), NULL);
ok(!ret, "succeeded\n");
ok(GetLastError() == ERROR_NOACCESS, "expected error=ERROR_NOACCESS but got
%d\n", GetLastError());
ok(hMod == GetModuleHandleA(NULL),
"hMod=%p GetModuleHandleA(NULL)=%p\n", hMod, GetModuleHandleA(NULL));
SetLastError(0xdeadbeef);
- ret = pEnumProcessModules(hpQV, NULL, 0, &cbNeeded);
+ ret = EnumProcessModules(hpQV, NULL, 0, &cbNeeded);
ok(ret == 1, "failed with %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pEnumProcessModules(hpQV, NULL, sizeof(HMODULE), &cbNeeded);
+ ret = EnumProcessModules(hpQV, NULL, sizeof(HMODULE), &cbNeeded);
ok(!ret, "succeeded\n");
ok(GetLastError() == ERROR_NOACCESS, "expected error=ERROR_NOACCESS but got
%d\n", GetLastError());
SetLastError(0xdeadbeef);
hMod = (void *)0xdeadbeef;
- ret = pEnumProcessModules(hpQV, &hMod, sizeof(HMODULE), &cbNeeded);
+ ret = EnumProcessModules(hpQV, &hMod, sizeof(HMODULE), &cbNeeded);
ok(ret == 1, "got %d, failed with %d\n", ret, GetLastError());
ok(hMod == GetModuleHandleA(NULL),
"hMod=%p GetModuleHandleA(NULL)=%p\n", hMod, GetModuleHandleA(NULL));
ok(cbNeeded % sizeof(hMod) == 0, "not a multiple of sizeof(HMODULE)
cbNeeded=%d\n", cbNeeded);
+
+ ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si,
&pi);
+ ok(ret, "CreateProcess failed: %u\n", GetLastError());
+
+ ret = WaitForInputIdle(pi.hProcess, 1000);
+ ok(!ret, "wait timed out\n");
+
+ SetLastError(0xdeadbeef);
+ hMod = NULL;
+ ret = EnumProcessModules(pi.hProcess, &hMod, sizeof(HMODULE), &cbNeeded);
+ ok(ret == 1, "got %d, error %u\n", ret, GetLastError());
+ ok(!!hMod, "expected non-NULL module\n");
+ ok(cbNeeded % sizeof(hMod) == 0, "got %u\n", cbNeeded);
+
+ TerminateProcess(pi.hProcess, 0);
+
+ if (sizeof(void *) == 8)
+ {
+ MODULEINFO info;
+ char name[40];
+
+ strcpy(buffer, "C:\\windows\\syswow64\\notepad.exe");
+ ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si,
&pi);
+ ok(ret, "CreateProcess failed: %u\n", GetLastError());
+
+ ret = WaitForInputIdle(pi.hProcess, 1000);
+ ok(!ret, "wait timed out\n");
+
+ SetLastError(0xdeadbeef);
+ hMod = NULL;
+ ret = EnumProcessModules(pi.hProcess, &hMod, sizeof(HMODULE),
&cbNeeded);
+ ok(ret == 1, "got %d, error %u\n", ret, GetLastError());
+ ok(!!hMod, "expected non-NULL module\n");
+ ok(cbNeeded % sizeof(hMod) == 0, "got %u\n", cbNeeded);
+
+ ret = GetModuleBaseNameA(pi.hProcess, hMod, name, sizeof(name));
+ ok(ret, "got error %u\n", GetLastError());
+ ok(!strcmp(name, "notepad.exe"), "got %s\n", name);
+
+ ret = GetModuleFileNameExA(pi.hProcess, hMod, name, sizeof(name));
+ ok(ret, "got error %u\n", GetLastError());
+todo_wine
+ ok(!strcmp(name, buffer), "got %s\n", name);
+
+ ret = GetModuleInformation(pi.hProcess, hMod, &info, sizeof(info));
+ ok(ret, "got error %u\n", GetLastError());
+ ok(info.lpBaseOfDll == hMod, "expected %p, got %p\n", hMod,
info.lpBaseOfDll);
+ ok(info.SizeOfImage, "image size was 0\n");
+ ok(info.EntryPoint >= info.lpBaseOfDll, "got entry point %p\n",
info.EntryPoint);
+
+ TerminateProcess(pi.hProcess, 0);
+ }
+ else if (wow64)
+ {
+ pWow64DisableWow64FsRedirection(&cookie);
+ ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si,
&pi);
+ pWow64RevertWow64FsRedirection(cookie);
+ ok(ret, "CreateProcess failed: %u\n", GetLastError());
+
+ ret = WaitForInputIdle(pi.hProcess, 1000);
+ ok(!ret, "wait timed out\n");
+
+ SetLastError(0xdeadbeef);
+ ret = EnumProcessModules(pi.hProcess, &hMod, sizeof(HMODULE),
&cbNeeded);
+ ok(!ret, "got %d\n", ret);
+todo_wine
+ ok(GetLastError() == ERROR_PARTIAL_COPY, "got error %u\n",
GetLastError());
+
+ TerminateProcess(pi.hProcess, 0);
+ }
}
static void test_GetModuleInformation(void)
@@ -163,29 +203,29 @@ static void test_GetModuleInformation(void)
DWORD ret;
SetLastError(0xdeadbeef);
- pGetModuleInformation(NULL, hMod, &info, sizeof(info));
+ GetModuleInformation(NULL, hMod, &info, sizeof(info));
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pGetModuleInformation(hpQI, hMod, &info, sizeof(info));
+ GetModuleInformation(hpQI, hMod, &info, sizeof(info));
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pGetModuleInformation(hpQV, hBad, &info, sizeof(info));
+ GetModuleInformation(hpQV, hBad, &info, sizeof(info));
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pGetModuleInformation(hpQV, hMod, &info, sizeof(info)-1);
+ GetModuleInformation(hpQV, hMod, &info, sizeof(info)-1);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected
error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError());
- ret = pGetModuleInformation(hpQV, hMod, &info, sizeof(info));
+ ret = GetModuleInformation(hpQV, hMod, &info, sizeof(info));
ok(ret == 1, "failed with %d\n", GetLastError());
ok(info.lpBaseOfDll == hMod, "lpBaseOfDll=%p hMod=%p\n", info.lpBaseOfDll,
hMod);
hMod = LoadLibraryA("shell32.dll");
ok(hMod != NULL, "Failed to load shell32.dll, error: %u\n",
GetLastError());
- ret = pGetModuleInformation(hpQV, hMod, &info, sizeof(info));
+ ret = GetModuleInformation(hpQV, hMod, &info, sizeof(info));
ok(ret == 1, "failed with %d\n", GetLastError());
info.SizeOfImage /= sizeof(DWORD);
for (tmp = (DWORD *)hMod; info.SizeOfImage; info.SizeOfImage--)
@@ -208,15 +248,10 @@ static void test_GetPerformanceInfo(void)
BOOL ret;
SetLastError(0xdeadbeef);
- ret = pGetPerformanceInfo(&info, sizeof(info)-1);
+ ret = GetPerformanceInfo(&info, sizeof(info)-1);
ok(!ret, "GetPerformanceInfo unexpectedly succeeded\n");
ok(GetLastError() == ERROR_BAD_LENGTH, "expected error=ERROR_BAD_LENGTH but got
%d\n", GetLastError());
- SetLastError(0xdeadbeef);
- ret = pGetPerformanceInfo(&info, sizeof(info));
- ok(ret, "GetPerformanceInfo failed with %d\n", GetLastError());
- ok(info.cb == sizeof(PERFORMANCE_INFORMATION), "got %d\n", info.cb);
-
if (!pNtQuerySystemInformation)
win_skip("NtQuerySystemInformation not found, skipping tests\n");
else
@@ -233,6 +268,10 @@ static void test_GetPerformanceInfo(void)
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n",
status);
ok(size >= sizeof(SYSTEM_PERFORMANCE_INFORMATION), "incorrect length
%d\n", size);
+ SetLastError(0xdeadbeef);
+ ret = GetPerformanceInfo(&info, sizeof(info));
+ ok(ret, "GetPerformanceInfo failed with %d\n", GetLastError());
+ ok(info.cb == sizeof(PERFORMANCE_INFORMATION), "got %d\n", info.cb);
ok(check_with_margin(info.CommitTotal,
sys_performance_info->TotalCommittedPages, 288),
"expected approximately %ld but got %d\n", info.CommitTotal,
sys_performance_info->TotalCommittedPages);
@@ -297,7 +336,7 @@ static void test_GetPerformanceInfo(void)
}
HeapFree(GetProcessHeap(), 0, sys_process_info);
- ok(check_with_margin(info.HandleCount, handle_count, 24),
+ ok(check_with_margin(info.HandleCount, handle_count, 256),
"expected approximately %d but got %d\n", info.HandleCount,
handle_count);
ok(check_with_margin(info.ProcessCount, process_count, 4),
@@ -315,22 +354,22 @@ static void test_GetProcessMemoryInfo(void)
DWORD ret;
SetLastError(0xdeadbeef);
- ret = pGetProcessMemoryInfo(NULL, &pmc, sizeof(pmc));
+ ret = GetProcessMemoryInfo(NULL, &pmc, sizeof(pmc));
ok(!ret, "GetProcessMemoryInfo should fail\n");
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetProcessMemoryInfo(hpSR, &pmc, sizeof(pmc));
+ ret = GetProcessMemoryInfo(hpSR, &pmc, sizeof(pmc));
ok(!ret, "GetProcessMemoryInfo should fail\n");
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetProcessMemoryInfo(hpQI, &pmc, sizeof(pmc)-1);
+ ret = GetProcessMemoryInfo(hpQI, &pmc, sizeof(pmc)-1);
ok(!ret, "GetProcessMemoryInfo should fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected
error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetProcessMemoryInfo(hpQI, &pmc, sizeof(pmc));
+ ret = GetProcessMemoryInfo(hpQI, &pmc, sizeof(pmc));
ok(ret == 1, "failed with %d\n", GetLastError());
}
@@ -380,17 +419,17 @@ static void test_GetMappedFileName(void)
GetCurrentProcess(), ¤t_process, 0, 0,
DUPLICATE_SAME_ACCESS );
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(NULL, hMod, szMapPath, sizeof(szMapPath));
+ ret = GetMappedFileNameA(NULL, hMod, szMapPath, sizeof(szMapPath));
ok(!ret, "GetMappedFileName should fail\n");
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(hpSR, hMod, szMapPath, sizeof(szMapPath));
+ ret = GetMappedFileNameA(hpSR, hMod, szMapPath, sizeof(szMapPath));
ok(!ret, "GetMappedFileName should fail\n");
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED
but got %d\n", GetLastError());
SetLastError( 0xdeadbeef );
- ret = pGetMappedFileNameA(hpQI, hMod, szMapPath, sizeof(szMapPath));
+ ret = GetMappedFileNameA(hpQI, hMod, szMapPath, sizeof(szMapPath));
ok( ret || broken(GetLastError() == ERROR_UNEXP_NET_ERR), /* win2k */
"GetMappedFileNameA failed with error %u\n", GetLastError() );
if (ret)
@@ -433,33 +472,34 @@ static void test_GetMappedFileName(void)
ok(base != NULL, "MapViewOfFile error %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, 0);
+ ret = GetMappedFileNameA(GetCurrentProcess(), base, map_name, 0);
ok(!ret, "GetMappedFileName should fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() ==
ERROR_INSUFFICIENT_BUFFER,
"wrong error %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(GetCurrentProcess(), base, 0, sizeof(map_name));
+ ret = GetMappedFileNameA(GetCurrentProcess(), base, 0, sizeof(map_name));
ok(!ret, "GetMappedFileName should fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER,
got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, 1);
+ ret = GetMappedFileNameA(GetCurrentProcess(), base, map_name, 1);
ok(ret == 1, "GetMappedFileName error %d\n", GetLastError());
ok(!map_name[0] || broken(map_name[0] == device_name[0]) /* before win2k */,
"expected 0, got %c\n", map_name[0]);
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, sizeof(map_name));
+ ret = GetMappedFileNameA(GetCurrentProcess(), base, map_name, sizeof(map_name));
ok(ret, "GetMappedFileName error %d\n", GetLastError());
ok(ret > strlen(device_name), "map_name should be longer than
device_name\n");
ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not
start with a device name: %s\n", map_name);
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameW(GetCurrentProcess(), base, map_nameW,
sizeof(map_nameW)/sizeof(map_nameW[0]));
+ ret = GetMappedFileNameW(GetCurrentProcess(), base, map_nameW,
ARRAY_SIZE(map_nameW));
+todo_wine {
ok(ret, "GetMappedFileNameW error %d\n", GetLastError());
ok(ret > strlen(device_name), "map_name should be longer than
device_name\n");
-
- if (nt_get_mapped_file_name(GetCurrentProcess(), base, nt_map_name,
sizeof(nt_map_name)/sizeof(nt_map_name[0])))
+}
+ if (nt_get_mapped_file_name(GetCurrentProcess(), base, nt_map_name,
ARRAY_SIZE(nt_map_name)))
{
ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name does
not start with a device name: %s\n", map_name);
WideCharToMultiByte(CP_ACP, 0, map_nameW, -1, map_name, MAX_PATH, NULL, NULL);
@@ -467,7 +507,7 @@ static void test_GetMappedFileName(void)
}
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameW(current_process, base, map_nameW,
sizeof(map_nameW)/sizeof(map_nameW[0]));
+ ret = GetMappedFileNameW(current_process, base, map_nameW,
sizeof(map_nameW)/sizeof(map_nameW[0]));
ok(ret, "GetMappedFileNameW error %d\n", GetLastError());
ok(ret > strlen(device_name), "map_name should be longer than
device_name\n");
@@ -479,24 +519,24 @@ static void test_GetMappedFileName(void)
}
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(GetCurrentProcess(), base + 0x2000, map_name,
sizeof(map_name));
+ ret = GetMappedFileNameA(GetCurrentProcess(), base + 0x2000, map_name,
sizeof(map_name));
ok(ret, "GetMappedFileName error %d\n", GetLastError());
ok(ret > strlen(device_name), "map_name should be longer than
device_name\n");
ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not
start with a device name: %s\n", map_name);
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(GetCurrentProcess(), base + 0x4000, map_name,
sizeof(map_name));
+ ret = GetMappedFileNameA(GetCurrentProcess(), base + 0x4000, map_name,
sizeof(map_name));
ok(!ret, "GetMappedFileName should fail\n");
ok(GetLastError() == ERROR_UNEXP_NET_ERR, "expected ERROR_UNEXP_NET_ERR, got
%d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(GetCurrentProcess(), NULL, map_name, sizeof(map_name));
+ ret = GetMappedFileNameA(GetCurrentProcess(), NULL, map_name, sizeof(map_name));
ok(!ret, "GetMappedFileName should fail\n");
todo_wine
ok(GetLastError() == ERROR_UNEXP_NET_ERR, "expected ERROR_UNEXP_NET_ERR, got
%d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(0, base, map_name, sizeof(map_name));
+ ret = GetMappedFileNameA(0, base, map_name, sizeof(map_name));
ok(!ret, "GetMappedFileName should fail\n");
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got
%d\n", GetLastError());
@@ -514,7 +554,7 @@ todo_wine
ok(base != NULL, "MapViewOfFile error %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, sizeof(map_name));
+ ret = GetMappedFileNameA(GetCurrentProcess(), base, map_name, sizeof(map_name));
ok(!ret, "GetMappedFileName should fail\n");
ok(GetLastError() == ERROR_FILE_INVALID, "expected ERROR_FILE_INVALID, got
%d\n", GetLastError());
@@ -530,12 +570,9 @@ static void test_GetProcessImageFileName(void)
WCHAR szImgPathW[MAX_PATH];
DWORD ret, ret1;
- if(pGetProcessImageFileNameA == NULL)
- return;
-
/* This function is available on WinXP+ only */
SetLastError(0xdeadbeef);
- if(!pGetProcessImageFileNameA(hpQI, szImgPath, sizeof(szImgPath)))
+ if(!GetProcessImageFileNameA(hpQI, szImgPath, sizeof(szImgPath)))
{
if(GetLastError() == ERROR_INVALID_FUNCTION) {
win_skip("GetProcessImageFileName not implemented\n");
@@ -549,19 +586,19 @@ static void test_GetProcessImageFileName(void)
}
SetLastError(0xdeadbeef);
- pGetProcessImageFileNameA(NULL, szImgPath, sizeof(szImgPath));
+ GetProcessImageFileNameA(NULL, szImgPath, sizeof(szImgPath));
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pGetProcessImageFileNameA(hpSR, szImgPath, sizeof(szImgPath));
+ GetProcessImageFileNameA(hpSR, szImgPath, sizeof(szImgPath));
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pGetProcessImageFileNameA(hpQI, szImgPath, 0);
+ GetProcessImageFileNameA(hpQI, szImgPath, 0);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected
error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError());
- ret = pGetProcessImageFileNameA(hpQI, szImgPath, sizeof(szImgPath));
- ret1 = pGetMappedFileNameA(hpQV, hMod, szMapPath, sizeof(szMapPath));
+ ret = GetProcessImageFileNameA(hpQI, szImgPath, sizeof(szImgPath));
+ ret1 = GetMappedFileNameA(hpQV, hMod, szMapPath, sizeof(szMapPath));
if(ret && ret1)
{
/* Windows returns 2*strlen-1 */
@@ -570,32 +607,32 @@ static void test_GetProcessImageFileName(void)
}
SetLastError(0xdeadbeef);
- pGetProcessImageFileNameW(NULL, szImgPathW, sizeof(szImgPathW));
+ GetProcessImageFileNameW(NULL, szImgPathW, ARRAY_SIZE(szImgPathW));
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
/* no information about correct buffer size returned: */
SetLastError(0xdeadbeef);
- pGetProcessImageFileNameW(hpQI, szImgPathW, 0);
+ GetProcessImageFileNameW(hpQI, szImgPathW, 0);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected
error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pGetProcessImageFileNameW(hpQI, NULL, 0);
+ GetProcessImageFileNameW(hpQI, NULL, 0);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected
error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError());
/* correct call */
memset(szImgPathW, 0xff, sizeof(szImgPathW));
- ret = pGetProcessImageFileNameW(hpQI, szImgPathW, sizeof(szImgPathW)/sizeof(WCHAR));
+ ret = GetProcessImageFileNameW(hpQI, szImgPathW, ARRAY_SIZE(szImgPathW));
ok(ret > 0, "GetProcessImageFileNameW should have succeeded.\n");
ok(szImgPathW[0] == '\\', "GetProcessImageFileNameW should have returned
an NT path.\n");
ok(lstrlenW(szImgPathW) == ret, "Expected length to be %d, got %d\n", ret,
lstrlenW(szImgPathW));
/* boundary values of 'size' */
SetLastError(0xdeadbeef);
- pGetProcessImageFileNameW(hpQI, szImgPathW, ret);
+ GetProcessImageFileNameW(hpQI, szImgPathW, ret);
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected
error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError());
memset(szImgPathW, 0xff, sizeof(szImgPathW));
- ret = pGetProcessImageFileNameW(hpQI, szImgPathW, ret + 1);
+ ret = GetProcessImageFileNameW(hpQI, szImgPathW, ret + 1);
ok(ret > 0, "GetProcessImageFileNameW should have succeeded.\n");
ok(szImgPathW[0] == '\\', "GetProcessImageFileNameW should have returned
an NT path.\n");
ok(lstrlenW(szImgPathW) == ret, "Expected length to be %d, got %d\n", ret,
lstrlenW(szImgPathW));
@@ -609,21 +646,21 @@ static void test_GetModuleFileNameEx(void)
DWORD ret;
SetLastError(0xdeadbeef);
- ret = pGetModuleFileNameExA(NULL, hMod, szModExPath, sizeof(szModExPath));
+ ret = GetModuleFileNameExA(NULL, hMod, szModExPath, sizeof(szModExPath));
ok( !ret, "GetModuleFileNameExA succeeded\n" );
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetModuleFileNameExA(hpQI, hMod, szModExPath, sizeof(szModExPath));
+ ret = GetModuleFileNameExA(hpQI, hMod, szModExPath, sizeof(szModExPath));
ok( !ret, "GetModuleFileNameExA succeeded\n" );
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pGetModuleFileNameExA(hpQV, hBad, szModExPath, sizeof(szModExPath));
+ ret = GetModuleFileNameExA(hpQV, hBad, szModExPath, sizeof(szModExPath));
ok( !ret, "GetModuleFileNameExA succeeded\n" );
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
- ret = pGetModuleFileNameExA(hpQV, NULL, szModExPath, sizeof(szModExPath));
+ ret = GetModuleFileNameExA(hpQV, NULL, szModExPath, sizeof(szModExPath));
if(!ret)
return;
ok(ret == strlen(szModExPath), "szModExPath=\"%s\" ret=%d\n",
szModExPath, ret);
@@ -633,7 +670,7 @@ static void test_GetModuleFileNameEx(void)
SetLastError(0xdeadbeef);
memset( szModExPath, 0xcc, sizeof(szModExPath) );
- ret = pGetModuleFileNameExA(hpQV, NULL, szModExPath, 4 );
+ ret = GetModuleFileNameExA(hpQV, NULL, szModExPath, 4 );
ok( ret == 4 || ret == strlen(szModExPath), "wrong length %u\n", ret );
ok( broken(szModExPath[3]) /*w2kpro*/ || strlen(szModExPath) == 3,
"szModExPath=\"%s\" ret=%d\n", szModExPath, ret );
@@ -642,14 +679,14 @@ static void test_GetModuleFileNameEx(void)
if (0) /* crashes on Windows 10 */
{
SetLastError(0xdeadbeef);
- ret = pGetModuleFileNameExA(hpQV, NULL, szModExPath, 0 );
+ ret = GetModuleFileNameExA(hpQV, NULL, szModExPath, 0 );
ok( ret == 0, "wrong length %u\n", ret );
ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %d\n",
GetLastError());
}
SetLastError(0xdeadbeef);
memset( buffer, 0xcc, sizeof(buffer) );
- ret = pGetModuleFileNameExW(hpQV, NULL, buffer, 4 );
+ ret = GetModuleFileNameExW(hpQV, NULL, buffer, 4 );
ok( ret == 4 || ret == lstrlenW(buffer), "wrong length %u\n", ret );
ok( broken(buffer[3]) /*w2kpro*/ || lstrlenW(buffer) == 3,
"buffer=%s ret=%d\n", wine_dbgstr_w(buffer), ret );
@@ -659,7 +696,7 @@ static void test_GetModuleFileNameEx(void)
{
SetLastError(0xdeadbeef);
buffer[0] = 0xcc;
- ret = pGetModuleFileNameExW(hpQV, NULL, buffer, 0 );
+ ret = GetModuleFileNameExW(hpQV, NULL, buffer, 0 );
ok( ret == 0, "wrong length %u\n", ret );
ok(GetLastError() == 0xdeadbeef, "got error %d\n", GetLastError());
ok( buffer[0] == 0xcc, "buffer modified %s\n", wine_dbgstr_w(buffer)
);
@@ -673,18 +710,18 @@ static void test_GetModuleBaseName(void)
DWORD ret;
SetLastError(0xdeadbeef);
- pGetModuleBaseNameA(NULL, hMod, szModBaseName, sizeof(szModBaseName));
+ GetModuleBaseNameA(NULL, hMod, szModBaseName, sizeof(szModBaseName));
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pGetModuleBaseNameA(hpQI, hMod, szModBaseName, sizeof(szModBaseName));
+ GetModuleBaseNameA(hpQI, hMod, szModBaseName, sizeof(szModBaseName));
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error=ERROR_ACCESS_DENIED
but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pGetModuleBaseNameA(hpQV, hBad, szModBaseName, sizeof(szModBaseName));
+ GetModuleBaseNameA(hpQV, hBad, szModBaseName, sizeof(szModBaseName));
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected error=ERROR_INVALID_HANDLE
but got %d\n", GetLastError());
- ret = pGetModuleBaseNameA(hpQV, NULL, szModBaseName, sizeof(szModBaseName));
+ ret = GetModuleBaseNameA(hpQV, NULL, szModBaseName, sizeof(szModBaseName));
if(!ret)
return;
ok(ret == strlen(szModBaseName), "szModBaseName=\"%s\" ret=%d\n",
szModBaseName, ret);
@@ -697,24 +734,29 @@ static void test_ws_functions(void)
{
PSAPI_WS_WATCH_INFORMATION wswi[4096];
ULONG_PTR pages[4096];
+ HANDLE ws_handle;
char *addr;
unsigned int i;
BOOL ret;
+ ws_handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_SET_QUOTA |
+ PROCESS_SET_INFORMATION, FALSE, GetCurrentProcessId());
+ ok(!!ws_handle, "got error %u\n", GetLastError());
+
SetLastError(0xdeadbeef);
- pEmptyWorkingSet(NULL);
+ EmptyWorkingSet(NULL);
todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "expected
error=ERROR_INVALID_HANDLE but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- pEmptyWorkingSet(hpSR);
+ EmptyWorkingSet(hpSR);
todo_wine ok(GetLastError() == ERROR_ACCESS_DENIED, "expected
error=ERROR_ACCESS_DENIED but got %d\n", GetLastError());
SetLastError(0xdeadbeef);
- ret = pEmptyWorkingSet(hpAA);
+ ret = EmptyWorkingSet(ws_handle);
ok(ret == 1, "failed with %d\n", GetLastError());
SetLastError( 0xdeadbeef );
- ret = pInitializeProcessForWsWatch( NULL );
+ ret = InitializeProcessForWsWatch( NULL );
todo_wine ok( !ret, "InitializeProcessForWsWatch succeeded\n" );
if (!ret)
{
@@ -726,7 +768,7 @@ static void test_ws_functions(void)
ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n",
GetLastError() );
}
SetLastError(0xdeadbeef);
- ret = pInitializeProcessForWsWatch(hpAA);
+ ret = InitializeProcessForWsWatch(ws_handle);
ok(ret == 1, "failed with %d\n", GetLastError());
addr = VirtualAlloc(NULL, 1, MEM_COMMIT, PAGE_READWRITE);
@@ -741,7 +783,7 @@ static void test_ws_functions(void)
}
SetLastError(0xdeadbeef);
- ret = pQueryWorkingSet(hpQI, pages, 4096 * sizeof(ULONG_PTR));
+ ret = QueryWorkingSet(hpQI, pages, 4096 * sizeof(ULONG_PTR));
todo_wine ok(ret == 1, "failed with %d\n", GetLastError());
if(ret == 1)
{
@@ -757,7 +799,7 @@ static void test_ws_functions(void)
test_gwsc:
SetLastError(0xdeadbeef);
- ret = pGetWsChanges(hpQI, wswi, sizeof(wswi));
+ ret = GetWsChanges(hpQI, wswi, sizeof(wswi));
todo_wine ok(ret == 1, "failed with %d\n", GetLastError());
if(ret == 1)
{
@@ -777,43 +819,35 @@ free_page:
START_TEST(psapi_main)
{
- HMODULE hpsapi = LoadLibraryA("psapi.dll");
+ DWORD pid = GetCurrentProcessId();
- if(!hpsapi)
- {
- win_skip("Could not load psapi.dll\n");
- return;
- }
+ init_func_ptrs();
- if(InitFunctionPtrs(hpsapi))
- {
- DWORD pid = GetCurrentProcessId();
+ if (pIsWow64Process)
+ IsWow64Process(GetCurrentProcess(), &wow64);
hpSR = OpenProcess(STANDARD_RIGHTS_REQUIRED, FALSE, pid);
+ ok(!!hpSR, "got error %u\n", GetLastError());
hpQI = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
+ ok(!!hpQI, "got error %u\n", GetLastError());
hpVR = OpenProcess(PROCESS_VM_READ, FALSE, pid);
+ ok(!!hpVR, "got error %u\n", GetLastError());
hpQV = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
- hpAA = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
-
- if(hpSR && hpQI && hpVR && hpQV && hpAA)
- {
- test_EnumProcesses();
- test_EnumProcessModules();
- test_GetModuleInformation();
- test_GetPerformanceInfo();
- test_GetProcessMemoryInfo();
- test_GetMappedFileName();
- test_GetProcessImageFileName();
- test_GetModuleFileNameEx();
- test_GetModuleBaseName();
- test_ws_functions();
- }
- CloseHandle(hpSR);
- CloseHandle(hpQI);
- CloseHandle(hpVR);
- CloseHandle(hpQV);
- CloseHandle(hpAA);
- }
-
- FreeLibrary(hpsapi);
+ ok(!!hpQV, "got error %u\n", GetLastError());
+
+ test_EnumProcesses();
+ test_EnumProcessModules();
+ test_GetModuleInformation();
+ test_GetPerformanceInfo();
+ test_GetProcessMemoryInfo();
+ test_GetMappedFileName();
+ test_GetProcessImageFileName();
+ test_GetModuleFileNameEx();
+ test_GetModuleBaseName();
+ test_ws_functions();
+
+ CloseHandle(hpSR);
+ CloseHandle(hpQI);
+ CloseHandle(hpVR);
+ CloseHandle(hpQV);
}