Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/kernel32/tests/process.c | 2 +- include/winternl.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index b0371c615e6..8996dd91446 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -3685,7 +3685,7 @@ static void test_process_info(HANDLE hproc) case ProcessPriorityClass: case ProcessPriorityBoost: case ProcessLUIDDeviceMapsEnabled: - case 33 /* ProcessIoPriority */: + case ProcessIoPriority: case ProcessIoCounters: case ProcessVmCounters: case ProcessWow64Information: diff --git a/include/winternl.h b/include/winternl.h index e23a02b9b26..20b2a44ba20 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -1153,6 +1153,7 @@ typedef enum _PROCESSINFOCLASS { ProcessDebugObjectHandle = 30, ProcessDebugFlags = 31, ProcessHandleTracing = 32, + ProcessIoPriority = 33, ProcessExecuteFlags = 34, ProcessTlsInformation = 35, ProcessCookie = 36,
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
Only changed functions that are already used directly in other kernel32 tests.
dlls/kernel32/tests/actctx.c | 4 +- dlls/kernel32/tests/environ.c | 7 +-- dlls/kernel32/tests/file.c | 38 ++++-------- dlls/kernel32/tests/pipe.c | 12 ++-- dlls/kernel32/tests/process.c | 28 ++------- dlls/kernel32/tests/timer.c | 25 ++------ dlls/kernel32/tests/virtual.c | 28 +++------ dlls/kernel32/tests/volume.c | 107 +++++++++++----------------------- 8 files changed, 71 insertions(+), 178 deletions(-)
diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c index 1bcb25a53fa..4a9adc15748 100644 --- a/dlls/kernel32/tests/actctx.c +++ b/dlls/kernel32/tests/actctx.c @@ -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"); diff --git a/dlls/kernel32/tests/environ.c b/dlls/kernel32/tests/environ.c index 1f69594fcd3..d19b8700c5f 100644 --- a/dlls/kernel32/tests/environ.c +++ b/dlls/kernel32/tests/environ.c @@ -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); diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index ec0e923706c..9327d0319dd 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -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()); diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index 3c7ca06a045..91f6df34f81 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -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"); diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index 8996dd91446..486363956b1 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -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);
diff --git a/dlls/kernel32/tests/timer.c b/dlls/kernel32/tests/timer.c index 5e4bab47894..7efcdef6563 100644 --- a/dlls/kernel32/tests/timer.c +++ b/dlls/kernel32/tests/timer.c @@ -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 ); diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index f576d132d8b..854d3e04e19 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -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" ); diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c index 6f09be154ee..ead06764a11 100644 --- a/dlls/kernel32/tests/volume.c +++ b/dlls/kernel32/tests/volume.c @@ -48,15 +48,11 @@ struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR C_ASSERT(sizeof(struct COMPLETE_DVD_MANUFACTURER_DESCRIPTOR) == 2053);
static HINSTANCE hdll; -static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD); -static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD); static HANDLE (WINAPI *pFindFirstVolumeA)(LPSTR,DWORD); static BOOL (WINAPI *pFindNextVolumeA)(HANDLE,LPSTR,DWORD); static BOOL (WINAPI *pFindVolumeClose)(HANDLE); static UINT (WINAPI *pGetLogicalDriveStringsA)(UINT,LPSTR); static UINT (WINAPI *pGetLogicalDriveStringsW)(UINT,LPWSTR); -static BOOL (WINAPI *pGetVolumeInformationA)(LPCSTR, LPSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPSTR, DWORD); -static BOOL (WINAPI *pGetVolumePathNameA)(LPCSTR, LPSTR, DWORD); static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameA)(LPCSTR, LPSTR, DWORD, LPDWORD); static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameW)(LPCWSTR, LPWSTR, DWORD, LPDWORD); static BOOL (WINAPI *pCreateSymbolicLinkA)(const char *, const char *, DWORD); @@ -229,38 +225,32 @@ static void test_GetVolumeNameForVolumeMountPointA(void) DWORD len = sizeof(volume), reti; char temp_path[MAX_PATH];
- /* not present before w2k */ - if (!pGetVolumeNameForVolumeMountPointA) { - win_skip("GetVolumeNameForVolumeMountPointA not found\n"); - return; - } - reti = GetTempPathA(MAX_PATH, temp_path); ok(reti != 0, "GetTempPathA error %d\n", GetLastError()); ok(reti < MAX_PATH, "temp path should fit into MAX_PATH\n");
- ret = pGetVolumeNameForVolumeMountPointA(path, volume, 0); + ret = GetVolumeNameForVolumeMountPointA(path, volume, 0); ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n"); ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE || GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */ "wrong error, last=%d\n", GetLastError());
if (0) { /* these crash on XP */ - ret = pGetVolumeNameForVolumeMountPointA(path, NULL, len); + ret = GetVolumeNameForVolumeMountPointA(path, NULL, len); ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
- ret = pGetVolumeNameForVolumeMountPointA(NULL, volume, len); + ret = GetVolumeNameForVolumeMountPointA(NULL, volume, len); ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n"); }
- ret = pGetVolumeNameForVolumeMountPointA(path, volume, len); + ret = GetVolumeNameForVolumeMountPointA(path, volume, len); ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n"); ok(!strncmp( volume, "\\?\Volume{", 11), "GetVolumeNameForVolumeMountPointA failed to return valid string <%s>\n", volume);
/* test with too small buffer */ - ret = pGetVolumeNameForVolumeMountPointA(path, volume, 10); + ret = GetVolumeNameForVolumeMountPointA(path, volume, 10); ok(ret == FALSE && GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumeNameForVolumeMountPointA failed, wrong error returned, was %d, should be ERROR_FILENAME_EXCED_RANGE\n", GetLastError()); @@ -268,7 +258,7 @@ static void test_GetVolumeNameForVolumeMountPointA(void) /* Try on an arbitrary directory */ /* On FAT filesystems it seems that GetLastError() is set to ERROR_INVALID_FUNCTION. */ - ret = pGetVolumeNameForVolumeMountPointA(temp_path, volume, len); + ret = GetVolumeNameForVolumeMountPointA(temp_path, volume, len); ok(ret == FALSE && (GetLastError() == ERROR_NOT_A_REPARSE_POINT || GetLastError() == ERROR_INVALID_FUNCTION), "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n", @@ -283,14 +273,14 @@ static void test_GetVolumeNameForVolumeMountPointA(void) if (path[0] <= 'z') { path[2] = '\'; - ret = pGetVolumeNameForVolumeMountPointA(path, volume, len); + ret = GetVolumeNameForVolumeMountPointA(path, volume, len); ok(ret == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND, "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n", path, GetLastError());
/* Try without trailing \ and on a nonexistent dos drive */ path[2] = 0; - ret = pGetVolumeNameForVolumeMountPointA(path, volume, len); + ret = GetVolumeNameForVolumeMountPointA(path, volume, len); ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n", path, GetLastError()); @@ -303,27 +293,21 @@ static void test_GetVolumeNameForVolumeMountPointW(void) WCHAR volume[MAX_PATH], path[] = {'c',':','\',0}; DWORD len = ARRAY_SIZE(volume);
- /* not present before w2k */ - if (!pGetVolumeNameForVolumeMountPointW) { - win_skip("GetVolumeNameForVolumeMountPointW not found\n"); - return; - } - - ret = pGetVolumeNameForVolumeMountPointW(path, volume, 0); + ret = GetVolumeNameForVolumeMountPointW(path, volume, 0); ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n"); ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE || GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */ "wrong error, last=%d\n", GetLastError());
if (0) { /* these crash on XP */ - ret = pGetVolumeNameForVolumeMountPointW(path, NULL, len); + ret = GetVolumeNameForVolumeMountPointW(path, NULL, len); ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
- ret = pGetVolumeNameForVolumeMountPointW(NULL, volume, len); + ret = GetVolumeNameForVolumeMountPointW(NULL, volume, len); ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n"); }
- ret = pGetVolumeNameForVolumeMountPointW(path, volume, len); + ret = GetVolumeNameForVolumeMountPointW(path, volume, len); ok(ret == TRUE, "GetVolumeNameForVolumeMountPointW failed\n"); }
@@ -413,11 +397,6 @@ static void test_GetVolumeInformationA(void) char windowsdir[MAX_PATH+10]; char currentdir[MAX_PATH+1];
- ok( pGetVolumeInformationA != NULL, "GetVolumeInformationA not found\n"); - if(!pGetVolumeInformationA) { - return; - } - /* get windows drive letter and update strings for testing */ result = GetWindowsDirectoryA(windowsdir, sizeof(windowsdir)); ok(result < sizeof(windowsdir), "windowsdir is abnormally long!\n"); @@ -433,7 +412,7 @@ static void test_GetVolumeInformationA(void) /* check for NO error on no trailing \ when current dir is root dir */ ret = SetCurrentDirectoryA(Root_Slash); ok(ret, "SetCurrentDirectory: error %d\n", GetLastError()); - ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, + ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, NULL, NULL, fs_name_buf, fs_name_len); ok(ret, "GetVolumeInformationA root failed, last error %u\n", GetLastError());
@@ -441,7 +420,7 @@ static void test_GetVolumeInformationA(void) ret = SetCurrentDirectoryA(windowsdir); ok(ret, "SetCurrentDirectory: error %d\n", GetLastError()); SetLastError(0xdeadbeef); - ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, + ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, NULL, NULL, fs_name_buf, fs_name_len); ok(!ret && (GetLastError() == ERROR_INVALID_NAME), "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError()); @@ -469,13 +448,13 @@ static void test_GetVolumeInformationA(void)
/* windows dir is current on the root drive, call fails */ SetLastError(0xdeadbeef); - ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, + ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, NULL, NULL, fs_name_buf, fs_name_len); ok(!ret && (GetLastError() == ERROR_INVALID_NAME), "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
/* Try normal drive letter with trailing \ */ - ret = pGetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size, NULL, + ret = GetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size, NULL, NULL, NULL, fs_name_buf, fs_name_len); ok(ret, "GetVolumeInformationA with \ failed, last error %u\n", GetLastError());
@@ -487,7 +466,7 @@ static void test_GetVolumeInformationA(void) /* windows dir is STILL CURRENT on root drive; the call fails as before, */ /* proving that SetCurrentDir did not remember the other drive's directory */ SetLastError(0xdeadbeef); - ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, + ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, NULL, NULL, fs_name_buf, fs_name_len); ok(!ret && (GetLastError() == ERROR_INVALID_NAME), "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError()); @@ -497,7 +476,7 @@ static void test_GetVolumeInformationA(void) ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
/* \ is current on root drive, call succeeds */ - ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, + ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, NULL, NULL, fs_name_buf, fs_name_len); ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
@@ -508,59 +487,55 @@ static void test_GetVolumeInformationA(void) ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
/* \ is current on root drive, call succeeds */ - ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, + ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL, NULL, NULL, fs_name_buf, fs_name_len); ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError()); }
/* try null root directory to return "root of the current directory" */ - ret = pGetVolumeInformationA(NULL, vol_name_buf, vol_name_size, NULL, + ret = GetVolumeInformationA(NULL, vol_name_buf, vol_name_size, NULL, NULL, NULL, fs_name_buf, fs_name_len); ok(ret, "GetVolumeInformationA failed on null root dir, last error %u\n", GetLastError());
/* Try normal drive letter with trailing \ */ - ret = pGetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size, + ret = GetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size, &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len); ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Slash, GetLastError());
/* try again with drive letter and the "disable parsing" prefix */ SetLastError(0xdeadbeef); - ret = pGetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size, + ret = GetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size, &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len); ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
/* try again with device name space */ Root_UNC[2] = '.'; SetLastError(0xdeadbeef); - ret = pGetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size, + ret = GetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size, &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len); ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
/* try again with a directory off the root - should generate error */ if (windowsdir[strlen(windowsdir)-1] != '\') strcat(windowsdir, "\"); SetLastError(0xdeadbeef); - ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size, + ret = GetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size, &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len); ok(!ret && (GetLastError()==ERROR_DIR_NOT_ROOT), "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError()); /* A subdir with trailing \ yields DIR_NOT_ROOT instead of INVALID_NAME */ if (windowsdir[strlen(windowsdir)-1] == '\') windowsdir[strlen(windowsdir)-1] = 0; SetLastError(0xdeadbeef); - ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size, + ret = GetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size, &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len); ok(!ret && (GetLastError()==ERROR_INVALID_NAME), "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
- if (!pGetVolumeNameForVolumeMountPointA) { - win_skip("GetVolumeNameForVolumeMountPointA not found\n"); - return; - } /* get the unique volume name for the windows drive */ - ret = pGetVolumeNameForVolumeMountPointA(Root_Slash, volume, MAX_PATH); + ret = GetVolumeNameForVolumeMountPointA(Root_Slash, volume, MAX_PATH); ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
/* try again with unique volume name */ - ret = pGetVolumeInformationA(volume, vol_name_buf, vol_name_size, + ret = GetVolumeInformationA(volume, vol_name_buf, vol_name_size, &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len); ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume, GetLastError()); } @@ -578,11 +553,6 @@ static void test_enum_vols(void) BOOL found = FALSE; char windowsdir[MAX_PATH];
- if (!pGetVolumeNameForVolumeMountPointA) { - win_skip("GetVolumeNameForVolumeMountPointA not found\n"); - return; - } - /*get windows drive letter and update strings for testing */ ret = GetWindowsDirectoryA( windowsdir, sizeof(windowsdir) ); ok(ret < sizeof(windowsdir), "windowsdir is abnormally long!\n"); @@ -590,7 +560,7 @@ static void test_enum_vols(void) path[0] = windowsdir[0];
/* get the unique volume name for the windows drive */ - ret = pGetVolumeNameForVolumeMountPointA( path, Volume_1, MAX_PATH ); + ret = GetVolumeNameForVolumeMountPointA( path, Volume_1, MAX_PATH ); ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n"); ok(strlen(Volume_1) == 49, "GetVolumeNameForVolumeMountPointA returned wrong length name %s\n", Volume_1);
@@ -843,13 +813,6 @@ static void test_GetVolumePathNameA(void) DWORD error; UINT i;
- /* GetVolumePathNameA is not present before w2k */ - if (!pGetVolumePathNameA) - { - win_skip("required functions not found\n"); - return; - } - for (i=0; i<ARRAY_SIZE(test_paths); i++) { BOOL broken_ret = test_paths[i].broken_error == NO_ERROR; @@ -861,7 +824,7 @@ static void test_GetVolumePathNameA(void) volume_path[ test_paths[i].path_len ] = 0x11;
SetLastError( 0xdeadbeef ); - ret = pGetVolumePathNameA( test_paths[i].file_name, output, test_paths[i].path_len ); + ret = GetVolumePathNameA( test_paths[i].file_name, output, test_paths[i].path_len ); error = GetLastError(); ok(ret == expected_ret || broken(ret == broken_ret), "GetVolumePathName test %d %s unexpectedly.\n", @@ -973,13 +936,13 @@ static void test_GetVolumePathNamesForVolumeNameA(void) char volume[MAX_PATH], buffer[MAX_PATH]; DWORD len, error;
- if (!pGetVolumePathNamesForVolumeNameA || !pGetVolumeNameForVolumeMountPointA) + if (!pGetVolumePathNamesForVolumeNameA) { win_skip("required functions not found\n"); return; }
- ret = pGetVolumeNameForVolumeMountPointA( "c:\", volume, sizeof(volume) ); + ret = GetVolumeNameForVolumeMountPointA( "c:\", volume, sizeof(volume) ); ok(ret, "failed to get volume name %u\n", GetLastError()); trace("c:\ -> %s\n", volume);
@@ -1061,13 +1024,13 @@ static void test_GetVolumePathNamesForVolumeNameW(void) WCHAR volume[MAX_PATH], buffer[MAX_PATH]; DWORD len, error;
- if (!pGetVolumePathNamesForVolumeNameW || !pGetVolumeNameForVolumeMountPointW) + if (!pGetVolumePathNamesForVolumeNameW) { win_skip("required functions not found\n"); return; }
- ret = pGetVolumeNameForVolumeMountPointW( drive_c, volume, ARRAY_SIZE(volume) ); + ret = GetVolumeNameForVolumeMountPointW( drive_c, volume, ARRAY_SIZE(volume) ); ok(ret, "failed to get volume name %u\n", GetLastError());
SetLastError( 0xdeadbeef ); @@ -1589,15 +1552,11 @@ static void test_GetVolumeInformationByHandle(void) START_TEST(volume) { hdll = GetModuleHandleA("kernel32.dll"); - pGetVolumeNameForVolumeMountPointA = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointA"); - pGetVolumeNameForVolumeMountPointW = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointW"); pFindFirstVolumeA = (void *) GetProcAddress(hdll, "FindFirstVolumeA"); pFindNextVolumeA = (void *) GetProcAddress(hdll, "FindNextVolumeA"); pFindVolumeClose = (void *) GetProcAddress(hdll, "FindVolumeClose"); pGetLogicalDriveStringsA = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsA"); pGetLogicalDriveStringsW = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsW"); - pGetVolumeInformationA = (void *) GetProcAddress(hdll, "GetVolumeInformationA"); - pGetVolumePathNameA = (void *) GetProcAddress(hdll, "GetVolumePathNameA"); pGetVolumePathNamesForVolumeNameA = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameA"); pGetVolumePathNamesForVolumeNameW = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameW"); pCreateSymbolicLinkA = (void *) GetProcAddress(hdll, "CreateSymbolicLinkA");
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=79119
Your paranoid android.
=== w10pro64_2scr (32 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-7fff-0000-e049-e069a3010000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1 actctx.c:2940: Test failed: Wrong type, got 32767 for 2 actctx.c:2940: Test failed: got wrong clsid {386e4a4a-0001-0000-ff7f-000000000000}, expected {1f676c76-80e1-4239-95bb-83d0f6d0da78} for 4
=== w10pro64_ar (32 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-0000-0000-f0e2-8539ce010000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1
=== w10pro64_he (32 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-0000-0000-201b-c3b3a9010000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1
=== w10pro64_ja (32 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-0000-0000-b045-e0e475010000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1 actctx.c:2940: Test failed: got wrong clsid {2be3e3b0-0062-0000-e328-2f4ab9534144}, expected {8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a} for 3 actctx.c:2940: Test failed: got wrong clsid {386e4a4a-0001-0000-0000-0000b0e3e32b}, expected {1f676c76-80e1-4239-95bb-83d0f6d0da78} for 4 actctx.c:2940: Test failed: Wrong type, got 98 for 4
=== w10pro64_zh_CN (32 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-0000-0000-6088-829802020000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1 actctx.c:2940: Test failed: got wrong clsid {00000000-0000-0000-e328-2f4ab9534144}, expected {8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a} for 3 actctx.c:2940: Test failed: got wrong clsid {386e4a4a-0001-0000-0000-000060170000}, expected {1f676c76-80e1-4239-95bb-83d0f6d0da78} for 4 actctx.c:2940: Test failed: Wrong type, got 0 for 4
=== w10pro64 (64 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00001760-0000-0000-e328-2f4ab9534144}, expected {8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a} for 3
=== w10pro64_2scr (64 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-0000-0000-b045-e069a3010000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1 actctx.c:2940: Test failed: got wrong clsid {386e4a4a-0001-0000-0000-000000000000}, expected {1f676c76-80e1-4239-95bb-83d0f6d0da78} for 4
=== w10pro64_ar (64 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-0000-0000-f0e2-8539ce010000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1
=== w10pro64_he (64 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-0000-0000-303c-c2b3a9010000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1
=== w10pro64_ja (64 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-0000-0000-903a-e2e475010000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1 actctx.c:2940: Test failed: got wrong clsid {e4e02000-0175-0000-e328-2f4ab9534144}, expected {8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a} for 3 actctx.c:2940: Test failed: got wrong clsid {386e4a4a-0001-0000-0000-00000020e0e4}, expected {1f676c76-80e1-4239-95bb-83d0f6d0da78} for 4
=== w10pro64_zh_CN (64 bit report) ===
kernel32: actctx.c:2940: Test failed: got wrong clsid {00000001-0000-0000-6088-829802020000}, expected {35138b9a-5d96-4fbd-8e2d-a2440225f93a} for 1 actctx.c:2940: Test failed: got wrong clsid {386e4a4a-0001-0000-0000-0000c0120000}, expected {1f676c76-80e1-4239-95bb-83d0f6d0da78} for 4
=== debiant (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/kernel32/tests/process.c | 74 ++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 5 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index 486363956b1..a666434035e 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -3900,7 +3900,7 @@ static void test_ProcThreadAttributeList(void) * level 2: Process created by level 1 process with handle inheritance and level 0 * process parent substitute. * level 255: Process created by level 1 process during invalid parent handles testing. */ -void test_parent_process_attribute(unsigned int level, HANDLE read_pipe) +static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe) { PROCESS_BASIC_INFORMATION pbi; char buffer[MAX_PATH + 64]; @@ -4081,10 +4081,68 @@ void test_parent_process_attribute(unsigned int level, HANDLE read_pipe) } }
+static void test_handle_list_attribute(BOOL child, HANDLE handle1, HANDLE handle2) +{ + char buffer[MAX_PATH + 64]; + HANDLE pipe[2]; + PROCESS_INFORMATION info; + STARTUPINFOEXA si; + SIZE_T size; + BOOL ret; + SECURITY_ATTRIBUTES sa; + + if (child) + { + DWORD flags; + + flags = 0; + ret = GetHandleInformation(handle1, &flags); + ok(ret, "Failed to get handle info, error %d.\n", GetLastError()); + ok(flags == HANDLE_FLAG_INHERIT, "Unexpected flags %#x.\n", flags); + CloseHandle(handle1); + + ret = GetHandleInformation(handle2, &flags); + todo_wine + ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Unexpected return value, error %d.\n", GetLastError()); + + return; + } + + ret = pInitializeProcThreadAttributeList(NULL, 1, 0, &size); + ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, + "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + + memset(&si, 0, sizeof(si)); + si.StartupInfo.cb = sizeof(si.StartupInfo); + si.lpAttributeList = heap_alloc(size); + ret = pInitializeProcThreadAttributeList(si.lpAttributeList, 1, 0, &size); + ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + + memset(&sa, 0, sizeof(sa)); + sa.nLength = sizeof(sa); + sa.bInheritHandle = TRUE; + + ret = CreatePipe(&pipe[0], &pipe[1], &sa, 1024); + ok(ret, "Failed to create a pipe.\n"); + + ret = pUpdateProcThreadAttribute(si.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST, &pipe[0], + sizeof(pipe[0]), NULL, NULL); + ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + + sprintf(buffer, ""%s" process handlelist %p %p", selfname, pipe[0], pipe[1]); + ret = CreateProcessA(NULL, buffer, NULL, NULL, TRUE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, + (STARTUPINFOA *)&si, &info); + ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + + wait_and_close_child_process(&info); + + CloseHandle(pipe[0]); + CloseHandle(pipe[1]); +} + START_TEST(process) { - HANDLE job; - HANDLE hproc; + HANDLE job, hproc, h, h2; BOOL b = init(); ok(b, "Basic init of CreateProcess test\n"); if (!b) return; @@ -4146,12 +4204,17 @@ START_TEST(process) } else if (!strcmp(myARGV[2], "parent") && myARGC >= 5) { - HANDLE h; - sscanf(myARGV[4], "%p", &h); test_parent_process_attribute(atoi(myARGV[3]), h); return; } + else if (!strcmp(myARGV[2], "handlelist") && myARGC >= 5) + { + sscanf(myARGV[3], "%p", &h); + sscanf(myARGV[4], "%p", &h2); + test_handle_list_attribute(TRUE, h, h2); + return; + }
ok(0, "Unexpected command %s\n", myARGV[2]); return; @@ -4220,4 +4283,5 @@ START_TEST(process) test_BreakawayOk(job); CloseHandle(job); test_parent_process_attribute(0, NULL); + test_handle_list_attribute(FALSE, NULL, NULL); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=79120
Your paranoid android.
=== w10pro64_zh_CN (32 bit report) ===
kernel32: process.c:4106: Test failed: Unexpected return value, error 203.
=== debiant (32 bit Chinese:China report) ===
kernel32: process.c:1605: Test failed: Console:winRight expected 79, but got 80
=== debiant (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
v3: fixed indexing of duplicated handles, handle table updated correctly now.
dlls/kernel32/tests/process.c | 1 - dlls/ntdll/unix/process.c | 39 ++++++++++++++++++++++++++++++++++ include/wine/server_protocol.h | 5 +++-- server/handle.c | 38 ++++++++++++++++++++++++++------- server/handle.h | 3 ++- server/process.c | 25 ++++++++++++++++------ server/process.h | 3 ++- server/protocol.def | 2 ++ server/request.c | 2 +- server/request.h | 1 + server/trace.c | 2 ++ 11 files changed, 101 insertions(+), 20 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index a666434035e..109322d6844 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -4102,7 +4102,6 @@ static void test_handle_list_attribute(BOOL child, HANDLE handle1, HANDLE handle CloseHandle(handle1);
ret = GetHandleInformation(handle2, &flags); - todo_wine ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Unexpected return value, error %d.\n", GetLastError());
return; diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 64380aba036..6c7aa0c2aa9 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -812,6 +812,28 @@ done: return status; }
+static NTSTATUS alloc_handle_list( const PS_ATTRIBUTE *handles_attr, obj_handle_t **handles, data_size_t *handles_len ) +{ + SIZE_T count, i; + HANDLE *src; + + *handles = NULL; + *handles_len = 0; + + if (!handles_attr) return STATUS_SUCCESS; + + count = handles_attr->Size / sizeof(HANDLE); + + if (!(*handles = calloc( sizeof(**handles), count ))) return STATUS_NO_MEMORY; + + src = handles_attr->ValuePtr; + for (i = 0; i < count; ++i) + (*handles)[i] = wine_server_obj_handle( src[i] ); + + *handles_len = count * sizeof(**handles); + + return STATUS_SUCCESS; +}
/********************************************************************** * NtCreateUserProcess (NTDLL.@) @@ -837,6 +859,9 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_ HANDLE parent = 0, debug = 0, token = 0; UNICODE_STRING path = {0}; SIZE_T i, attr_count = (attr->TotalLength - sizeof(attr->TotalLength)) / sizeof(PS_ATTRIBUTE); + const PS_ATTRIBUTE *handles_attr = NULL; + data_size_t handles_size; + obj_handle_t *handles;
for (i = 0; i < attr_count; i++) { @@ -855,6 +880,10 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_ case PS_ATTRIBUTE_TOKEN: token = attr->Attributes[i].ValuePtr; break; + case PS_ATTRIBUTE_HANDLE_LIST: + if (process_flags & PROCESS_CREATE_FLAGS_INHERIT_HANDLES) + handles_attr = &attr->Attributes[i]; + break; default: if (attr->Attributes[i].Attribute & PS_ATTRIBUTE_INPUT) FIXME( "unhandled input attribute %lx\n", attr->Attributes[i].Attribute ); @@ -883,12 +912,19 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_
if ((status = alloc_object_attributes( process_attr, &objattr, &attr_len ))) goto done;
+ if ((status = alloc_handle_list( handles_attr, &handles, &handles_size ))) + { + free( objattr ); + goto done; + } + /* create the socket for the new process */
if (socketpair( PF_UNIX, SOCK_STREAM, 0, socketfd ) == -1) { status = STATUS_TOO_MANY_OPENED_FILES; free( objattr ); + free( handles ); goto done; } #ifdef SO_PASSCRED @@ -914,7 +950,9 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_ req->access = process_access; req->cpu = pe_info.cpu; req->info_size = startup_info_size; + req->handles_size = handles_size; wine_server_add_data( req, objattr, attr_len ); + wine_server_add_data( req, handles, handles_size ); wine_server_add_data( req, startup_info, startup_info_size ); wine_server_add_data( req, params->Environment, env_size ); if (!(status = wine_server_call( req ))) @@ -926,6 +964,7 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_ } SERVER_END_REQ; free( objattr ); + free( handles );
if (status) { diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 2d4e0164783..ab033732f58 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -781,10 +781,11 @@ struct new_process_request unsigned int access; client_cpu_t cpu; data_size_t info_size; + data_size_t handles_size; /* VARARG(objattr,object_attributes); */ + /* VARARG(handles,uints,handles_size); */ /* VARARG(info,startup_info,info_size); */ /* VARARG(env,unicode_str); */ - char __pad_44[4]; }; struct new_process_reply { @@ -6305,7 +6306,7 @@ union generic_reply
/* ### protocol_version begin ### */
-#define SERVER_PROTOCOL_VERSION 642 +#define SERVER_PROTOCOL_VERSION 643
/* ### protocol_version end ### */
diff --git a/server/handle.c b/server/handle.c index 10e6a52e571..e0a21329449 100644 --- a/server/handle.c +++ b/server/handle.c @@ -355,7 +355,8 @@ static void shrink_handle_table( struct handle_table *table )
/* copy the handle table of the parent process */ /* return 1 if OK, 0 on error */ -struct handle_table *copy_handle_table( struct process *process, struct process *parent ) +struct handle_table *copy_handle_table( struct process *process, struct process *parent, + const obj_handle_t *handles, unsigned int handle_count ) { struct handle_table *parent_table = parent->handles; struct handle_table *table; @@ -367,15 +368,36 @@ struct handle_table *copy_handle_table( struct process *process, struct process if (!(table = alloc_handle_table( process, parent_table->count ))) return NULL;
- if ((table->last = parent_table->last) >= 0) + if (handles) { - struct handle_entry *ptr = table->entries; - memcpy( ptr, parent_table->entries, (table->last + 1) * sizeof(struct handle_entry) ); - for (i = 0; i <= table->last; i++, ptr++) + struct handle_entry *dst, *src; + int index; + + dst = table->entries; + memset( dst, 0, parent_table->count * sizeof(*dst) ); + + for (i = 0; i < handle_count; i++) + { + src = get_handle( parent, handles[i] ); + if (!src || !(src->access & RESERVED_INHERIT)) continue; + grab_object_for_handle( src->ptr ); + index = handle_to_index( handles[i] ); + dst[index] = *src; + table->last = max( table->last, index ); + } + } + else + { + if ((table->last = parent_table->last) >= 0) { - if (!ptr->ptr) continue; - if (ptr->access & RESERVED_INHERIT) grab_object_for_handle( ptr->ptr ); - else ptr->ptr = NULL; /* don't inherit this entry */ + struct handle_entry *ptr = table->entries; + memcpy( ptr, parent_table->entries, (table->last + 1) * sizeof(struct handle_entry) ); + for (i = 0; i <= table->last; i++, ptr++) + { + if (!ptr->ptr) continue; + if (ptr->access & RESERVED_INHERIT) grab_object_for_handle( ptr->ptr ); + else ptr->ptr = NULL; /* don't inherit this entry */ + } } } /* attempt to shrink the table */ diff --git a/server/handle.h b/server/handle.h index 40b3b427c2a..bb541de13b1 100644 --- a/server/handle.h +++ b/server/handle.h @@ -50,7 +50,8 @@ extern obj_handle_t open_object( struct process *process, obj_handle_t parent, u extern obj_handle_t find_inherited_handle( struct process *process, const struct object_ops *ops ); extern void close_process_handles( struct process *process ); extern struct handle_table *alloc_handle_table( struct process *process, int count ); -extern struct handle_table *copy_handle_table( struct process *process, struct process *parent ); +extern struct handle_table *copy_handle_table( struct process *process, struct process *parent, + const obj_handle_t *handles, unsigned int handle_count ); extern unsigned int get_handle_table_count( struct process *process);
#endif /* __WINE_SERVER_HANDLE_H */ diff --git a/server/process.c b/server/process.c index 9bf5e447d37..83f5fb6c732 100644 --- a/server/process.c +++ b/server/process.c @@ -500,7 +500,8 @@ static void start_sigkill_timer( struct process *process ) /* create a new process */ /* if the function fails the fd is closed */ struct process *create_process( int fd, struct process *parent, int inherit_all, - const struct security_descriptor *sd ) + const struct security_descriptor *sd, const obj_handle_t *handles, + unsigned int handle_count ) { struct process *process;
@@ -573,7 +574,7 @@ struct process *create_process( int fd, struct process *parent, int inherit_all, else { process->parent_id = parent->id; - process->handles = inherit_all ? copy_handle_table( process, parent ) + process->handles = inherit_all ? copy_handle_table( process, parent, handles, handle_count ) : alloc_handle_table( process, 0 ); /* Note: for security reasons, starting a new process does not attempt * to use the current impersonation token for the new process */ @@ -1101,6 +1102,8 @@ DECL_HANDLER(new_process) struct process *parent; struct thread *parent_thread = current; int socket_fd = thread_get_inflight_fd( current, req->socket_fd ); + const obj_handle_t *handles = NULL; + data_size_t data_size;
if (socket_fd == -1) { @@ -1161,8 +1164,17 @@ DECL_HANDLER(new_process) info->process = NULL; info->data = NULL;
- info_ptr = get_req_data_after_objattr( objattr, &info->data_size ); - info->info_size = min( req->info_size, info->data_size ); + info_ptr = get_req_data_after_objattr( objattr, &data_size ); + + if (req->handles_size) + { + if (req->handles_size < data_size) + handles = info_ptr; + info_ptr = (const char *)info_ptr + req->handles_size; + data_size -= req->handles_size; + } + info->data_size = data_size; + info->info_size = min( req->info_size, data_size );
if (req->info_size < sizeof(*info->data)) { @@ -1202,7 +1214,8 @@ DECL_HANDLER(new_process) #undef FIXUP_LEN }
- if (!(process = create_process( socket_fd, parent, req->inherit_all, sd ))) goto done; + if (!(process = create_process( socket_fd, parent, req->inherit_all, sd, handles, req->handles_size / sizeof(*handles) ))) + goto done;
process->startup_info = (struct startup_info *)grab_object( info );
@@ -1297,7 +1310,7 @@ DECL_HANDLER(exec_process) close( socket_fd ); return; } - if (!(process = create_process( socket_fd, NULL, 0, NULL ))) return; + if (!(process = create_process( socket_fd, NULL, 0, NULL, NULL, 0 ))) return; create_thread( -1, process, NULL ); release_object( process ); } diff --git a/server/process.h b/server/process.h index 0fdf070b78e..7facc4f6dfa 100644 --- a/server/process.h +++ b/server/process.h @@ -109,7 +109,8 @@ extern unsigned int alloc_ptid( void *ptr ); extern void free_ptid( unsigned int id ); extern void *get_ptid_entry( unsigned int id ); extern struct process *create_process( int fd, struct process *parent, int inherit_all, - const struct security_descriptor *sd ); + const struct security_descriptor *sd, const obj_handle_t *handles, + unsigned int handle_count ); extern data_size_t init_process( struct thread *thread ); extern struct thread *get_process_first_thread( struct process *process ); extern struct process *get_process_from_id( process_id_t id ); diff --git a/server/protocol.def b/server/protocol.def index fd9b721d693..83067e5e932 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -795,7 +795,9 @@ struct rawinput_device unsigned int access; /* access rights for process object */ client_cpu_t cpu; /* CPU that the new process will use */ data_size_t info_size; /* size of startup info */ + data_size_t handles_size; /* length of explicit handles list */ VARARG(objattr,object_attributes); /* object attributes */ + VARARG(handles,uints,handles_size); /* handles list */ VARARG(info,startup_info,info_size); /* startup information */ VARARG(env,unicode_str); /* environment for new process */ @REPLY diff --git a/server/request.c b/server/request.c index 4c1f30a5fe7..8f3bad8701d 100644 --- a/server/request.c +++ b/server/request.c @@ -582,7 +582,7 @@ static void master_socket_poll_event( struct fd *fd, int event ) int client = accept( get_unix_fd( master_socket->fd ), (struct sockaddr *) &dummy, &len ); if (client == -1) return; fcntl( client, F_SETFL, O_NONBLOCK ); - if ((process = create_process( client, NULL, 0, NULL ))) + if ((process = create_process( client, NULL, 0, NULL, NULL, 0 ))) { create_thread( -1, process, NULL ); release_object( process ); diff --git a/server/request.h b/server/request.h index 39f3ce7b2ef..bc57d1dc91d 100644 --- a/server/request.h +++ b/server/request.h @@ -727,6 +727,7 @@ C_ASSERT( FIELD_OFFSET(struct new_process_request, exe_file) == 28 ); C_ASSERT( FIELD_OFFSET(struct new_process_request, access) == 32 ); C_ASSERT( FIELD_OFFSET(struct new_process_request, cpu) == 36 ); C_ASSERT( FIELD_OFFSET(struct new_process_request, info_size) == 40 ); +C_ASSERT( FIELD_OFFSET(struct new_process_request, handles_size) == 44 ); C_ASSERT( sizeof(struct new_process_request) == 48 ); C_ASSERT( FIELD_OFFSET(struct new_process_reply, info) == 8 ); C_ASSERT( FIELD_OFFSET(struct new_process_reply, pid) == 12 ); diff --git a/server/trace.c b/server/trace.c index 707a952357f..86b234bc324 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1292,7 +1292,9 @@ static void dump_new_process_request( const struct new_process_request *req ) fprintf( stderr, ", access=%08x", req->access ); dump_client_cpu( ", cpu=", &req->cpu ); fprintf( stderr, ", info_size=%u", req->info_size ); + fprintf( stderr, ", handles_size=%u", req->handles_size ); dump_varargs_object_attributes( ", objattr=", cur_size ); + dump_varargs_uints( ", handles=", min(cur_size,req->handles_size) ); dump_varargs_startup_info( ", info=", min(cur_size,req->info_size) ); dump_varargs_unicode_str( ", env=", cur_size ); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=79118
Your paranoid android.
=== debiant (build log) ===
Task: WineTest did not produce the wow32 report