kernelbase: Implement GetOverlappedResultEx().

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38830
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-11-28 18:19:21 -06:00 committed by Alexandre Julliard
parent a4131ca625
commit 216530f230
6 changed files with 79 additions and 6 deletions

View File

@ -4,7 +4,7 @@
@ stdcall CreateIoCompletionPort(long long long long) kernel32.CreateIoCompletionPort @ stdcall CreateIoCompletionPort(long long long long) kernel32.CreateIoCompletionPort
@ stdcall DeviceIoControl(long long ptr long ptr long ptr ptr) kernel32.DeviceIoControl @ stdcall DeviceIoControl(long long ptr long ptr long ptr ptr) kernel32.DeviceIoControl
@ stdcall GetOverlappedResult(long ptr ptr long) kernel32.GetOverlappedResult @ stdcall GetOverlappedResult(long ptr ptr long) kernel32.GetOverlappedResult
@ stub GetOverlappedResultEx @ stdcall GetOverlappedResultEx(long ptr ptr long long) kernel32.GetOverlappedResultEx
@ stdcall GetQueuedCompletionStatus(long ptr ptr ptr long) kernel32.GetQueuedCompletionStatus @ stdcall GetQueuedCompletionStatus(long ptr ptr ptr long) kernel32.GetQueuedCompletionStatus
@ stdcall GetQueuedCompletionStatusEx(ptr ptr long ptr long long) kernel32.GetQueuedCompletionStatusEx @ stdcall GetQueuedCompletionStatusEx(ptr ptr long ptr long long) kernel32.GetQueuedCompletionStatusEx
@ stdcall PostQueuedCompletionStatus(long long ptr ptr) kernel32.PostQueuedCompletionStatus @ stdcall PostQueuedCompletionStatus(long long ptr ptr) kernel32.PostQueuedCompletionStatus

View File

@ -760,6 +760,7 @@
@ stdcall GetNumberOfConsoleMouseButtons(ptr) @ stdcall GetNumberOfConsoleMouseButtons(ptr)
@ stdcall -import GetOEMCP() @ stdcall -import GetOEMCP()
@ stdcall -import GetOverlappedResult(long ptr ptr long) @ stdcall -import GetOverlappedResult(long ptr ptr long)
@ stdcall -import GetOverlappedResultEx(long ptr ptr long long)
@ stdcall GetUserPreferredUILanguages(long ptr ptr ptr) @ stdcall GetUserPreferredUILanguages(long ptr ptr ptr)
@ stdcall GetPackageFullName(long ptr ptr) @ stdcall GetPackageFullName(long ptr ptr)
@ stdcall -import GetPhysicallyInstalledSystemMemory(ptr) @ stdcall -import GetPhysicallyInstalledSystemMemory(ptr)

View File

