Commit bce9cdcc authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

kernel32/tests: Link to more functions directly.

parent 7e564c43
......@@ -29,7 +29,6 @@
#include "oaidl.h"
#include "initguid.h"
static BOOL (WINAPI *pIsDebuggerPresent)(void);
static BOOL (WINAPI *pQueryActCtxSettingsW)(DWORD,HANDLE,LPCWSTR,LPCWSTR,LPWSTR,SIZE_T,SIZE_T*);
static NTSTATUS(NTAPI *pRtlFindActivationContextSectionString)(DWORD,const GUID *,ULONG,PUNICODE_STRING,PACTCTX_SECTION_KEYED_DATA);
......@@ -2016,7 +2015,7 @@ static void test_actctx(void)
test_detailed_info(handle, &detailed_info1, __LINE__);
test_info_in_assembly(handle, 1, &manifest1_info, __LINE__);
if (pIsDebuggerPresent && !pIsDebuggerPresent())
if (!IsDebuggerPresent())
{
/* CloseHandle will generate an exception if a debugger is present */
b = CloseHandle(handle);
......@@ -2714,7 +2713,6 @@ static BOOL init_funcs(void)
HMODULE hLibrary = GetModuleHandleA("kernel32.dll");
#define X(f) if (!(p##f = (void*)GetProcAddress(hLibrary, #f))) return FALSE;
X(IsDebuggerPresent);
pQueryActCtxSettingsW = (void *)GetProcAddress( hLibrary, "QueryActCtxSettingsW" );
hLibrary = GetModuleHandleA("ntdll.dll");
......
......@@ -34,20 +34,17 @@ static CHAR string[MAX_PATH];
static BOOL (WINAPI *pGetComputerNameExA)(COMPUTER_NAME_FORMAT,LPSTR,LPDWORD);
static BOOL (WINAPI *pGetComputerNameExW)(COMPUTER_NAME_FORMAT,LPWSTR,LPDWORD);
static BOOL (WINAPI *pOpenProcessToken)(HANDLE,DWORD,PHANDLE);
static BOOL (WINAPI *pGetUserProfileDirectoryA)(HANDLE,LPSTR,LPDWORD);
static BOOL (WINAPI *pSetEnvironmentStringsW)(WCHAR *);
static void init_functionpointers(void)
{
HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
HMODULE huserenv = LoadLibraryA("userenv.dll");
pGetComputerNameExA = (void *)GetProcAddress(hkernel32, "GetComputerNameExA");
pGetComputerNameExW = (void *)GetProcAddress(hkernel32, "GetComputerNameExW");
pSetEnvironmentStringsW = (void *)GetProcAddress(hkernel32, "SetEnvironmentStringsW");
pOpenProcessToken = (void *)GetProcAddress(hadvapi32, "OpenProcessToken");
pGetUserProfileDirectoryA = (void *)GetProcAddress(huserenv,
"GetUserProfileDirectoryA");
}
......@@ -65,12 +62,12 @@ static void test_Predefined(void)
* Check value of %USERPROFILE%, should be same as GetUserProfileDirectory()
* If this fails, your test environment is probably not set up
*/
if (pOpenProcessToken == NULL || pGetUserProfileDirectoryA == NULL)
if (pGetUserProfileDirectoryA == NULL)
{
skip("Skipping USERPROFILE check\n");
return;
}
NoErr = pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token);
NoErr = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token);
ok(NoErr, "Failed to open token, error %u\n", GetLastError());
DataSize = sizeof(Data);
NoErr = pGetUserProfileDirectoryA(Token, Data, &DataSize);
......
......@@ -38,11 +38,9 @@
#undef DeleteFile /* needed for FILE_DISPOSITION_INFO */
static HANDLE (WINAPI *pFindFirstFileExA)(LPCSTR,FINDEX_INFO_LEVELS,LPVOID,FINDEX_SEARCH_OPS,LPVOID,DWORD);
static BOOL (WINAPI *pReplaceFileA)(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID);
static BOOL (WINAPI *pReplaceFileW)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID);
static UINT (WINAPI *pGetSystemWindowsDirectoryA)(LPSTR, UINT);
static BOOL (WINAPI *pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD);
static DWORD (WINAPI *pQueueUserAPC)(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData);
static BOOL (WINAPI *pGetFileInformationByHandleEx)(HANDLE, FILE_INFO_BY_HANDLE_CLASS, LPVOID, DWORD);
static HANDLE (WINAPI *pOpenFileById)(HANDLE, LPFILE_ID_DESCRIPTOR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD);
static BOOL (WINAPI *pSetFileValidData)(HANDLE, LONGLONG);
......@@ -95,11 +93,9 @@ static void InitFunctionPointers(void)
pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
pFindFirstFileExA=(void*)GetProcAddress(hkernel32, "FindFirstFileExA");
pReplaceFileA=(void*)GetProcAddress(hkernel32, "ReplaceFileA");
pReplaceFileW=(void*)GetProcAddress(hkernel32, "ReplaceFileW");
pGetSystemWindowsDirectoryA=(void*)GetProcAddress(hkernel32, "GetSystemWindowsDirectoryA");
pGetVolumeNameForVolumeMountPointA = (void *) GetProcAddress(hkernel32, "GetVolumeNameForVolumeMountPointA");
pQueueUserAPC = (void *) GetProcAddress(hkernel32, "QueueUserAPC");
pGetFileInformationByHandleEx = (void *) GetProcAddress(hkernel32, "GetFileInformationByHandleEx");
pOpenFileById = (void *) GetProcAddress(hkernel32, "OpenFileById");
pSetFileValidData = (void *) GetProcAddress(hkernel32, "SetFileValidData");
......@@ -3149,11 +3145,8 @@ static void test_read_write(void)
ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %d\n", GetLastError());
user_apc_ran = FALSE;
if (pQueueUserAPC) {
trace("Queueing an user APC\n"); /* verify the file is non alerable */
ret = pQueueUserAPC(&user_apc, GetCurrentThread(), 0);
ok(ret, "QueueUserAPC failed: %d\n", GetLastError());
}
ret = QueueUserAPC(&user_apc, GetCurrentThread(), 0);
ok(ret, "QueueUserAPC failed: %d\n", GetLastError());
SetLastError(12345678);
bytes = 12345678;
......@@ -3192,8 +3185,7 @@ static void test_read_write(void)
ok(!bytes, "bytes = %d\n", bytes);
ok(user_apc_ran == FALSE, "UserAPC ran, file using alertable io mode\n");
if (pQueueUserAPC)
SleepEx(0, TRUE); /* get rid of apc */
SleepEx(0, TRUE); /* get rid of apc */
/* test passing protected memory as buffer */
......@@ -3593,12 +3585,6 @@ static void test_ReplaceFileA(void)
BOOL retok, removeBackup = FALSE;
char **argv;
if (!pReplaceFileA)
{
win_skip("ReplaceFileA() is missing\n");
return;
}
ret = GetTempPathA(MAX_PATH, temp_path);
ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
......@@ -3664,7 +3650,7 @@ static void test_ReplaceFileA(void)
* TODO: flags are not implemented
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ret = ReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ok(ret, "ReplaceFileA: unexpected error %d\n", GetLastError());
/* make sure that the backup has the size of the old "replaced" file */
hBackupFile = CreateFileA(backup, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
......@@ -3710,7 +3696,7 @@ static void test_ReplaceFileA(void)
* TODO: flags are not implemented
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"ReplaceFileA: unexpected error %d\n", GetLastError());
......@@ -3724,7 +3710,7 @@ static void test_ReplaceFileA(void)
* TODO: flags are not implemented
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ret = ReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
"ReplaceFileA: unexpected error %d\n", GetLastError());
if (ret)
......@@ -3741,7 +3727,7 @@ static void test_ReplaceFileA(void)
* TODO: flags are not implemented
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ret = ReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ok(ret == 0 && GetLastError() == ERROR_ACCESS_DENIED, "ReplaceFileA: unexpected error %d\n", GetLastError());
/* make sure that the replacement file still exists */
hReplacementFile = CreateFileA(replacement, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
......@@ -3759,7 +3745,7 @@ static void test_ReplaceFileA(void)
ok(ret != 0, "GetTempFileNameA error (replacement) %#x\n", GetLastError());
ret = SetFileAttributesA(replacement, FILE_ATTRIBUTE_READONLY);
ok(ret, "SetFileAttributesA: error setting to readonly %#x\n", GetLastError());
ret = pReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ok(GetLastError() == ERROR_ACCESS_DENIED, "ReplaceFileA: unexpected error %#x\n", GetLastError());
ret = SetFileAttributesA(replacement, FILE_ATTRIBUTE_NORMAL);
ok(ret, "SetFileAttributesA: error setting to normal %#x\n", GetLastError());
......@@ -3777,7 +3763,7 @@ static void test_ReplaceFileA(void)
ok(hReplacedFile != INVALID_HANDLE_VALUE,
"unexpected error, replaced file should be able to be opened %d\n", GetLastError());
/*Calling ReplaceFileA on an exe should succeed*/
ret = pReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ok(ret, "ReplaceFileA: unexpected error %d\n", GetLastError());
CloseHandle(hReplacedFile);
......@@ -3787,7 +3773,7 @@ static void test_ReplaceFileA(void)
hReplacementFile = CreateFileA(replacement, GENERIC_READ | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, 0);
ok(hReplacementFile != INVALID_HANDLE_VALUE, "unexpected error, replacement file should be able to be opened %d\n",
GetLastError());
ret = pReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ok(!ret, "expect failure\n");
ok(GetLastError() == ERROR_SHARING_VIOLATION, "expect ERROR_SHARING_VIOLATION, got %#x.\n", GetLastError());
CloseHandle(hReplacementFile);
......@@ -3800,7 +3786,7 @@ static void test_ReplaceFileA(void)
* TODO: flags are not implemented
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ret = ReplaceFileA(replaced, replacement, backup, 0, 0, 0);
ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == ERROR_ACCESS_DENIED),
"ReplaceFileA: unexpected error %d\n", GetLastError());
......@@ -3809,7 +3795,7 @@ static void test_ReplaceFileA(void)
* TODO: flags are not implemented
*/
SetLastError(0xdeadbeef);
ret = pReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == ERROR_ACCESS_DENIED),
"ReplaceFileA: unexpected error %d\n", GetLastError());
......
......@@ -36,7 +36,6 @@
static HANDLE alarm_event;
static BOOL (WINAPI *pDuplicateTokenEx)(HANDLE,DWORD,LPSECURITY_ATTRIBUTES,
SECURITY_IMPERSONATION_LEVEL,TOKEN_TYPE,PHANDLE);
static DWORD (WINAPI *pQueueUserAPC)(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData);
static BOOL (WINAPI *pCancelIoEx)(HANDLE handle, LPOVERLAPPED lpOverlapped);
static BOOL (WINAPI *pGetNamedPipeClientProcessId)(HANDLE,ULONG*);
static BOOL (WINAPI *pGetNamedPipeServerProcessId)(HANDLE,ULONG*);
......@@ -908,9 +907,10 @@ static DWORD CALLBACK serverThreadMain2(LPVOID arg)
user_apc_ran = FALSE;
if (i == 0 && pQueueUserAPC) {
if (i == 0)
{
if (winetest_debug > 1) trace("Queueing an user APC\n"); /* verify the pipe is non alerable */
ret = pQueueUserAPC(&user_apc, GetCurrentThread(), 0);
ret = QueueUserAPC(&user_apc, GetCurrentThread(), 0);
ok(ret, "QueueUserAPC failed: %d\n", GetLastError());
}
......@@ -939,7 +939,7 @@ static DWORD CALLBACK serverThreadMain2(LPVOID arg)
ok(user_apc_ran == FALSE, "UserAPC ran, pipe using alertable io mode\n");
if (i == 0 && pQueueUserAPC)
if (i == 0)
SleepEx(0, TRUE); /* get rid of apc */
/* Set up next echo server */
......@@ -1530,8 +1530,7 @@ static void test_CreatePipe(void)
char readbuf[32];
user_apc_ran = FALSE;
if (pQueueUserAPC)
ok(pQueueUserAPC(user_apc, GetCurrentThread(), 0), "couldn't create user apc\n");
ok(QueueUserAPC(user_apc, GetCurrentThread(), 0), "couldn't create user apc\n");
pipe_attr.nLength = sizeof(SECURITY_ATTRIBUTES);
pipe_attr.bInheritHandle = TRUE;
......@@ -4126,7 +4125,6 @@ START_TEST(pipe)
hmod = GetModuleHandleA("advapi32.dll");
pDuplicateTokenEx = (void *) GetProcAddress(hmod, "DuplicateTokenEx");
hmod = GetModuleHandleA("kernel32.dll");
pQueueUserAPC = (void *) GetProcAddress(hmod, "QueueUserAPC");
pCancelIoEx = (void *) GetProcAddress(hmod, "CancelIoEx");
pGetNamedPipeClientProcessId = (void *) GetProcAddress(hmod, "GetNamedPipeClientProcessId");
pGetNamedPipeServerProcessId = (void *) GetProcAddress(hmod, "GetNamedPipeServerProcessId");
......
......@@ -67,8 +67,6 @@ static void (WINAPI *pGetNativeSystemInfo)(LPSYSTEM_INFO);
static BOOL (WINAPI *pGetSystemRegistryQuota)(PDWORD, PDWORD);
static BOOL (WINAPI *pIsWow64Process)(HANDLE,PBOOL);
static BOOL (WINAPI *pIsWow64Process2)(HANDLE, USHORT *, USHORT *);
static LPVOID (WINAPI *pVirtualAllocEx)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD);
static BOOL (WINAPI *pVirtualFreeEx)(HANDLE, LPVOID, SIZE_T, DWORD);
static BOOL (WINAPI *pQueryFullProcessImageNameA)(HANDLE hProcess, DWORD dwFlags, LPSTR lpExeName, PDWORD lpdwSize);
static BOOL (WINAPI *pQueryFullProcessImageNameW)(HANDLE hProcess, DWORD dwFlags, LPWSTR lpExeName, PDWORD lpdwSize);
static DWORD (WINAPI *pK32GetProcessImageFileNameA)(HANDLE,LPSTR,DWORD);
......@@ -81,7 +79,6 @@ static BOOL (WINAPI *pSetInformationJobObject)(HANDLE job, JOBOBJECTINFOCLASS
static HANDLE (WINAPI *pCreateIoCompletionPort)(HANDLE file, HANDLE existing_port, ULONG_PTR key, DWORD threads);
static BOOL (WINAPI *pGetNumaProcessorNode)(UCHAR, PUCHAR);
static NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
static BOOL (WINAPI *pProcessIdToSessionId)(DWORD,DWORD*);
static DWORD (WINAPI *pWTSGetActiveConsoleSessionId)(void);
static HANDLE (WINAPI *pCreateToolhelp32Snapshot)(DWORD, DWORD);
static BOOL (WINAPI *pProcess32First)(HANDLE, PROCESSENTRY32*);
......@@ -251,8 +248,6 @@ static BOOL init(void)
pGetSystemRegistryQuota = (void *) GetProcAddress(hkernel32, "GetSystemRegistryQuota");
pIsWow64Process = (void *) GetProcAddress(hkernel32, "IsWow64Process");
pIsWow64Process2 = (void *) GetProcAddress(hkernel32, "IsWow64Process2");
pVirtualAllocEx = (void *) GetProcAddress(hkernel32, "VirtualAllocEx");
pVirtualFreeEx = (void *) GetProcAddress(hkernel32, "VirtualFreeEx");
pQueryFullProcessImageNameA = (void *) GetProcAddress(hkernel32, "QueryFullProcessImageNameA");
pQueryFullProcessImageNameW = (void *) GetProcAddress(hkernel32, "QueryFullProcessImageNameW");
pK32GetProcessImageFileNameA = (void *) GetProcAddress(hkernel32, "K32GetProcessImageFileNameA");
......@@ -264,7 +259,6 @@ static BOOL init(void)
pSetInformationJobObject = (void *)GetProcAddress(hkernel32, "SetInformationJobObject");
pCreateIoCompletionPort = (void *)GetProcAddress(hkernel32, "CreateIoCompletionPort");
pGetNumaProcessorNode = (void *)GetProcAddress(hkernel32, "GetNumaProcessorNode");
pProcessIdToSessionId = (void *)GetProcAddress(hkernel32, "ProcessIdToSessionId");
pWTSGetActiveConsoleSessionId = (void *)GetProcAddress(hkernel32, "WTSGetActiveConsoleSessionId");
pCreateToolhelp32Snapshot = (void *)GetProcAddress(hkernel32, "CreateToolhelp32Snapshot");
pProcess32First = (void *)GetProcAddress(hkernel32, "Process32First");
......@@ -1714,18 +1708,12 @@ static void test_OpenProcess(void)
SIZE_T dummy, read_bytes;
BOOL ret;
/* not exported in all windows versions */
if ((!pVirtualAllocEx) || (!pVirtualFreeEx)) {
win_skip("VirtualAllocEx not found\n");
return;
}
/* without PROCESS_VM_OPERATION */
hproc = OpenProcess(PROCESS_ALL_ACCESS_NT4 & ~PROCESS_VM_OPERATION, FALSE, GetCurrentProcessId());
ok(hproc != NULL, "OpenProcess error %d\n", GetLastError());
SetLastError(0xdeadbeef);
addr1 = pVirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
addr1 = VirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
ok(!addr1, "VirtualAllocEx should fail\n");
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{ /* Win9x */
......@@ -1746,7 +1734,7 @@ static void test_OpenProcess(void)
hproc = OpenProcess(PROCESS_VM_OPERATION, FALSE, GetCurrentProcessId());
ok(hproc != NULL, "OpenProcess error %d\n", GetLastError());
addr1 = pVirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
addr1 = VirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
ok(addr1 != NULL, "VirtualAllocEx error %d\n", GetLastError());
/* without PROCESS_QUERY_INFORMATION */
......@@ -1783,7 +1771,7 @@ static void test_OpenProcess(void)
ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
SetLastError(0xdeadbeef);
ok(!pVirtualFreeEx(hproc, addr1, 0, MEM_RELEASE),
ok(!VirtualFreeEx(hproc, addr1, 0, MEM_RELEASE),
"VirtualFreeEx without PROCESS_VM_OPERATION rights should fail\n");
ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
......@@ -1810,7 +1798,7 @@ static void test_OpenProcess(void)
ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
SetLastError(0xdeadbeef);
ok(!pVirtualFreeEx(hproc, addr1, 0, MEM_RELEASE),
ok(!VirtualFreeEx(hproc, addr1, 0, MEM_RELEASE),
"VirtualFreeEx without PROCESS_VM_OPERATION rights should fail\n");
ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
......@@ -3564,13 +3552,7 @@ static void test_session_info(void)
DWORD session_id, active_session;
BOOL r;
if (!pProcessIdToSessionId)
{
win_skip("ProcessIdToSessionId is missing\n");
return;
}
r = pProcessIdToSessionId(GetCurrentProcessId(), &session_id);
r = ProcessIdToSessionId(GetCurrentProcessId(), &session_id);
ok(r, "ProcessIdToSessionId failed: %u\n", GetLastError());
trace("session_id = %x\n", session_id);
......
......@@ -26,43 +26,26 @@
static void test_timer(void)
{
HANDLE (WINAPI *pCreateWaitableTimerA)( SECURITY_ATTRIBUTES*, BOOL, LPSTR );
BOOL (WINAPI *pSetWaitableTimer)(HANDLE, LARGE_INTEGER*, LONG, PTIMERAPCROUTINE, LPVOID, BOOL);
HMODULE hker = GetModuleHandleA("kernel32.dll");
HANDLE handle;
BOOL r;
LARGE_INTEGER due;
pCreateWaitableTimerA = (void*)GetProcAddress( hker, "CreateWaitableTimerA");
if( !pCreateWaitableTimerA )
{
win_skip("CreateWaitableTimerA is not available\n");
return;
}
pSetWaitableTimer = (void*)GetProcAddress( hker, "SetWaitableTimer");
if( !pSetWaitableTimer )
{
win_skip("SetWaitableTimer is not available\n");
return;
}
/* try once with a positive number */
handle = pCreateWaitableTimerA( NULL, 0, NULL );
handle = CreateWaitableTimerA( NULL, 0, NULL );
ok( handle != NULL, "failed to create waitable timer with no name\n" );
due.QuadPart = 10000;
r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
r = SetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
ok( r, "failed to set timer\n");
CloseHandle( handle );
/* try once with a negative number */
handle = pCreateWaitableTimerA( NULL, 0, NULL );
handle = CreateWaitableTimerA( NULL, 0, NULL );
ok( handle != NULL, "failed to create waitable timer with no name\n" );
due.QuadPart = -10000;
r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
r = SetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
ok( r, "failed to set timer\n");
CloseHandle( handle );
......
......@@ -37,8 +37,6 @@
static HINSTANCE hkernel32, hntdll;
static SYSTEM_INFO si;
static LPVOID (WINAPI *pVirtualAllocEx)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD);
static BOOL (WINAPI *pVirtualFreeEx)(HANDLE, LPVOID, SIZE_T, DWORD);
static UINT (WINAPI *pGetWriteWatch)(DWORD,LPVOID,SIZE_T,LPVOID*,ULONG_PTR*,ULONG*);
static UINT (WINAPI *pResetWriteWatch)(LPVOID,SIZE_T);
static NTSTATUS (WINAPI *pNtAreMappedFilesTheSame)(PVOID,PVOID);
......@@ -84,17 +82,11 @@ static void test_VirtualAllocEx(void)
MEMORY_BASIC_INFORMATION info;
HANDLE hProcess;
/* not exported in all windows-versions */
if ((!pVirtualAllocEx) || (!pVirtualFreeEx)) {
win_skip("Virtual{Alloc,Free}Ex not available\n");
return;
}
hProcess = create_target_process("sleep");
ok(hProcess != NULL, "Can't start process\n");
SetLastError(0xdeadbeef);
addr1 = pVirtualAllocEx(hProcess, NULL, alloc_size, MEM_COMMIT,
addr1 = VirtualAllocEx(hProcess, NULL, alloc_size, MEM_COMMIT,
PAGE_EXECUTE_READWRITE);
ok(addr1 != NULL, "VirtualAllocEx error %u\n", GetLastError());
......@@ -144,7 +136,7 @@ static void test_VirtualAllocEx(void)
if (GetLastError() == ERROR_NOACCESS)
ok( bytes_read == 0, "%lu bytes written\n", bytes_read );
b = pVirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE);
b = VirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE);
ok(b != 0, "VirtualFreeEx, error %u\n", GetLastError());
VirtualFree( src, 0, MEM_RELEASE );
......@@ -155,12 +147,12 @@ static void test_VirtualAllocEx(void)
*/
SetLastError(0xdeadbeef);
addr1 = pVirtualAllocEx(hProcess, 0, 0, MEM_RESERVE, PAGE_NOACCESS);
addr1 = VirtualAllocEx(hProcess, 0, 0, MEM_RESERVE, PAGE_NOACCESS);
ok(addr1 == NULL, "VirtualAllocEx should fail on zero-sized allocation\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
addr1 = pVirtualAllocEx(hProcess, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
addr1 = VirtualAllocEx(hProcess, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
ok(addr1 != NULL, "VirtualAllocEx failed\n");
/* test a not committed memory */
......@@ -180,7 +172,7 @@ static void test_VirtualAllocEx(void)
ok(GetLastError() == ERROR_INVALID_ADDRESS,
"got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
addr2 = pVirtualAllocEx(hProcess, addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
addr2 = VirtualAllocEx(hProcess, addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
ok(addr1 == addr2, "VirtualAllocEx failed\n");
/* test a committed memory */
......@@ -210,20 +202,20 @@ static void test_VirtualAllocEx(void)
ok(VirtualProtectEx(hProcess, addr1, 0x1000, PAGE_READWRITE, &old_prot), "VirtualProtectEx failed\n");
ok(old_prot == PAGE_READONLY, "wrong old protection: got %04x instead of PAGE_READONLY\n", old_prot);
ok(!pVirtualFreeEx(hProcess, addr1, 0x10000, 0),
ok(!VirtualFreeEx(hProcess, addr1, 0x10000, 0),
"VirtualFreeEx should fail with type 0\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
ok(pVirtualFreeEx(hProcess, addr1, 0x10000, MEM_DECOMMIT), "VirtualFreeEx failed\n");
ok(VirtualFreeEx(hProcess, addr1, 0x10000, MEM_DECOMMIT), "VirtualFreeEx failed\n");
/* if the type is MEM_RELEASE, size must be 0 */
ok(!pVirtualFreeEx(hProcess, addr1, 1, MEM_RELEASE),
ok(!VirtualFreeEx(hProcess, addr1, 1, MEM_RELEASE),
"VirtualFreeEx should fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
ok(pVirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE), "VirtualFreeEx failed\n");
ok(VirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE), "VirtualFreeEx failed\n");
TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
......@@ -4249,8 +4241,6 @@ START_TEST(virtual)
hkernel32 = GetModuleHandleA("kernel32.dll");
hntdll = GetModuleHandleA("ntdll.dll");
pVirtualAllocEx = (void *) GetProcAddress(hkernel32, "VirtualAllocEx");
pVirtualFreeEx = (void *) GetProcAddress(hkernel32, "VirtualFreeEx");
pGetWriteWatch = (void *) GetProcAddress(hkernel32, "GetWriteWatch");
pResetWriteWatch = (void *) GetProcAddress(hkernel32, "ResetWriteWatch");
pGetProcessDEPPolicy = (void *)GetProcAddress( hkernel32, "GetProcessDEPPolicy" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment