[driver] Special-case IRP_MJ_DEVICE_CONTROL for bus
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Sun, 2 Jan 2011 23:16:26 +0000 (18:16 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Sun, 2 Jan 2011 23:16:26 +0000 (18:16 -0500)
src/winvblock/driver.c

index 8b56ca7..deb31d6 100644 (file)
@@ -144,7 +144,7 @@ static NTSTATUS STDCALL WvAttachFdo(
     static WV_S_DEV_IRP_MJ irp_mj = {
         (WV_FP_DEV_DISPATCH) 0,
         (WV_FP_DEV_DISPATCH) 0,
-        WvBusDevCtl,
+        (WV_FP_DEV_CTL) 0,
         (WV_FP_DEV_SCSI) 0,
         WvBusPnp,
       };
@@ -392,13 +392,22 @@ static NTSTATUS WvIrpDevCtl(
     IN PDEVICE_OBJECT dev_obj,
     IN PIRP irp
   ) {
-    /* WvDevFromDevObj() checks for a NULL dev_obj */
-    WV_SP_DEV_T dev = WvDevFromDevObj(dev_obj);
+    WV_SP_DEV_T dev;
     PIO_STACK_LOCATION io_stack_loc = IoGetCurrentIrpStackLocation(irp);
 
     #ifdef DEBUGIRPS
     Debug_IrpStart(dev_obj, irp);
     #endif
+    /* Check for a bus IRP. */
+    if (dev_obj == WvBus.Fdo) {
+        return WvBusDevCtl(
+            &WvBusDev,
+            irp,
+            io_stack_loc->Parameters.DeviceIoControl.IoControlCode
+          );
+      }
+    /* WvDevFromDevObj() checks for a NULL dev_obj */
+    dev = WvDevFromDevObj(dev_obj);
     /* Check that the device exists. */
     if (!dev || dev->State == WvDevStateDeleted)
       return WvlIrpComplete(irp, 0, STATUS_NO_SUCH_DEVICE);