[bus_pnp] Move bus PnP IRP handling into bus_pnp
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Wed, 16 Dec 2009 04:12:50 +0000 (23:12 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Wed, 16 Dec 2009 04:12:50 +0000 (23:12 -0500)
Changed functions to use mini IRP handling.  Put in own file.

WinVBlock.dev
config.bat
src/bus.c
src/bus.h
src/bus_pnp.c [new file with mode: 0644]
src/bus_pnp.h [new file with mode: 0644]

index d70f3f7..c6135d4 100644 (file)
@@ -1,7 +1,7 @@
 [Project]\r
 FileName=WinVBlock.dev\r
 Name=WinVBlock\r
-UnitCount=24\r
+UnitCount=28\r
 PchHead=-1\r
 PchSource=-1\r
 Ver=3\r
@@ -322,3 +322,43 @@ Priority=1000
 OverrideBuildCmd=0\r
 BuildCmd=\r
 \r
+[Unit25]\r
+FileName=src\winvblock.h\r
+CompileCpp=1\r
+Folder=WinVBlock\r
+Compile=1\r
+Link=1\r
+Priority=1000\r
+OverrideBuildCmd=0\r
+BuildCmd=\r
+\r
+[Unit26]\r
+FileName=src\irp.h\r
+CompileCpp=1\r
+Folder=\r
+Compile=1\r
+Link=1\r
+Priority=1000\r
+OverrideBuildCmd=0\r
+BuildCmd=\r
+\r
+[Unit27]\r
+FileName=src\bus_pnp.c\r
+CompileCpp=1\r
+Folder=WinVBlock\r
+Compile=1\r
+Link=1\r
+Priority=1000\r
+OverrideBuildCmd=0\r
+BuildCmd=\r
+\r
+[Unit28]\r
+FileName=src\bus_pnp.h\r
+CompileCpp=1\r
+Folder=WinVBlock\r
+Compile=1\r
+Link=1\r
+Priority=1000\r
+OverrideBuildCmd=0\r
+BuildCmd=\r
+\r
index f214828..7c51d4f 100644 (file)
@@ -2,5 +2,5 @@ rem This is the root directory of the ddk.
 set ddkdir=c:\winddk\6001.18001\r
 \r
 rem Next two lines are duplicated in Makefile, edit both when adding files or changing pxe style.\r
-set c=driver.c registry.c bus.c aoedisk.c aoe.c protocol.c debug.c probe.c winvblock.rc\r
+set c=driver.c registry.c bus.c bus_pnp.c aoedisk.c aoe.c protocol.c debug.c probe.c winvblock.rc\r
 set pxestyle=asm\r
index f54cf7c..daf775f 100644 (file)
--- a/src/bus.c
+++ b/src/bus.c
@@ -34,6 +34,7 @@
 #include "driver.h"
 #include "disk.h"
 #include "bus.h"
+#include "bus_pnp.h"
 #include "aoe.h"
 #include "mount.h"
 #include "debug.h"
@@ -53,11 +54,6 @@ winvblock__bool STDCALL Bus_AddChild (
   IN disk__type Disk,
   IN winvblock__bool Boot
  );
-static NTSTATUS STDCALL Bus_IoCompletionRoutine (
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  IN PKEVENT Event
- );
 
 typedef struct _BUS_TARGETLIST
 {
@@ -242,8 +238,8 @@ Bus_AddChild (
     Disk.DiskType == OpticalDisc ? FILE_DEVICE_CD_ROM : FILE_DEVICE_DISK;
   ULONG DiskType2 =
     Disk.DiskType ==
-    OpticalDisc ? FILE_READ_ONLY_DEVICE | FILE_REMOVABLE_MEDIA : Disk.DiskType
-    == FloppyDisk ? FILE_REMOVABLE_MEDIA | FILE_FLOPPY_DISKETTE : 0;
+    OpticalDisc ? FILE_READ_ONLY_DEVICE | FILE_REMOVABLE_MEDIA : Disk.
+    DiskType == FloppyDisk ? FILE_REMOVABLE_MEDIA | FILE_FLOPPY_DISKETTE : 0;
 
   DBG ( "Entry\n" );
   /*
@@ -331,48 +327,6 @@ Bus_AddChild (
   return TRUE;
 }
 
-static
-irp__handler_decl (
-  pnp_start_dev
- )
-{
-  NTSTATUS status;
-  KEVENT event;
-  bus__type_ptr bus_ptr;
-
-  bus_ptr = get_bus_ptr ( DeviceExtension );
-  KeInitializeEvent ( &event, NotificationEvent, FALSE );
-  IoCopyCurrentIrpStackLocationToNext ( Irp );
-  IoSetCompletionRoutine ( Irp,
-                          ( PIO_COMPLETION_ROUTINE ) Bus_IoCompletionRoutine,
-                          ( PVOID ) & event, TRUE, TRUE, TRUE );
-  status = IoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
-  if ( status == STATUS_PENDING )
-    {
-      DBG ( "Locked\n" );
-      KeWaitForSingleObject ( &event, Executive, KernelMode, FALSE, NULL );
-    }
-  if ( NT_SUCCESS ( status = Irp->IoStatus.Status ) )
-    {
-      DeviceExtension->OldState = DeviceExtension->State;
-      DeviceExtension->State = Started;
-    }
-  status = STATUS_SUCCESS;
-  Irp->IoStatus.Status = status;
-  IoCompleteRequest ( Irp, IO_NO_INCREMENT );
-  *completion_ptr = TRUE;
-  return status;
-}
-
-static
-irp__handler_decl (
-  foo
- )
-{
-  DBG ( "BUS PNP test\n" );
-  return STATUS_SUCCESS;
-}
-
 irp__handling handling_table[] = {
   /*
    * Major, minor, any major?, any minor?, handler
@@ -380,130 +334,18 @@ irp__handling handling_table[] = {
    * Note that the fall-through case must come FIRST!
    * Why? It sets completion to true, so others won't be called
    */
-  {IRP_MJ_PNP, IRP_MN_START_DEVICE, FALSE, FALSE, pnp_start_dev}
+  {IRP_MJ_PNP, 0, FALSE, TRUE, bus_pnp__simple}
+  ,
+  {IRP_MJ_PNP, IRP_MN_START_DEVICE, FALSE, FALSE, bus_pnp__start_dev}
+  ,
+  {IRP_MJ_PNP, IRP_MN_REMOVE_DEVICE, FALSE, FALSE, bus_pnp__remove_dev}
   ,
-  {IRP_MJ_PNP, IRP_MN_QUERY_DEVICE_RELATIONS, FALSE, FALSE, foo}
+  {IRP_MJ_PNP, IRP_MN_QUERY_DEVICE_RELATIONS, FALSE, FALSE,
+   bus_pnp__query_dev_relations}
 };
 
 size_t handling_table_size = sizeof ( handling_table );
 
-irp__handler_decl ( Bus_DispatchPnP )
-{
-  NTSTATUS Status;
-  KEVENT Event;
-  PDEVICE_RELATIONS DeviceRelations;
-  bus__type_ptr bus_ptr;
-  disk__type_ptr Walker,
-   Next;
-  ULONG Count;
-
-  /*
-   * Establish a pointer into the bus device's extension space
-   */
-  bus_ptr = get_bus_ptr ( DeviceExtension );
-
-  switch ( Stack->MinorFunction )
-    {
-      case IRP_MN_REMOVE_DEVICE:
-       DeviceExtension->OldState = DeviceExtension->State;
-       DeviceExtension->State = Deleted;
-       Irp->IoStatus.Information = 0;
-       Irp->IoStatus.Status = STATUS_SUCCESS;
-       IoSkipCurrentIrpStackLocation ( Irp );
-       Status = IoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
-       Walker = ( disk__type_ptr ) bus_ptr->first_child_ptr;
-       while ( Walker != NULL )
-         {
-           Next = Walker->next_sibling_ptr;
-           IoDeleteDevice ( Walker->dev_ext_ptr->Self );
-           Walker = Next;
-         }
-       bus_ptr->Children = 0;
-       bus_ptr->first_child_ptr = NULL;
-       IoDetachDevice ( bus_ptr->LowerDeviceObject );
-       IoDeleteDevice ( DeviceExtension->Self );
-       return Status;
-      case IRP_MN_QUERY_DEVICE_RELATIONS:
-       if ( Stack->Parameters.QueryDeviceRelations.Type != BusRelations
-            || Irp->IoStatus.Information )
-         {
-           Status = Irp->IoStatus.Status;
-           break;
-         }
-       Count = 0;
-       Walker = ( disk__type_ptr ) bus_ptr->first_child_ptr;
-       while ( Walker != NULL )
-         {
-           Count++;
-           Walker = Walker->next_sibling_ptr;
-         }
-       DeviceRelations =
-         ( PDEVICE_RELATIONS ) ExAllocatePool ( NonPagedPool,
-                                                sizeof ( DEVICE_RELATIONS ) +
-                                                ( sizeof ( PDEVICE_OBJECT ) *
-                                                  Count ) );
-       if ( DeviceRelations == NULL )
-         {
-           Irp->IoStatus.Information = 0;
-           Status = STATUS_INSUFFICIENT_RESOURCES;
-           break;
-         }
-       DeviceRelations->Count = Count;
-
-       Count = 0;
-       Walker = ( disk__type_ptr ) bus_ptr->first_child_ptr;
-       while ( Walker != NULL )
-         {
-           ObReferenceObject ( Walker->dev_ext_ptr->Self );
-           DeviceRelations->Objects[Count] = Walker->dev_ext_ptr->Self;
-           Count++;
-           Walker = Walker->next_sibling_ptr;
-         }
-       Irp->IoStatus.Information = ( ULONG_PTR ) DeviceRelations;
-       Status = STATUS_SUCCESS;
-       break;
-      case IRP_MN_QUERY_PNP_DEVICE_STATE:
-       Irp->IoStatus.Information = 0;
-       Status = STATUS_SUCCESS;
-       break;
-      case IRP_MN_QUERY_STOP_DEVICE:
-       DeviceExtension->OldState = DeviceExtension->State;
-       DeviceExtension->State = StopPending;
-       Status = STATUS_SUCCESS;
-       break;
-      case IRP_MN_CANCEL_STOP_DEVICE:
-       DeviceExtension->State = DeviceExtension->OldState;
-       Status = STATUS_SUCCESS;
-       break;
-      case IRP_MN_STOP_DEVICE:
-       DeviceExtension->OldState = DeviceExtension->State;
-       DeviceExtension->State = Stopped;
-       Status = STATUS_SUCCESS;
-       break;
-      case IRP_MN_QUERY_REMOVE_DEVICE:
-       DeviceExtension->OldState = DeviceExtension->State;
-       DeviceExtension->State = RemovePending;
-       Status = STATUS_SUCCESS;
-       break;
-      case IRP_MN_CANCEL_REMOVE_DEVICE:
-       DeviceExtension->State = DeviceExtension->OldState;
-       Status = STATUS_SUCCESS;
-       break;
-      case IRP_MN_SURPRISE_REMOVAL:
-       DeviceExtension->OldState = DeviceExtension->State;
-       DeviceExtension->State = SurpriseRemovePending;
-       Status = STATUS_SUCCESS;
-       break;
-      default:
-       Status = Irp->IoStatus.Status;
-    }
-
-  Irp->IoStatus.Status = Status;
-  IoSkipCurrentIrpStackLocation ( Irp );
-  Status = IoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
-  return Status;
-}
-
 irp__handler_decl ( Bus_DispatchDeviceControl )
 {
   NTSTATUS Status;
@@ -565,14 +407,16 @@ irp__handler_decl ( Bus_DispatchDeviceControl )
            TargetWalker = TargetWalker->Next;
          }
        RtlCopyMemory ( Irp->AssociatedIrp.SystemBuffer, Targets,
-                       ( Stack->Parameters.
-                         DeviceIoControl.OutputBufferLength <
+                       ( Stack->Parameters.DeviceIoControl.
+                         OutputBufferLength <
                          ( sizeof ( MOUNT_TARGETS ) +
                            ( Count *
-                             sizeof ( MOUNT_TARGET ) ) ) ? Stack->
-                         Parameters.DeviceIoControl.OutputBufferLength
-                         : ( sizeof ( MOUNT_TARGETS ) +
-                             ( Count * sizeof ( MOUNT_TARGET ) ) ) ) );
+                             sizeof ( MOUNT_TARGET ) ) ) ? Stack->Parameters.
+                         DeviceIoControl.
+                         OutputBufferLength : ( sizeof ( MOUNT_TARGETS ) +
+                                                ( Count *
+                                                  sizeof
+                                                  ( MOUNT_TARGET ) ) ) ) );
        ExFreePool ( Targets );
 
        KeReleaseSpinLock ( &Bus_Globals_TargetListSpinLock, Irql );
@@ -621,14 +465,16 @@ irp__handler_decl ( Bus_DispatchDeviceControl )
            DiskWalker = DiskWalker->next_sibling_ptr;
          }
        RtlCopyMemory ( Irp->AssociatedIrp.SystemBuffer, Disks,
-                       ( Stack->Parameters.
-                         DeviceIoControl.OutputBufferLength <
+                       ( Stack->Parameters.DeviceIoControl.
+                         OutputBufferLength <
                          ( sizeof ( MOUNT_DISKS ) +
                            ( Count *
-                             sizeof ( MOUNT_DISK ) ) ) ? Stack->
-                         Parameters.DeviceIoControl.OutputBufferLength
-                         : ( sizeof ( MOUNT_DISKS ) +
-                             ( Count * sizeof ( MOUNT_DISK ) ) ) ) );
+                             sizeof ( MOUNT_DISK ) ) ) ? Stack->Parameters.
+                         DeviceIoControl.
+                         OutputBufferLength : ( sizeof ( MOUNT_DISKS ) +
+                                                ( Count *
+                                                  sizeof
+                                                  ( MOUNT_DISK ) ) ) ) );
        ExFreePool ( Disks );
 
        Status = STATUS_SUCCESS;
@@ -732,11 +578,6 @@ irp__handler_decl ( Bus_Dispatch )
        IoSkipCurrentIrpStackLocation ( Irp );
        Status = PoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
        break;
-      case IRP_MJ_PNP:
-       Status =
-         Bus_DispatchPnP ( DeviceObject, Irp, Stack, DeviceExtension,
-                           completion_ptr );
-       break;
       case IRP_MJ_SYSTEM_CONTROL:
        Status =
          Bus_DispatchSystemControl ( DeviceObject, Irp, Stack,
@@ -755,17 +596,6 @@ irp__handler_decl ( Bus_Dispatch )
   return Status;
 }
 
-static NTSTATUS STDCALL
-Bus_IoCompletionRoutine (
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  IN PKEVENT Event
- )
-{
-  KeSetEvent ( Event, 0, FALSE );
-  return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
 NTSTATUS STDCALL
 Bus_GetDeviceCapabilities (
   IN PDEVICE_OBJECT DeviceObject,
@@ -864,9 +694,9 @@ Bus_AddDevice (
     sizeof ( bus__type );
   RtlCopyMemory ( bus_dev_ext_ptr->irp_handler_stack_ptr,
                  driver__handling_table, driver__handling_table_size );
-  RtlCopyMemory ( ( winvblock__uint8 * ) bus_dev_ext_ptr->
-                 irp_handler_stack_ptr + driver__handling_table_size,
-                 handling_table, handling_table_size );
+  RtlCopyMemory ( ( winvblock__uint8 * ) bus_dev_ext_ptr->irp_handler_stack_ptr
+                 + driver__handling_table_size, handling_table,
+                 handling_table_size );
   bus_dev_ext_ptr->irp_handler_stack_size =
     ( driver__handling_table_size +
       handling_table_size ) / sizeof ( irp__handling );
index fbd5925..7c8343f 100644 (file)
--- a/src/bus.h
+++ b/src/bus.h
@@ -50,10 +50,6 @@ extern NTSTATUS STDCALL Bus_AddDevice (
   IN PDEVICE_OBJECT PhysicalDeviceObject
  );
 
-extern irp__handler_decl (
-  Bus_DispatchPnP
- );
-
 extern irp__handler_decl (
   Bus_DispatchDeviceControl
  );
diff --git a/src/bus_pnp.c b/src/bus_pnp.c
new file mode 100644 (file)
index 0000000..4a98787
--- /dev/null
@@ -0,0 +1,218 @@
+/**
+ * Copyright (C) 2009, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
+ * Copyright 2006-2008, V.
+ * For WinAoE contact information, see http://winaoe.org/
+ *
+ * This file is part of WinVBlock, derived from WinAoE.
+ *
+ * WinVBlock is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * WinVBlock is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with WinVBlock.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file
+ *
+ * Bus PnP IRP handling
+ *
+ */
+
+#include <ntddk.h>
+
+#include "winvblock.h"
+#include "portable.h"
+#include "irp.h"
+#include "driver.h"
+#include "disk.h"
+#include "bus.h"
+#include "debug.h"
+
+static NTSTATUS STDCALL
+Bus_IoCompletionRoutine (
+  IN PDEVICE_OBJECT DeviceObject,
+  IN PIRP Irp,
+  IN PKEVENT Event
+ )
+{
+  KeSetEvent ( Event, 0, FALSE );
+  return STATUS_MORE_PROCESSING_REQUIRED;
+}
+
+irp__handler_decl ( bus_pnp__start_dev )
+{
+  NTSTATUS status;
+  KEVENT event;
+  bus__type_ptr bus_ptr;
+
+  bus_ptr = get_bus_ptr ( DeviceExtension );
+  KeInitializeEvent ( &event, NotificationEvent, FALSE );
+  IoCopyCurrentIrpStackLocationToNext ( Irp );
+  IoSetCompletionRoutine ( Irp,
+                          ( PIO_COMPLETION_ROUTINE ) Bus_IoCompletionRoutine,
+                          ( PVOID ) & event, TRUE, TRUE, TRUE );
+  status = IoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
+  if ( status == STATUS_PENDING )
+    {
+      DBG ( "Locked\n" );
+      KeWaitForSingleObject ( &event, Executive, KernelMode, FALSE, NULL );
+    }
+  if ( NT_SUCCESS ( status = Irp->IoStatus.Status ) )
+    {
+      DeviceExtension->OldState = DeviceExtension->State;
+      DeviceExtension->State = Started;
+    }
+  status = STATUS_SUCCESS;
+  Irp->IoStatus.Status = status;
+  IoCompleteRequest ( Irp, IO_NO_INCREMENT );
+  *completion_ptr = TRUE;
+  return status;
+}
+
+irp__handler_decl ( bus_pnp__remove_dev )
+{
+  NTSTATUS status;
+  bus__type_ptr bus_ptr;
+  disk__type_ptr walker,
+   next;
+
+  DeviceExtension->OldState = DeviceExtension->State;
+  DeviceExtension->State = Deleted;
+  Irp->IoStatus.Information = 0;
+  Irp->IoStatus.Status = STATUS_SUCCESS;
+  IoSkipCurrentIrpStackLocation ( Irp );
+  bus_ptr = get_bus_ptr ( DeviceExtension );
+  status = IoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
+  walker = ( disk__type_ptr ) bus_ptr->first_child_ptr;
+  while ( walker != NULL )
+    {
+      next = walker->next_sibling_ptr;
+      IoDeleteDevice ( walker->dev_ext_ptr->Self );
+      walker = next;
+    }
+  bus_ptr->Children = 0;
+  bus_ptr->first_child_ptr = NULL;
+  IoDetachDevice ( bus_ptr->LowerDeviceObject );
+  IoDeleteDevice ( DeviceExtension->Self );
+  *completion_ptr = TRUE;
+  return status;
+}
+
+irp__handler_decl ( bus_pnp__query_dev_relations )
+{
+  NTSTATUS status;
+  bus__type_ptr bus_ptr;
+  ULONG count;
+  disk__type_ptr walker;
+  PDEVICE_RELATIONS dev_relations;
+
+  bus_ptr = get_bus_ptr ( DeviceExtension );
+  if ( Stack->Parameters.QueryDeviceRelations.Type != BusRelations
+       || Irp->IoStatus.Information )
+    {
+      status = Irp->IoStatus.Status;
+      IoSkipCurrentIrpStackLocation ( Irp );
+      status = IoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
+      *completion_ptr = TRUE;
+      return status;
+    }
+  count = 0;
+  walker = ( disk__type_ptr ) bus_ptr->first_child_ptr;
+  while ( walker != NULL )
+    {
+      count++;
+      walker = walker->next_sibling_ptr;
+    }
+  dev_relations =
+    ( PDEVICE_RELATIONS ) ExAllocatePool ( NonPagedPool,
+                                          sizeof ( DEVICE_RELATIONS ) +
+                                          ( sizeof ( PDEVICE_OBJECT ) *
+                                            count ) );
+  if ( dev_relations == NULL )
+    {
+      Irp->IoStatus.Information = 0;
+      status = STATUS_INSUFFICIENT_RESOURCES;
+      Irp->IoStatus.Status = status;
+      IoSkipCurrentIrpStackLocation ( Irp );
+      status = IoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
+      *completion_ptr = TRUE;
+      return status;
+    }
+  dev_relations->Count = count;
+
+  count = 0;
+  walker = ( disk__type_ptr ) bus_ptr->first_child_ptr;
+  while ( walker != NULL )
+    {
+      ObReferenceObject ( walker->dev_ext_ptr->Self );
+      dev_relations->Objects[count] = walker->dev_ext_ptr->Self;
+      count++;
+      walker = walker->next_sibling_ptr;
+    }
+  Irp->IoStatus.Information = ( ULONG_PTR ) dev_relations;
+  status = STATUS_SUCCESS;
+  Irp->IoStatus.Status = status;
+  IoSkipCurrentIrpStackLocation ( Irp );
+  status = IoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
+  *completion_ptr = TRUE;
+  return status;
+}
+
+irp__handler_decl ( bus_pnp__simple )
+{
+  NTSTATUS status;
+  bus__type_ptr bus_ptr;
+
+  bus_ptr = get_bus_ptr ( DeviceExtension );
+  switch ( Stack->MinorFunction )
+    {
+      case IRP_MN_QUERY_PNP_DEVICE_STATE:
+       Irp->IoStatus.Information = 0;
+       status = STATUS_SUCCESS;
+       break;
+      case IRP_MN_QUERY_STOP_DEVICE:
+       DeviceExtension->OldState = DeviceExtension->State;
+       DeviceExtension->State = StopPending;
+       status = STATUS_SUCCESS;
+       break;
+      case IRP_MN_CANCEL_STOP_DEVICE:
+       DeviceExtension->State = DeviceExtension->OldState;
+       status = STATUS_SUCCESS;
+       break;
+      case IRP_MN_STOP_DEVICE:
+       DeviceExtension->OldState = DeviceExtension->State;
+       DeviceExtension->State = Stopped;
+       status = STATUS_SUCCESS;
+       break;
+      case IRP_MN_QUERY_REMOVE_DEVICE:
+       DeviceExtension->OldState = DeviceExtension->State;
+       DeviceExtension->State = RemovePending;
+       status = STATUS_SUCCESS;
+       break;
+      case IRP_MN_CANCEL_REMOVE_DEVICE:
+       DeviceExtension->State = DeviceExtension->OldState;
+       status = STATUS_SUCCESS;
+       break;
+      case IRP_MN_SURPRISE_REMOVAL:
+       DeviceExtension->OldState = DeviceExtension->State;
+       DeviceExtension->State = SurpriseRemovePending;
+       status = STATUS_SUCCESS;
+       break;
+      default:
+       status = Irp->IoStatus.Status;
+    }
+
+  Irp->IoStatus.Status = status;
+  IoSkipCurrentIrpStackLocation ( Irp );
+  status = IoCallDriver ( bus_ptr->LowerDeviceObject, Irp );
+  *completion_ptr = TRUE;
+  return status;
+}
diff --git a/src/bus_pnp.h b/src/bus_pnp.h
new file mode 100644 (file)
index 0000000..c7a7cba
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2009, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
+ * Copyright 2006-2008, V.
+ * For WinAoE contact information, see http://winaoe.org/
+ *
+ * This file is part of WinVBlock, derived from WinAoE.
+ *
+ * WinVBlock is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * WinVBlock is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with WinVBlock.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _BUS_PNP_H
+#  define _BUS_PNP_H
+
+/**
+ * @file
+ *
+ * Bus PnP IRP handling
+ *
+ */
+
+extern irp__handler_decl (
+  bus_pnp__start_dev
+ );
+extern irp__handler_decl (
+  bus_pnp__remove_dev
+ );
+extern irp__handler_decl (
+  bus_pnp__query_dev_relations
+ );
+extern irp__handler_decl (
+  bus_pnp__simple
+ );
+
+#endif                         /* _BUS_PNP_H */