Fixed bug in DeviceIoContol().

svn path=/trunk/; revision=351
This commit is contained in:
Eric Kohl 1999-03-30 22:05:06 +00:00
parent 9e3fe0593a
commit 74b0d03ccc

View file

@ -11,6 +11,10 @@
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#define NDEBUG
#include <kernel32/kernel32.h>
WINBOOL WINBOOL
STDCALL STDCALL
DeviceIoControl( DeviceIoControl(
@ -24,7 +28,6 @@ DeviceIoControl(
LPOVERLAPPED lpOverlapped LPOVERLAPPED lpOverlapped
) )
{ {
NTSTATUS errCode = 0; NTSTATUS errCode = 0;
HANDLE hEvent = NULL; HANDLE hEvent = NULL;
PIO_STATUS_BLOCK IoStatusBlock; PIO_STATUS_BLOCK IoStatusBlock;
@ -41,7 +44,7 @@ DeviceIoControl(
bFsIoControlCode = TRUE; bFsIoControlCode = TRUE;
else else
bFsIoControlCode = FALSE; bFsIoControlCode = FALSE;
CHECKPOINT
if(lpOverlapped != NULL) { if(lpOverlapped != NULL) {
hEvent = lpOverlapped->hEvent; hEvent = lpOverlapped->hEvent;
lpOverlapped->Internal = STATUS_PENDING; lpOverlapped->Internal = STATUS_PENDING;
@ -51,13 +54,13 @@ DeviceIoControl(
IoStatusBlock = &IIosb; IoStatusBlock = &IIosb;
} }
CHECKPOINT
if(bFsIoControlCode == TRUE) { if(bFsIoControlCode == TRUE) {
errCode = NtFsControlFile(hDevice,hEvent,NULL,NULL,IoStatusBlock,dwIoControlCode,lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize ); errCode = NtFsControlFile(hDevice,hEvent,NULL,NULL,IoStatusBlock,dwIoControlCode,lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize );
} else { } else {
errCode = NtDeviceIoControlFile(hDevice,hEvent,NULL,NULL,IoStatusBlock,dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize); errCode = NtDeviceIoControlFile(hDevice,hEvent,NULL,NULL,IoStatusBlock,dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize);
} }
CHECKPOINT
if(errCode == STATUS_PENDING ) { if(errCode == STATUS_PENDING ) {
if(NtWaitForSingleObject(hDevice,FALSE,NULL) < 0) { if(NtWaitForSingleObject(hDevice,FALSE,NULL) < 0) {
@ -70,11 +73,13 @@ DeviceIoControl(
SetLastError(RtlNtStatusToDosError(errCode)); SetLastError(RtlNtStatusToDosError(errCode));
return FALSE; return FALSE;
} }
*lpBytesReturned = lpOverlapped->InternalHigh; CHECKPOINT
if (lpOverlapped)
*lpBytesReturned = lpOverlapped->InternalHigh;
else
*lpBytesReturned = IoStatusBlock->Information;
CHECKPOINT
return TRUE; return TRUE;
} }