diff --git a/reactos/dll/win32/kernel32/file/iocompl.c b/reactos/dll/win32/kernel32/file/iocompl.c index a245d0438d0..83a1fc04c0d 100644 --- a/reactos/dll/win32/kernel32/file/iocompl.c +++ b/reactos/dll/win32/kernel32/file/iocompl.c @@ -99,9 +99,10 @@ GetQueuedCompletionStatus( { NTSTATUS errCode; IO_STATUS_BLOCK IoStatus; + ULONG_PTR CompletionKey; LARGE_INTEGER Interval; - if (!lpNumberOfBytesTransferred||!lpCompletionKey||!lpOverlapped) + if (!lpNumberOfBytesTransferred || !lpCompletionKey || !lpOverlapped) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; @@ -113,18 +114,19 @@ GetQueuedCompletionStatus( } errCode = NtRemoveIoCompletion(CompletionHandle, - (PVOID*)lpCompletionKey, - (PVOID*)lpNumberOfBytesTransferred, + (PVOID*)&CompletionKey, + (PVOID*)lpOverlapped, &IoStatus, dwMilliseconds == INFINITE ? NULL : &Interval); - if (!NT_SUCCESS(errCode)) { + if (!NT_SUCCESS(errCode) || errCode == STATUS_TIMEOUT) { *lpOverlapped = NULL; SetLastErrorByStatus(errCode); return FALSE; } - *lpOverlapped = (LPOVERLAPPED)IoStatus.Information; + *lpCompletionKey = CompletionKey; + *lpNumberOfBytesTransferred = IoStatus.Information; if (!NT_SUCCESS(IoStatus.Status)){ //failed io operation @@ -133,7 +135,6 @@ GetQueuedCompletionStatus( } return TRUE; - } @@ -152,10 +153,10 @@ PostQueuedCompletionStatus( NTSTATUS errCode; errCode = NtSetIoCompletion(CompletionHandle, - (PVOID)dwCompletionKey, - (PVOID)lpOverlapped,//CompletionValue - STATUS_SUCCESS, //IoStatusBlock->Status - dwNumberOfBytesTransferred); //IoStatusBlock->Information + (PVOID)dwCompletionKey, // KeyContext + (PVOID)lpOverlapped, // ApcContext + STATUS_SUCCESS, // IoStatusBlock->Status + dwNumberOfBytesTransferred); // IoStatusBlock->Information if ( !NT_SUCCESS(errCode) ) {