@ -42,6 +42,7 @@ static BOOL (WINAPI *pGetNamedPipeClientProcessId)(HANDLE,ULONG*);
static BOOL (WINAPI *pGetNamedPipeServerProcessId)(HANDLE,ULONG*); static BOOL (WINAPI *pGetNamedPipeServerProcessId)(HANDLE,ULONG*);
static BOOL (WINAPI *pGetNamedPipeClientSessionId)(HANDLE,ULONG*); static BOOL (WINAPI *pGetNamedPipeClientSessionId)(HANDLE,ULONG*);
static BOOL (WINAPI *pGetNamedPipeServerSessionId)(HANDLE,ULONG*); static BOOL (WINAPI *pGetNamedPipeServerSessionId)(HANDLE,ULONG*);
static BOOL (WINAPI *pGetOverlappedResultEx)(HANDLE,OVERLAPPED *,DWORD *,DWORD,BOOL);
static BOOL user_apc_ran; static BOOL user_apc_ran;
static void CALLBACK user_apc(ULONG_PTR param) static void CALLBACK user_apc(ULONG_PTR param)
@ -4065,6 +4066,57 @@ static void test_nowait(DWORD pipe_type)
ok(CloseHandle(pipewrite), "CloseHandle for the write pipe failed\n"); ok(CloseHandle(pipewrite), "CloseHandle for the write pipe failed\n");
} }
static void test_GetOverlappedResultEx(void)
{
HANDLE client, server;
OVERLAPPED ovl;
char buffer[8000];
DWORD ret_size;
BOOL ret;
if (!pGetOverlappedResultEx)
{
win_skip("GetOverlappedResultEx() is not available\n");
return;
}
create_overlapped_pipe(PIPE_TYPE_BYTE, &client, &server);
overlapped_write_async(client, buffer, sizeof(buffer), &ovl);
user_apc_ran = FALSE;
QueueUserAPC(user_apc, GetCurrentThread(), 0);
SetLastError(0xdeadbeef);
ret = pGetOverlappedResultEx(client, &ovl, &ret_size, 0, FALSE);
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_IO_INCOMPLETE, "wrong error %u\n", GetLastError());
ok(!user_apc_ran, "APC should not have run\n");
SetLastError(0xdeadbeef);
ret = pGetOverlappedResultEx(client, &ovl, &ret_size, 0, TRUE);
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_IO_INCOMPLETE, "wrong error %u\n", GetLastError());
ok(!user_apc_ran, "APC should not have run\n");
SetLastError(0xdeadbeef);
ret = pGetOverlappedResultEx(client, &ovl, &ret_size, 10, FALSE);
ok(!ret, "expected failure\n");
ok(GetLastError() == WAIT_TIMEOUT, "wrong error %u\n", GetLastError());
ok(!user_apc_ran, "APC should not have run\n");
SetLastError(0xdeadbeef);
ret = pGetOverlappedResultEx(client, &ovl, &ret_size, 10, TRUE);
ok(!ret, "expected failure\n");
ok(GetLastError() == WAIT_IO_COMPLETION, "wrong error %u\n", GetLastError());
ok(user_apc_ran, "APC should have run\n");
CloseHandle(ovl.hEvent);
CloseHandle(client);
CloseHandle(server);
}
START_TEST(pipe) START_TEST(pipe)
{ {
char **argv; char **argv;
@ -4080,6 +4132,7 @@ START_TEST(pipe)
pGetNamedPipeServerProcessId = (void *) GetProcAddress(hmod, "GetNamedPipeServerProcessId"); pGetNamedPipeServerProcessId = (void *) GetProcAddress(hmod, "GetNamedPipeServerProcessId");
pGetNamedPipeClientSessionId = (void *) GetProcAddress(hmod, "GetNamedPipeClientSessionId"); pGetNamedPipeClientSessionId = (void *) GetProcAddress(hmod, "GetNamedPipeClientSessionId");
pGetNamedPipeServerSessionId = (void *) GetProcAddress(hmod, "GetNamedPipeServerSessionId"); pGetNamedPipeServerSessionId = (void *) GetProcAddress(hmod, "GetNamedPipeServerSessionId");
pGetOverlappedResultEx = (void *)GetProcAddress(hmod, "GetOverlappedResultEx");
argc = winetest_get_mainargs(&argv); argc = winetest_get_mainargs(&argv);
@ -4134,4 +4187,5 @@ START_TEST(pipe)
test_wait_pipe(); test_wait_pipe();
test_nowait(PIPE_TYPE_BYTE); test_nowait(PIPE_TYPE_BYTE);
test_nowait(PIPE_TYPE_MESSAGE); test_nowait(PIPE_TYPE_MESSAGE);
test_GetOverlappedResultEx();
} }

View File

@ -2003,20 +2003,37 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetFileType( HANDLE file )
BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResult( HANDLE file, LPOVERLAPPED overlapped, BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResult( HANDLE file, LPOVERLAPPED overlapped,
LPDWORD result, BOOL wait ) LPDWORD result, BOOL wait )
{ {
NTSTATUS status; return GetOverlappedResultEx( file, overlapped, result, wait ? INFINITE : 0, FALSE );
}
TRACE( "(%p %p %p %x)\n", file, overlapped, result, wait );
/***********************************************************************
* GetOverlappedResultEx (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResultEx( HANDLE file, OVERLAPPED *overlapped,
DWORD *result, DWORD timeout, BOOL alertable )
{
NTSTATUS status;
DWORD ret;
TRACE( "(%p %p %p %u %d)\n", file, overlapped, result, timeout, alertable );
status = overlapped->Internal; status = overlapped->Internal;
if (status == STATUS_PENDING) if (status == STATUS_PENDING)
{ {
if (!wait) if (!timeout)
{ {
SetLastError( ERROR_IO_INCOMPLETE ); SetLastError( ERROR_IO_INCOMPLETE );
return FALSE; return FALSE;
} }
if (WaitForSingleObject( overlapped->hEvent ? overlapped->hEvent : file, INFINITE ) == WAIT_FAILED) ret = WaitForSingleObjectEx( overlapped->hEvent ? overlapped->hEvent : file, timeout, alertable );
if (ret == WAIT_FAILED)
return FALSE; return FALSE;
else if (ret)
{
SetLastError( ret );
return FALSE;
}
status = overlapped->Internal; status = overlapped->Internal;
if (status == STATUS_PENDING) status = STATUS_SUCCESS; if (status == STATUS_PENDING) status = STATUS_SUCCESS;

View File

@ -584,7 +584,7 @@
# @ stub GetOsManufacturingMode # @ stub GetOsManufacturingMode
# @ stub GetOsSafeBootMode # @ stub GetOsSafeBootMode
@ stdcall GetOverlappedResult(long ptr ptr long) @ stdcall GetOverlappedResult(long ptr ptr long)
# @ stub GetOverlappedResultEx @ stdcall GetOverlappedResultEx(long ptr ptr long long)
# @ stub GetPackageApplicationContext # @ stub GetPackageApplicationContext
# @ stub GetPackageApplicationIds # @ stub GetPackageApplicationIds
# @ stub GetPackageApplicationProperty # @ stub GetPackageApplicationProperty

View File

@ -2215,6 +2215,7 @@ WINBASEAPI BOOL WINAPI GetNumaProximityNodeEx(ULONG,PUSHORT);
WINADVAPI BOOL WINAPI GetNumberOfEventLogRecords(HANDLE,PDWORD); WINADVAPI BOOL WINAPI GetNumberOfEventLogRecords(HANDLE,PDWORD);
WINADVAPI BOOL WINAPI GetOldestEventLogRecord(HANDLE,PDWORD); WINADVAPI BOOL WINAPI GetOldestEventLogRecord(HANDLE,PDWORD);
WINBASEAPI BOOL WINAPI GetOverlappedResult(HANDLE,LPOVERLAPPED,LPDWORD,BOOL); WINBASEAPI BOOL WINAPI GetOverlappedResult(HANDLE,LPOVERLAPPED,LPDWORD,BOOL);
WINBASEAPI BOOL WINAPI GetOverlappedResultEx(HANDLE,OVERLAPPED*,DWORD*,DWORD,BOOL);
WINBASEAPI DWORD WINAPI GetPriorityClass(HANDLE); WINBASEAPI DWORD WINAPI GetPriorityClass(HANDLE);
WINADVAPI BOOL WINAPI GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,DWORD,PDWORD); WINADVAPI BOOL WINAPI GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,DWORD,PDWORD);
WINBASEAPI UINT WINAPI GetPrivateProfileIntA(LPCSTR,LPCSTR,INT,LPCSTR); WINBASEAPI UINT WINAPI GetPrivateProfileIntA(LPCSTR,LPCSTR,INT,LPCSTR);