[NDIS]
authorCameron Gutman <aicommander@gmail.com>
Sun, 1 Mar 2015 10:43:12 +0000 (10:43 +0000)
committerCameron Gutman <aicommander@gmail.com>
Sun, 1 Mar 2015 10:43:12 +0000 (10:43 +0000)
- Fix a bugcheck caused when drivers pend requests NDIS-internal requests issued during initialization
- Fixes Dell 1390 WLAN card (currently scanning via wlanconf isn't working, but connecting via SSID works)

svn path=/trunk/; revision=66514

reactos/drivers/network/ndis/ndis/miniport.c

index cd5c61b..732fecb 100644 (file)
@@ -495,11 +495,25 @@ MiniRequestComplete(
 
     MacBlock = (PNDIS_REQUEST_MAC_BLOCK)Request->MacReserved;
 
-    if( MacBlock->Binding->RequestCompleteHandler ) {
-        (*MacBlock->Binding->RequestCompleteHandler)(
-            MacBlock->Binding->ProtocolBindingContext,
-            Request,
-            Status);
+    /* We may or may not be doing this request on behalf of an adapter binding */
+    if (MacBlock->Binding != NULL)
+    {
+        /* We are, so invoke its request complete handler */
+        if (MacBlock->Binding->RequestCompleteHandler != NULL)
+        {
+            (*MacBlock->Binding->RequestCompleteHandler)(
+                MacBlock->Binding->ProtocolBindingContext,
+                Request,
+                Status);
+        }
+    }
+    else
+    {
+        /* We are doing this internally, so we'll signal this event we've stashed in the MacBlock */
+        ASSERT(MacBlock->Unknown1 != NULL);
+        ASSERT(MacBlock->Unknown3 == NULL);
+        MacBlock->Unknown3 = (PVOID)Status;
+        KeSetEvent(MacBlock->Unknown1, IO_NO_INCREMENT, FALSE);
     }
 
     KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
@@ -746,6 +760,8 @@ MiniSetInformation(
 {
   NDIS_STATUS NdisStatus;
   PNDIS_REQUEST NdisRequest;
+  KEVENT Event;
+  PNDIS_REQUEST_MAC_BLOCK MacBlock;
 
   NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
 
@@ -762,11 +778,19 @@ MiniSetInformation(
   NdisRequest->DATA.SET_INFORMATION.InformationBuffer = Buffer;
   NdisRequest->DATA.SET_INFORMATION.InformationBufferLength = Size;
 
-  NdisStatus = MiniDoRequest(Adapter, NdisRequest);
+  /* We'll need to give the completion routine some way of letting us know
+   * when it's finished. We'll stash a pointer to an event in the MacBlock */
+  KeInitializeEvent(&Event, NotificationEvent, FALSE);
+  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
+  MacBlock->Unknown1 = &Event;
 
-  /* FIXME: Wait in pending case! */
+  NdisStatus = MiniDoRequest(Adapter, NdisRequest);
 
-  ASSERT(NdisStatus != NDIS_STATUS_PENDING);
+  if (NdisStatus == NDIS_STATUS_PENDING)
+  {
+      KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+      NdisStatus = (NDIS_STATUS)MacBlock->Unknown3;
+  }
 
   *BytesRead = NdisRequest->DATA.SET_INFORMATION.BytesRead;
 
@@ -796,6 +820,8 @@ MiniQueryInformation(
 {
   NDIS_STATUS NdisStatus;
   PNDIS_REQUEST NdisRequest;
+  KEVENT Event;
+  PNDIS_REQUEST_MAC_BLOCK MacBlock;
 
   NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
 
@@ -812,11 +838,19 @@ MiniQueryInformation(
   NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer = Buffer;
   NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength = Size;
 
-  NdisStatus = MiniDoRequest(Adapter, NdisRequest);
+  /* We'll need to give the completion routine some way of letting us know
+   * when it's finished. We'll stash a pointer to an event in the MacBlock */
+  KeInitializeEvent(&Event, NotificationEvent, FALSE);
+  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
+  MacBlock->Unknown1 = &Event;
 
-  /* FIXME: Wait in pending case! */
+  NdisStatus = MiniDoRequest(Adapter, NdisRequest);
 
-  ASSERT(NdisStatus != NDIS_STATUS_PENDING);
+  if (NdisStatus == NDIS_STATUS_PENDING)
+  {
+      KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+      NdisStatus = (NDIS_STATUS)MacBlock->Unknown3;
+  }
 
   *BytesWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten;