mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
fixed/improved GetOverlappedResult
svn path=/trunk/; revision=6806
This commit is contained in:
parent
ebdb1b6328
commit
05dd288048
1 changed files with 35 additions and 43 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: deviceio.c,v 1.12 2003/07/10 18:50:51 chorns Exp $
|
/* $Id: deviceio.c,v 1.13 2003/11/27 00:57:57 gdalsnes Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -139,54 +139,46 @@ DeviceIoControl(
|
||||||
WINBOOL
|
WINBOOL
|
||||||
STDCALL
|
STDCALL
|
||||||
GetOverlappedResult (
|
GetOverlappedResult (
|
||||||
HANDLE hFile,
|
IN HANDLE hFile,
|
||||||
LPOVERLAPPED lpOverlapped,
|
IN LPOVERLAPPED lpOverlapped,
|
||||||
LPDWORD lpNumberOfBytesTransferred,
|
OUT LPDWORD lpNumberOfBytesTransferred,
|
||||||
WINBOOL bWait
|
IN WINBOOL bWait
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD WaitStatus;
|
DWORD WaitStatus;
|
||||||
|
HANDLE hObject;
|
||||||
|
|
||||||
if (lpOverlapped == NULL)
|
if (lpOverlapped->Internal == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
|
if (!bWait)
|
||||||
return FALSE;
|
{
|
||||||
}
|
/* can't use SetLastErrorByStatus(STATUS_PENDING) here,
|
||||||
|
since STATUS_PENDING translates to ERROR_IO_PENDING */
|
||||||
|
SetLastError(ERROR_IO_INCOMPLETE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
hObject = lpOverlapped->hEvent ? lpOverlapped->hEvent : hFile;
|
||||||
|
|
||||||
if (lpOverlapped ->Internal == STATUS_PENDING)
|
/* Wine delivers pending APC's while waiting, but Windows does
|
||||||
{
|
not, nor do we... */
|
||||||
if (lpNumberOfBytesTransferred == 0)
|
WaitStatus = WaitForSingleObject(hObject, INFINITE);
|
||||||
{
|
|
||||||
SetLastErrorByStatus (STATUS_PENDING);
|
if (WaitStatus == WAIT_FAILED)
|
||||||
return FALSE;
|
{
|
||||||
}
|
DPRINT("Wait failed!\n");
|
||||||
else if (bWait == TRUE)
|
/* WaitForSingleObjectEx sets the last error */
|
||||||
{
|
return FALSE;
|
||||||
if (lpOverlapped->hEvent != NULL)
|
}
|
||||||
{
|
}
|
||||||
WaitStatus = WaitForSingleObject (lpOverlapped->hEvent,
|
|
||||||
-1);
|
|
||||||
if (WaitStatus == STATUS_TIMEOUT)
|
|
||||||
{
|
|
||||||
SetLastError (ERROR_IO_INCOMPLETE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return GetOverlappedResult (hFile,
|
|
||||||
lpOverlapped,
|
|
||||||
lpNumberOfBytesTransferred,
|
|
||||||
FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpNumberOfBytesTransferred = lpOverlapped->InternalHigh;
|
*lpNumberOfBytesTransferred = lpOverlapped->InternalHigh;
|
||||||
|
|
||||||
if (lpOverlapped->Internal < 0)
|
if (!NT_SUCCESS(lpOverlapped->Internal))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus (lpOverlapped->Internal);
|
SetLastErrorByStatus(lpOverlapped->Internal);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue