[ros-diffs] [cgutman] 36667: - Call the MiniportShutdown handler at the right time - Now we call it upon system shutdown and if a bug check occurred

cgutman at svn.reactos.org cgutman at svn.reactos.org
Mon Oct 6 20:56:45 CEST 2008


Author: cgutman
Date: Mon Oct  6 13:56:44 2008
New Revision: 36667

URL: http://svn.reactos.org/svn/reactos?rev=36667&view=rev
Log:
 - Call the MiniportShutdown handler at the right time
 - Now we call it upon system shutdown and if a bug check occurred

Modified:
    branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c

Modified: branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c
URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c?rev=36667&r1=36666&r2=36667&view=diff
==============================================================================
--- branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c [iso-8859-1] (original)
+++ branches/aicom-network-fixes/drivers/network/ndis/ndis/miniport.c [iso-8859-1] Mon Oct  6 13:56:44 2008
@@ -1137,8 +1137,10 @@
 
   NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
 
-  if(Adapter->BugcheckContext->ShutdownHandler)
+  if(Adapter->BugcheckContext->ShutdownHandler) {
     KeDeregisterBugCheckCallback(Adapter->BugcheckContext->CallbackRecord);
+    IoUnregisterShutdownNotification(Adapter->NdisMiniportBlock.DeviceObject);
+  }
 }
 
 
@@ -1306,12 +1308,9 @@
  */
 {
   PLOGICAL_ADAPTER            Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
-  PMINIPORT_BUGCHECK_CONTEXT  BugcheckContext = Adapter->BugcheckContext;
+  PMINIPORT_BUGCHECK_CONTEXT  BugcheckContext;
 
   NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
-
-  if(BugcheckContext)
-    return;
 
   BugcheckContext = ExAllocatePool(NonPagedPool, sizeof(MINIPORT_BUGCHECK_CONTEXT));
   if(!BugcheckContext)
@@ -1324,11 +1323,19 @@
   BugcheckContext->DriverContext = ShutdownContext;
 
   BugcheckContext->CallbackRecord = ExAllocatePool(NonPagedPool, sizeof(KBUGCHECK_CALLBACK_RECORD));
+  if (!BugcheckContext->CallbackRecord) {
+      ExFreePool(BugcheckContext);
+      return;
+  }
+
+  Adapter->BugcheckContext = BugcheckContext;
 
   KeInitializeCallbackRecord(BugcheckContext->CallbackRecord);
 
   KeRegisterBugCheckCallback(BugcheckContext->CallbackRecord, NdisIBugcheckCallback,
       BugcheckContext, sizeof(BugcheckContext), (PUCHAR)"Ndis Miniport");
+
+  IoRegisterShutdownNotification(Adapter->NdisMiniportBlock.DeviceObject);
 }
 
 
@@ -1781,6 +1788,28 @@
   return STATUS_SUCCESS;
 }
 
+NTSTATUS
+NTAPI
+NdisIShutdown(
+    IN PDEVICE_OBJECT DeviceObject,
+    PIRP Irp)
+{
+  PLOGICAL_ADAPTER Adapter = DeviceObject->DeviceExtension;
+  PMINIPORT_BUGCHECK_CONTEXT Context = Adapter->BugcheckContext;
+  ADAPTER_SHUTDOWN_HANDLER ShutdownHandler = Context->ShutdownHandler;
+
+  ASSERT(ShutdownHandler);
+
+  ShutdownHandler(Context->DriverContext);
+
+  Irp->IoStatus.Status = STATUS_SUCCESS;
+  Irp->IoStatus.Information = 0;
+
+  IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+  return STATUS_SUCCESS;
+}
+
 
 NTSTATUS
 NTAPI
@@ -2075,6 +2104,7 @@
   *MiniportPtr = Miniport;
 
   Miniport->DriverObject->MajorFunction[IRP_MJ_PNP] = NdisIDispatchPnp;
+  Miniport->DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = NdisIShutdown;
   Miniport->DriverObject->DriverExtension->AddDevice = NdisIAddDevice;
 
   return NDIS_STATUS_SUCCESS;



More information about the Ros-diffs mailing list