Fix for DeviceIoControl masking FILE_DEVICE_FILE_SYSTEM incorrectly.
authorRobert Dickenson <robd@reactos.org>
Thu, 3 Oct 2002 19:09:04 +0000 (19:09 +0000)
committerRobert Dickenson <robd@reactos.org>
Thu, 3 Oct 2002 19:09:04 +0000 (19:09 +0000)
Anybody familiar with this module please review.

svn path=/trunk/; revision=3608

reactos/lib/kernel32/file/deviceio.c

index 8ff7173..c6d3c59 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: deviceio.c,v 1.9 2002/09/08 10:22:41 chorns Exp $
+/* $Id: deviceio.c,v 1.10 2002/10/03 19:09:04 robd Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -13,6 +13,7 @@
 #include <windows.h>
 
 #define NDEBUG
+//#define DBG
 #include <kernel32/kernel32.h>
 #include <kernel32/error.h>
 
@@ -37,16 +38,34 @@ DeviceIoControl(
 
        WINBOOL bFsIoControlCode = FALSE;
 
+    DPRINT("DeviceIoControl(hDevice %x dwIoControlCode %d lpInBuffer %x "
+          "nInBufferSize %d lpOutBuffer %x nOutBufferSize %d "
+          "lpBytesReturned %x lpOverlapped %x)\n",
+          hDevice,dwIoControlCode,lpInBuffer,nInBufferSize,lpOutBuffer,
+          nOutBufferSize,lpBytesReturned,lpOverlapped);
+
        if (lpBytesReturned == NULL)
        {
+        DPRINT("DeviceIoControl() - returning STATUS_INVALID_PARAMETER\n");
                SetLastErrorByStatus (STATUS_INVALID_PARAMETER);
                return FALSE;
        }
+       //
+       // TODO: Review and approve this change by RobD. IoCtrls for Serial.sys were 
+       //       going to NtFsControlFile instead of NtDeviceIoControlFile.
+       //               Don't know at this point if anything else is affected by this change.
+       //
+       // if (((dwIoControlCode >> 16) & FILE_DEVICE_FILE_SYSTEM) == FILE_DEVICE_FILE_SYSTEM) {
+       //
+
+       if ((dwIoControlCode >> 16) == FILE_DEVICE_FILE_SYSTEM) {
 
-       if (((dwIoControlCode >> 16) & FILE_DEVICE_FILE_SYSTEM) == FILE_DEVICE_FILE_SYSTEM)
                bFsIoControlCode = TRUE;
-       else
+        DPRINT("DeviceIoControl() - FILE_DEVICE_FILE_SYSTEM == TRUE %x %x\n", dwIoControlCode, dwIoControlCode >> 16);
+       } else {
                bFsIoControlCode = FALSE;
+        DPRINT("DeviceIoControl() - FILE_DEVICE_FILE_SYSTEM == FALSE %x %x\n", dwIoControlCode, dwIoControlCode >> 16);
+       }
 
        if(lpOverlapped  != NULL)
        {
@@ -88,16 +107,19 @@ DeviceIoControl(
 
        if (errCode == STATUS_PENDING)
        {
+        DPRINT("DeviceIoControl() - STATUS_PENDING\n");
                if (NtWaitForSingleObject(hDevice,FALSE,NULL) < 0)
                {
                        *lpBytesReturned = IoStatusBlock->Information;
                        SetLastErrorByStatus (errCode);
+            DPRINT("DeviceIoControl() - STATUS_PENDING wait failed.\n");
                        return FALSE;
                }
        }
        else if (!NT_SUCCESS(errCode))
        {
                SetLastErrorByStatus (errCode);
+        DPRINT("DeviceIoControl() - ERROR: %x\n", errCode);
                return FALSE;
        }