ReactOS  0.4.13-dev-52-g0efcfec
miniport.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS NDIS library
4  * FILE: ndis/miniport.c
5  * PURPOSE: Routines used by NDIS miniport drivers
6  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7  * Vizzini (vizzini@plasmic.com)
8  * REVISIONS:
9  * CSH 01/08-2000 Created
10  * 20 Aug 2003 vizzini - DMA support
11  * 3 Oct 2003 vizzini - SendPackets support
12  */
13 
14 #include "ndissys.h"
15 
16 #include <ndisguid.h>
17 
18 /*
19  * Define to 1 to get a debugger breakpoint at the end of NdisInitializeWrapper
20  * for each new miniport starting up
21  */
22 #define BREAK_ON_MINIPORT_INIT 0
23 
24 /*
25  * This has to be big enough to hold the results of querying the Route value
26  * from the Linkage key. Please re-code me to determine this dynamically.
27  */
28 #define ROUTE_DATA_SIZE 256
29 
30 /* Number of media we know */
31 #define MEDIA_ARRAY_SIZE 15
32 
34 {
50 };
51 
52 /* global list and lock of Miniports NDIS has registered */
55 
56 /* global list and lock of adapters NDIS has registered */
59 
60 VOID
63  PCSTR Reason)
64 {
65 #if DBG
66  ULONG i, Length;
67  UCHAR Buffer[64];
68  if ((DebugTraceLevel & DEBUG_PACKET) > 0) {
70  Buffer,
71  Packet,
72  0,
73  64);
74 
75  DbgPrint("*** %s PACKET START (%p) ***\n", Reason, Packet);
76 
77  for (i = 0; i < Length; i++) {
78  if (i % 16 == 0)
79  DbgPrint("\n%04X ", i);
80  DbgPrint("%02X ", Buffer[i]);
81  }
82 
83  DbgPrint("\n*** %s PACKET STOP ***\n", Reason);
84  }
85 #endif /* DBG */
86 }
87 
88 VOID
90  PVOID HeaderBuffer,
91  UINT HeaderBufferSize,
92  PVOID LookaheadBuffer,
93  UINT LookaheadBufferSize)
94 {
95 #if DBG
96  if ((DebugTraceLevel & DEBUG_PACKET) > 0) {
97  ULONG i, Length;
98  PUCHAR p;
99 
100  DbgPrint("*** RECEIVE PACKET START ***\n");
101  DbgPrint("HEADER:");
102  p = HeaderBuffer;
103  for (i = 0; i < HeaderBufferSize; i++) {
104  if (i % 16 == 0)
105  DbgPrint("\n%04X ", i);
106  DbgPrint("%02X ", *p++);
107  }
108 
109  DbgPrint("\nFRAME:");
110 
111  p = LookaheadBuffer;
112  Length = (LookaheadBufferSize < 64)? LookaheadBufferSize : 64;
113  for (i = 0; i < Length; i++) {
114  if (i % 16 == 0)
115  DbgPrint("\n%04X ", i);
116  DbgPrint("%02X ", *p++);
117  }
118 
119  DbgPrint("\n*** RECEIVE PACKET STOP ***\n");
120  }
121 #endif /* DBG */
122 }
123 
126  PLOGICAL_ADAPTER Adapter,
128 {
129  PNDIS_MINIPORT_WORK_ITEM CurrentEntry = Adapter->WorkQueueHead;
130 
131  while (CurrentEntry)
132  {
133  if (CurrentEntry->WorkItemType == Type || Type == NdisMaxWorkItems)
134  return CurrentEntry;
135 
136  CurrentEntry = (PNDIS_MINIPORT_WORK_ITEM)CurrentEntry->Link.Next;
137  }
138 
139  return NULL;
140 }
141 
142 BOOLEAN
144  PLOGICAL_ADAPTER Adapter,
146 {
147  BOOLEAN Busy = FALSE;
148  KIRQL OldIrql;
149 
151 
152  if (MiniGetFirstWorkItem(Adapter, Type))
153  {
154  Busy = TRUE;
155  }
157  {
158  Busy = TRUE;
159  }
161  {
162  Busy = TRUE;
163  }
164  else if (Type == NdisWorkItemResetRequested &&
166  {
167  Busy = TRUE;
168  }
169 
171 
172  return Busy;
173 }
174 
175 VOID
177  PLOGICAL_ADAPTER Adapter,
178  NDIS_HANDLE MacReceiveContext,
179  PVOID HeaderBuffer,
180  UINT HeaderBufferSize,
181  PVOID LookaheadBuffer,
182  UINT LookaheadBufferSize,
184 /*
185  * FUNCTION: Indicate received data to bound protocols
186  * ARGUMENTS:
187  * Adapter = Pointer to logical adapter
188  * MacReceiveContext = MAC receive context handle
189  * HeaderBuffer = Pointer to header buffer
190  * HeaderBufferSize = Size of header buffer
191  * LookaheadBuffer = Pointer to lookahead buffer
192  * LookaheadBufferSize = Size of lookahead buffer
193  * PacketSize = Total size of received packet
194  */
195 {
196  KIRQL OldIrql;
197  PLIST_ENTRY CurrentEntry;
198  PADAPTER_BINDING AdapterBinding;
199 
200  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called. Adapter (0x%X) HeaderBuffer (0x%X) "
201  "HeaderBufferSize (0x%X) LookaheadBuffer (0x%X) LookaheadBufferSize (0x%X).\n",
202  Adapter, HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize));
203 
204  MiniDisplayPacket2(HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize);
205 
206  NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
208  {
209  CurrentEntry = Adapter->ProtocolListHead.Flink;
210  NDIS_DbgPrint(DEBUG_MINIPORT, ("CurrentEntry = %x\n", CurrentEntry));
211 
212  if (CurrentEntry == &Adapter->ProtocolListHead)
213  {
214  NDIS_DbgPrint(MIN_TRACE, ("WARNING: No upper protocol layer.\n"));
215  }
216 
217  while (CurrentEntry != &Adapter->ProtocolListHead)
218  {
219  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
220  NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterBinding = %x\n", AdapterBinding));
221 
223  (MID_TRACE,
224  ("XXX (%x) %x %x %x %x %x %x %x XXX\n",
225  *AdapterBinding->ProtocolBinding->Chars.ReceiveHandler,
226  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
227  MacReceiveContext,
228  HeaderBuffer,
229  HeaderBufferSize,
230  LookaheadBuffer,
231  LookaheadBufferSize,
232  PacketSize));
233 
234  /* call the receive handler */
235  (*AdapterBinding->ProtocolBinding->Chars.ReceiveHandler)(
236  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
237  MacReceiveContext,
238  HeaderBuffer,
239  HeaderBufferSize,
240  LookaheadBuffer,
241  LookaheadBufferSize,
242  PacketSize);
243 
244  CurrentEntry = CurrentEntry->Flink;
245  }
246  }
248 
249  NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
250 }
251 
252 /*
253  * @implemented
254  */
255 VOID
256 EXPORT
258  IN PNDIS_PACKET *PacketsToReturn,
260 /*
261  * FUNCTION: Releases ownership of one or more packets
262  * ARGUMENTS:
263  * PacketsToReturn = Pointer to an array of pointers to packet descriptors
264  * NumberOfPackets = Number of pointers in descriptor pointer array
265  */
266 {
267  UINT i;
268  PLOGICAL_ADAPTER Adapter;
269  KIRQL OldIrql;
270 
271  NDIS_DbgPrint(MID_TRACE, ("Returning %d packets\n", NumberOfPackets));
272 
273  for (i = 0; i < NumberOfPackets; i++)
274  {
275  PacketsToReturn[i]->WrapperReserved[0]--;
276  if (PacketsToReturn[i]->WrapperReserved[0] == 0)
277  {
278  Adapter = (PVOID)(ULONG_PTR)PacketsToReturn[i]->Reserved[1];
279 
280  NDIS_DbgPrint(MAX_TRACE, ("Freeing packet %d (adapter = 0x%p)\n", i, Adapter));
281 
283  Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ReturnPacketHandler(
285  PacketsToReturn[i]);
287  }
288  }
289 }
290 
291 VOID NTAPI
296 /*
297  * FUNCTION: receives miniport packet array indications
298  * ARGUMENTS:
299  * MiniportAdapterHandle: Miniport handle for the adapter
300  * PacketArray: pointer to a list of packet pointers to indicate
301  * NumberOfPackets: number of packets to indicate
302  *
303  */
304 {
306  PLIST_ENTRY CurrentEntry;
307  PADAPTER_BINDING AdapterBinding;
308  KIRQL OldIrql;
309  UINT i;
310 
312 
313  CurrentEntry = Adapter->ProtocolListHead.Flink;
314 
315  while (CurrentEntry != &Adapter->ProtocolListHead)
316  {
317  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
318 
319  for (i = 0; i < NumberOfPackets; i++)
320  {
321  /* Store the indicating miniport in the packet */
322  PacketArray[i]->Reserved[1] = (ULONG_PTR)Adapter;
323 
324  if (AdapterBinding->ProtocolBinding->Chars.ReceivePacketHandler &&
326  {
327  NDIS_DbgPrint(MID_TRACE, ("Indicating packet to protocol's ReceivePacket handler\n"));
329  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
330  PacketArray[i]);
331  NDIS_DbgPrint(MID_TRACE, ("Protocol is holding %d references to the packet\n", PacketArray[i]->WrapperReserved[0]));
332  }
333  else
334  {
335  UINT FirstBufferLength, TotalBufferLength, LookAheadSize, HeaderSize;
336  PNDIS_BUFFER NdisBuffer;
337  PVOID NdisBufferVA, LookAheadBuffer;
338 
340  &NdisBuffer,
341  &NdisBufferVA,
342  &FirstBufferLength,
343  &TotalBufferLength);
344 
346 
347  LookAheadSize = TotalBufferLength - HeaderSize;
348 
349  LookAheadBuffer = ExAllocatePool(NonPagedPool, LookAheadSize);
350  if (!LookAheadBuffer)
351  {
352  NDIS_DbgPrint(MIN_TRACE, ("Failed to allocate lookahead buffer!\n"));
354  return;
355  }
356 
357  CopyBufferChainToBuffer(LookAheadBuffer,
358  NdisBuffer,
359  HeaderSize,
360  LookAheadSize);
361 
362  NDIS_DbgPrint(MID_TRACE, ("Indicating packet to protocol's legacy Receive handler\n"));
363  (*AdapterBinding->ProtocolBinding->Chars.ReceiveHandler)(
364  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
365  AdapterBinding->NdisOpenBlock.MacHandle,
366  NdisBufferVA,
367  HeaderSize,
368  LookAheadBuffer,
369  LookAheadSize,
370  TotalBufferLength - HeaderSize);
371 
372  ExFreePool(LookAheadBuffer);
373  }
374  }
375 
376  CurrentEntry = CurrentEntry->Flink;
377  }
378 
379  /* Loop the packet array to get everything
380  * set up for return the packets to the miniport */
381  for (i = 0; i < NumberOfPackets; i++)
382  {
383  /* First, check the initial packet status */
385  {
386  /* The miniport driver gets it back immediately so nothing to do here */
387  NDIS_DbgPrint(MID_TRACE, ("Miniport needs the packet back immediately\n"));
388  continue;
389  }
390 
391  /* Different behavior depending on whether it's serialized or not */
393  {
394  /* We need to check the reference count */
395  if (PacketArray[i]->WrapperReserved[0] == 0)
396  {
397  /* NOTE: Unlike serialized miniports, this is REQUIRED to be called for each
398  * packet received that can be reused immediately, it is not implied! */
399  Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ReturnPacketHandler(
401  PacketArray[i]);
402  NDIS_DbgPrint(MID_TRACE, ("Packet has been returned to miniport (Deserialized)\n"));
403  }
404  else
405  {
406  /* Packet will be returned by the protocol's call to NdisReturnPackets */
407  NDIS_DbgPrint(MID_TRACE, ("Packet will be returned to miniport later (Deserialized)\n"));
408  }
409  }
410  else
411  {
412  /* Check the reference count */
413  if (PacketArray[i]->WrapperReserved[0] == 0)
414  {
415  /* NDIS_STATUS_SUCCESS means the miniport can have the packet back immediately */
417 
418  NDIS_DbgPrint(MID_TRACE, ("Packet has been returned to miniport (Serialized)\n"));
419  }
420  else
421  {
422  /* NDIS_STATUS_PENDING means the miniport needs to wait for MiniportReturnPacket */
424 
425  NDIS_DbgPrint(MID_TRACE, ("Packet will be returned to miniport later (Serialized)\n"));
426  }
427  }
428  }
429 
431 }
432 
433 VOID NTAPI
437  IN BOOLEAN AddressingReset)
438 {
440  PLIST_ENTRY CurrentEntry;
441  PADAPTER_BINDING AdapterBinding;
442  KIRQL OldIrql;
443 
444  if (AddressingReset)
445  MiniDoAddressingReset(Adapter);
446 
449 
451 
453  {
454  KeBugCheckEx(BUGCODE_ID_DRIVER,
456  (ULONG_PTR)Status,
457  (ULONG_PTR)AddressingReset,
458  0);
459  }
460 
462 
463  CurrentEntry = Adapter->ProtocolListHead.Flink;
464 
465  while (CurrentEntry != &Adapter->ProtocolListHead)
466  {
467  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
468 
469  (*AdapterBinding->ProtocolBinding->Chars.ResetCompleteHandler)(
470  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
471  Status);
472 
473  CurrentEntry = CurrentEntry->Flink;
474  }
475 
477 }
478 
479 VOID NTAPI
483 {
486  PNDIS_REQUEST_MAC_BLOCK MacBlock;
487  KIRQL OldIrql;
488 
489  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
490 
492 
496 
497  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)Request->MacReserved;
498 
499  /* We may or may not be doing this request on behalf of an adapter binding */
500  if (MacBlock->Binding != NULL)
501  {
502  /* We are, so invoke its request complete handler */
503  if (MacBlock->Binding->RequestCompleteHandler != NULL)
504  {
505  (*MacBlock->Binding->RequestCompleteHandler)(
506  MacBlock->Binding->ProtocolBindingContext,
507  Request,
508  Status);
509  }
510  }
511  else
512  {
513  /* We are doing this internally, so we'll signal this event we've stashed in the MacBlock */
514  ASSERT(MacBlock->Unknown1 != NULL);
515  ASSERT(MacBlock->Unknown3 == NULL);
516  MacBlock->Unknown3 = UlongToPtr(Status);
518  }
519 
524 
526 }
527 
528 VOID NTAPI
533 /*
534  * FUNCTION: Forwards a message to the initiating protocol saying
535  * that a packet was handled
536  * ARGUMENTS:
537  * NdisAdapterHandle = Handle input to MiniportInitialize
538  * Packet = Pointer to NDIS packet that was sent
539  * Status = Status of send operation
540  */
541 {
543  PADAPTER_BINDING AdapterBinding;
544  KIRQL OldIrql;
545  PSCATTER_GATHER_LIST SGList;
546 
547  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
548 
549  AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[1];
550 
552 
553  if (Adapter->NdisMiniportBlock.ScatterGatherListSize != 0)
554  {
555  NDIS_DbgPrint(MAX_TRACE, ("Freeing Scatter/Gather list\n"));
556 
559 
560  Adapter->NdisMiniportBlock.SystemAdapterObject->
561  DmaOperations->PutScatterGatherList(
562  Adapter->NdisMiniportBlock.SystemAdapterObject,
563  SGList,
564  TRUE);
565 
568  }
569 
570  (*AdapterBinding->ProtocolBinding->Chars.SendCompleteHandler)(
571  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
572  Packet,
573  Status);
574 
576 
578 }
579 
580 
581 VOID NTAPI
584 {
585  /* Run the work if anything is waiting */
587 }
588 
589 
590 VOID NTAPI
595  IN UINT BytesTransferred)
596 {
597  PADAPTER_BINDING AdapterBinding;
598  KIRQL OldIrql;
599 
600  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
601 
602  AdapterBinding = (PADAPTER_BINDING)Packet->Reserved[1];
603 
606  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
607  Packet,
608  Status,
609  BytesTransferred);
611 }
612 
613 
614 BOOLEAN
616  PLOGICAL_ADAPTER Adapter,
618 /*
619  * FUNCTION: Determines whether a packet has the same destination address as an adapter
620  * ARGUMENTS:
621  * Adapter = Pointer to logical adapter object
622  * Packet = Pointer to NDIS packet
623  * RETURNS:
624  * TRUE if the destination address is that of the adapter, FALSE if not
625  */
626 {
627  UINT Length;
628  PUCHAR PacketAddress;
629  PUCHAR AdapterAddress;
630  PNDIS_BUFFER NdisBuffer;
632 
633  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
634 
635 #if DBG
636  if(!Adapter)
637  {
638  NDIS_DbgPrint(MIN_TRACE, ("Adapter object was null\n"));
639  return FALSE;
640  }
641 
642  if(!Packet)
643  {
644  NDIS_DbgPrint(MIN_TRACE, ("Packet was null\n"));
645  return FALSE;
646  }
647 #endif
648 
649  NdisQueryPacket(Packet, NULL, NULL, &NdisBuffer, NULL);
650 
651  if (!NdisBuffer)
652  {
653  NDIS_DbgPrint(MIN_TRACE, ("Packet contains no buffers.\n"));
654  return FALSE;
655  }
656 
657  NdisQueryBuffer(NdisBuffer, (PVOID)&PacketAddress, &BufferLength);
658 
659  /* FIXME: Should handle fragmented packets */
660 
661  switch (Adapter->NdisMiniportBlock.MediaType)
662  {
663  case NdisMedium802_3:
665  /* Destination address is the first field */
666  break;
667 
668  default:
669  NDIS_DbgPrint(MIN_TRACE, ("Adapter has unsupported media type (0x%X).\n", Adapter->NdisMiniportBlock.MediaType));
670  return FALSE;
671  }
672 
673  if (BufferLength < Length)
674  {
675  NDIS_DbgPrint(MIN_TRACE, ("Buffer is too small.\n"));
676  return FALSE;
677  }
678 
679  AdapterAddress = (PUCHAR)&Adapter->Address;
680  NDIS_DbgPrint(MAX_TRACE, ("packet address: %x:%x:%x:%x:%x:%x adapter address: %x:%x:%x:%x:%x:%x\n",
681  *(PacketAddress), *(PacketAddress+1), *(PacketAddress+2), *(PacketAddress+3), *(PacketAddress+4), *(PacketAddress+5),
682  *(AdapterAddress), *(AdapterAddress+1), *(AdapterAddress+2), *(AdapterAddress+3), *(AdapterAddress+4), *(AdapterAddress+5)));
683 
684  return (RtlCompareMemory(PacketAddress, AdapterAddress, Length) == Length);
685 }
686 
687 
691 /*
692  * FUNCTION: Finds an adapter object by name
693  * ARGUMENTS:
694  * AdapterName = Pointer to name of adapter
695  * RETURNS:
696  * Pointer to logical adapter object, or NULL if none was found.
697  * If found, the adapter is referenced for the caller. The caller
698  * is responsible for dereferencing after use
699  */
700 {
701  KIRQL OldIrql;
702  PLIST_ENTRY CurrentEntry;
703  PLOGICAL_ADAPTER Adapter = 0;
704 
706 
707  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
708 
710  {
711  NDIS_DbgPrint(MIN_TRACE, ("No registered miniports for protocol to bind to\n"));
712  return NULL;
713  }
714 
715  NDIS_DbgPrint(DEBUG_MINIPORT, ("AdapterName = %wZ\n", AdapterName));
716 
718  {
719  CurrentEntry = AdapterListHead.Flink;
720 
721  while (CurrentEntry != &AdapterListHead)
722  {
723  Adapter = CONTAINING_RECORD(CurrentEntry, LOGICAL_ADAPTER, ListEntry);
724 
725  ASSERT(Adapter);
726 
727  NDIS_DbgPrint(DEBUG_MINIPORT, ("Examining adapter 0x%lx\n", Adapter));
728 
729  /* We're technically not allowed to call this above PASSIVE_LEVEL, but it doesn't break
730  * right now and I'd rather use a working API than reimplement it here */
732  {
733  break;
734  }
735 
736  Adapter = NULL;
737  CurrentEntry = CurrentEntry->Flink;
738  }
739  }
741 
742  if(Adapter)
743  {
744  NDIS_DbgPrint(DEBUG_MINIPORT, ("Leaving. Adapter found at 0x%x\n", Adapter));
745  }
746  else
747  {
748  NDIS_DbgPrint(MIN_TRACE, ("Leaving (adapter not found for %wZ).\n", AdapterName));
749  }
750 
751  return Adapter;
752 }
753 
756  PLOGICAL_ADAPTER Adapter,
757  NDIS_OID Oid,
758  ULONG Size,
759  PVOID Buffer,
761 {
762  NDIS_STATUS NdisStatus;
764  KEVENT Event;
765  PNDIS_REQUEST_MAC_BLOCK MacBlock;
766 
767  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
768 
770  if (!NdisRequest) {
771  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
772  return NDIS_STATUS_RESOURCES;
773  }
774 
776 
777  NdisRequest->RequestType = NdisRequestSetInformation;
778  NdisRequest->DATA.SET_INFORMATION.Oid = Oid;
779  NdisRequest->DATA.SET_INFORMATION.InformationBuffer = Buffer;
780  NdisRequest->DATA.SET_INFORMATION.InformationBufferLength = Size;
781 
782  /* We'll need to give the completion routine some way of letting us know
783  * when it's finished. We'll stash a pointer to an event in the MacBlock */
785  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
786  MacBlock->Unknown1 = &Event;
787 
788  NdisStatus = MiniDoRequest(Adapter, NdisRequest);
789 
790  if (NdisStatus == NDIS_STATUS_PENDING)
791  {
793  NdisStatus = PtrToUlong(MacBlock->Unknown3);
794  }
795 
796  *BytesRead = NdisRequest->DATA.SET_INFORMATION.BytesRead;
797 
799 
800  return NdisStatus;
801 }
802 
805  PLOGICAL_ADAPTER Adapter,
806  NDIS_OID Oid,
807  ULONG Size,
808  PVOID Buffer,
810 /*
811  * FUNCTION: Queries a logical adapter for properties
812  * ARGUMENTS:
813  * Adapter = Pointer to the logical adapter object to query
814  * Oid = Specifies the Object ID to query for
815  * Size = Size of the passed buffer
816  * Buffer = Buffer for the output
817  * BytesWritten = Address of buffer to place number of bytes written
818  * RETURNS:
819  * Status of operation
820  */
821 {
822  NDIS_STATUS NdisStatus;
824  KEVENT Event;
825  PNDIS_REQUEST_MAC_BLOCK MacBlock;
826 
827  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
828 
830  if (!NdisRequest) {
831  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
832  return NDIS_STATUS_RESOURCES;
833  }
834 
836 
838  NdisRequest->DATA.QUERY_INFORMATION.Oid = Oid;
839  NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer = Buffer;
840  NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength = Size;
841 
842  /* We'll need to give the completion routine some way of letting us know
843  * when it's finished. We'll stash a pointer to an event in the MacBlock */
845  MacBlock = (PNDIS_REQUEST_MAC_BLOCK)NdisRequest->MacReserved;
846  MacBlock->Unknown1 = &Event;
847 
848  NdisStatus = MiniDoRequest(Adapter, NdisRequest);
849 
850  if (NdisStatus == NDIS_STATUS_PENDING)
851  {
853  NdisStatus = PtrToUlong(MacBlock->Unknown3);
854  }
855 
856  *BytesWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten;
857 
859 
860  return NdisStatus;
861 }
862 
863 BOOLEAN
865 /*
866  * FUNCTION: Checks to see if the miniport is hung
867  * ARGUMENTS:
868  * Adapter = Pointer to the logical adapter object
869  * RETURNS:
870  * TRUE if the miniport is hung
871  * FALSE if the miniport is not hung
872  */
873 {
874  BOOLEAN Ret = FALSE;
875  KIRQL OldIrql;
876 
878  if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)
879  Ret = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CheckForHangHandler)(
882 
883  return Ret;
884 }
885 
886 VOID
888 {
890 
891  MiniSetInformation(Adapter,
893  sizeof(ULONG),
895  &BytesRead);
896 
897  /* FIXME: Set more stuff */
898 }
899 
902  PLOGICAL_ADAPTER Adapter)
903 /*
904  * FUNCTION: Resets the miniport
905  * ARGUMENTS:
906  * Adapter = Pointer to the logical adapter object
907  * RETURNS:
908  * Status of the operation
909  */
910 {
912  KIRQL OldIrql;
913  BOOLEAN AddressingReset = TRUE;
914 
915  if (MiniIsBusy(Adapter, NdisWorkItemResetRequested)) {
917  return NDIS_STATUS_PENDING;
918  }
919 
922 
924  Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
925  &AddressingReset,
927 
931 
933 
934  if (Status != NDIS_STATUS_PENDING) {
935  if (AddressingReset)
936  MiniDoAddressingReset(Adapter);
937 
940 
942  }
943 
944  return Status;
945 }
946 
947 VOID NTAPI
949  PKDPC Dpc,
953 {
955 
956  if (MiniCheckForHang(Adapter)) {
957  NDIS_DbgPrint(MIN_TRACE, ("Miniport detected adapter hang\n"));
958  MiniReset(Adapter);
959  }
960 }
961 
962 VOID
964  PLOGICAL_ADAPTER Adapter,
965  NDIS_WORK_ITEM_TYPE WorkItemType)
966 {
968 
969  /* Check if there's anything queued to run after this work item */
970  if (!MiniIsBusy(Adapter, WorkItemType))
971  return;
972 
973  /* There is, so fire the worker */
975  if (IoWorkItem)
977 }
978 
979 VOID
980 FASTCALL
982  PLOGICAL_ADAPTER Adapter,
983  NDIS_WORK_ITEM_TYPE WorkItemType,
984  PVOID WorkItemContext,
985  BOOLEAN Top)
986 /*
987  * FUNCTION: Queues a work item for execution at a later time
988  * ARGUMENTS:
989  * Adapter = Pointer to the logical adapter object to queue work item on
990  * WorkItemType = Type of work item to queue
991  * WorkItemContext = Pointer to context information for work item
992  * RETURNS:
993  * Status of operation
994  */
995 {
996  PNDIS_MINIPORT_WORK_ITEM MiniportWorkItem;
997  KIRQL OldIrql;
998 
999  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1000 
1001  ASSERT(Adapter);
1002 
1004  if (Top)
1005  {
1006  if (WorkItemType == NdisWorkItemSend)
1007  {
1008  NDIS_DbgPrint(MIN_TRACE, ("Requeuing failed packet (%x).\n", WorkItemContext));
1009  Adapter->NdisMiniportBlock.FirstPendingPacket = WorkItemContext;
1010  }
1011  else
1012  {
1013  //This should never happen
1014  ASSERT(FALSE);
1015  }
1016  }
1017  else
1018  {
1019  MiniportWorkItem = ExAllocatePool(NonPagedPool, sizeof(NDIS_MINIPORT_WORK_ITEM));
1020  if (!MiniportWorkItem)
1021  {
1023  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1024  return;
1025  }
1026 
1027  MiniportWorkItem->WorkItemType = WorkItemType;
1028  MiniportWorkItem->WorkItemContext = WorkItemContext;
1029 
1030  /* safe due to adapter lock held */
1031  MiniportWorkItem->Link.Next = NULL;
1032  if (!Adapter->WorkQueueHead)
1033  {
1034  Adapter->WorkQueueHead = MiniportWorkItem;
1035  Adapter->WorkQueueTail = MiniportWorkItem;
1036  }
1037  else
1038  {
1039  Adapter->WorkQueueTail->Link.Next = (PSINGLE_LIST_ENTRY)MiniportWorkItem;
1040  Adapter->WorkQueueTail = MiniportWorkItem;
1041  }
1042  }
1043 
1045 }
1046 
1048 FASTCALL
1050  PLOGICAL_ADAPTER Adapter,
1051  NDIS_WORK_ITEM_TYPE *WorkItemType,
1052  PVOID *WorkItemContext)
1053 /*
1054  * FUNCTION: Dequeues a work item from the work queue of a logical adapter
1055  * ARGUMENTS:
1056  * Adapter = Pointer to the logical adapter object to dequeue work item from
1057  * AdapterBinding = Address of buffer for adapter binding for this request
1058  * WorkItemType = Address of buffer for work item type
1059  * WorkItemContext = Address of buffer for pointer to context information
1060  * NOTES:
1061  * Adapter lock must be held when called
1062  * RETURNS:
1063  * Status of operation
1064  */
1065 {
1066  PNDIS_MINIPORT_WORK_ITEM MiniportWorkItem;
1068 
1069  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1070 
1071  MiniportWorkItem = Adapter->WorkQueueHead;
1072 
1073  if ((Packet = Adapter->NdisMiniportBlock.FirstPendingPacket))
1074  {
1076 
1077  *WorkItemType = NdisWorkItemSend;
1078  *WorkItemContext = Packet;
1079 
1080  return NDIS_STATUS_SUCCESS;
1081  }
1082  else if (MiniportWorkItem)
1083  {
1084  /* safe due to adapter lock held */
1085  Adapter->WorkQueueHead = (PNDIS_MINIPORT_WORK_ITEM)MiniportWorkItem->Link.Next;
1086 
1087  if (MiniportWorkItem == Adapter->WorkQueueTail)
1088  Adapter->WorkQueueTail = NULL;
1089 
1090  *WorkItemType = MiniportWorkItem->WorkItemType;
1091  *WorkItemContext = MiniportWorkItem->WorkItemContext;
1092 
1093  ExFreePool(MiniportWorkItem);
1094 
1095  return NDIS_STATUS_SUCCESS;
1096  }
1097  else
1098  {
1099  NDIS_DbgPrint(MIN_TRACE, ("No work item to dequeue\n"));
1100 
1101  return NDIS_STATUS_FAILURE;
1102  }
1103 }
1104 
1107  PLOGICAL_ADAPTER Adapter,
1109 /*
1110  * FUNCTION: Sends a request to a miniport
1111  * ARGUMENTS:
1112  * AdapterBinding = Pointer to binding used in the request
1113  * NdisRequest = Pointer to NDIS request structure describing request
1114  * RETURNS:
1115  * Status of operation
1116  */
1117 {
1119  KIRQL OldIrql;
1120  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1121 
1123 
1127 
1128  if (!Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CoRequestHandler)
1129  {
1130  switch (NdisRequest->RequestType)
1131  {
1133  Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
1135  NdisRequest->DATA.QUERY_INFORMATION.Oid,
1136  NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
1137  NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
1138  (PULONG)&NdisRequest->DATA.QUERY_INFORMATION.BytesWritten,
1139  (PULONG)&NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded);
1140  break;
1141 
1143  Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SetInformationHandler)(
1145  NdisRequest->DATA.SET_INFORMATION.Oid,
1146  NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
1147  NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
1148  (PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesRead,
1149  (PULONG)&NdisRequest->DATA.SET_INFORMATION.BytesNeeded);
1150  break;
1151 
1152  default:
1153  NDIS_DbgPrint(MIN_TRACE, ("Bad request type\n"));
1155  }
1156  }
1157  else
1158  {
1159  Status = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CoRequestHandler)(
1161  NULL, /* FIXME */
1162  NdisRequest);
1163  }
1164 
1165  if (Status != NDIS_STATUS_PENDING) {
1169  }
1170 
1172 
1173  if (Status != NDIS_STATUS_PENDING) {
1175  }
1176 
1177  return Status;
1178 }
1179 
1180 /*
1181  * @implemented
1182  */
1183 #undef NdisMSetInformationComplete
1184 VOID
1185 EXPORT
1189 {
1190  PLOGICAL_ADAPTER Adapter =
1192  KIRQL OldIrql;
1193  ASSERT(Adapter);
1198 }
1199 
1200 /*
1201  * @implemented
1202  */
1203 #undef NdisMQueryInformationComplete
1204 VOID
1205 EXPORT
1209 {
1210  PLOGICAL_ADAPTER Adapter =
1212  KIRQL OldIrql;
1213  ASSERT(Adapter);
1218 }
1219 
1220 VOID
1221 NTAPI
1223 {
1225  KIRQL OldIrql, RaiseOldIrql;
1226  NDIS_STATUS NdisStatus;
1227  PVOID WorkItemContext;
1228  NDIS_WORK_ITEM_TYPE WorkItemType;
1229  BOOLEAN AddressingReset;
1230 
1232 
1234 
1235  NdisStatus =
1237  (Adapter, &WorkItemType, &WorkItemContext);
1238 
1240 
1241  if (NdisStatus == NDIS_STATUS_SUCCESS)
1242  {
1243  switch (WorkItemType)
1244  {
1245  case NdisWorkItemSend:
1246  /*
1247  * called by ProSend when protocols want to send packets to the miniport
1248  */
1249 
1250  if(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)
1251  {
1253  {
1254  NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's SendPackets handler\n"));
1255  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
1256  Adapter->NdisMiniportBlock.MiniportAdapterContext, (PPNDIS_PACKET)&WorkItemContext, 1);
1257  NdisStatus = NDIS_STATUS_PENDING;
1258  }
1259  else
1260  {
1261  /* SendPackets is called at DISPATCH_LEVEL for all serialized miniports */
1262  KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
1263  {
1264  NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's SendPackets handler\n"));
1265  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
1266  Adapter->NdisMiniportBlock.MiniportAdapterContext, (PPNDIS_PACKET)&WorkItemContext, 1);
1267  }
1268  KeLowerIrql(RaiseOldIrql);
1269 
1270  NdisStatus = NDIS_GET_PACKET_STATUS((PNDIS_PACKET)WorkItemContext);
1271  if( NdisStatus == NDIS_STATUS_RESOURCES ) {
1272  MiniQueueWorkItem(Adapter, WorkItemType, WorkItemContext, TRUE);
1273  break;
1274  }
1275  }
1276  }
1277  else
1278  {
1280  {
1281  NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
1282  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
1283  Adapter->NdisMiniportBlock.MiniportAdapterContext, (PNDIS_PACKET)WorkItemContext,
1284  ((PNDIS_PACKET)WorkItemContext)->Private.Flags);
1285  NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send handler\n"));
1286  }
1287  else
1288  {
1289  /* Send is called at DISPATCH_LEVEL for all serialized miniports */
1290  KeRaiseIrql(DISPATCH_LEVEL, &RaiseOldIrql);
1291  NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
1292  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
1293  Adapter->NdisMiniportBlock.MiniportAdapterContext, (PNDIS_PACKET)WorkItemContext,
1294  ((PNDIS_PACKET)WorkItemContext)->Private.Flags);
1295  NDIS_DbgPrint(MAX_TRACE, ("back from miniport's send handler\n"));
1296  KeLowerIrql(RaiseOldIrql);
1297  if( NdisStatus == NDIS_STATUS_RESOURCES ) {
1298  MiniQueueWorkItem(Adapter, WorkItemType, WorkItemContext, TRUE);
1299  break;
1300  }
1301  }
1302  }
1303 
1304  if( NdisStatus != NDIS_STATUS_PENDING ) {
1306  ( Adapter, (PNDIS_PACKET)WorkItemContext, NdisStatus );
1307  }
1308  break;
1309 
1311  /*
1312  * called by ProSend when protocols want to send loopback packets
1313  */
1314  /* XXX atm ProIndicatePacket sends a packet up via the loopback adapter only */
1315  NdisStatus = ProIndicatePacket(Adapter, (PNDIS_PACKET)WorkItemContext);
1316 
1317  if( NdisStatus != NDIS_STATUS_PENDING )
1318  MiniSendComplete((NDIS_HANDLE)Adapter, (PNDIS_PACKET)WorkItemContext, NdisStatus);
1319  break;
1320 
1322  break;
1323 
1326  NdisMIndicateStatusComplete(Adapter);
1327 
1329  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.ResetHandler)(
1330  &AddressingReset,
1331  Adapter->NdisMiniportBlock.MiniportAdapterContext);
1332 
1333  KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
1334  Adapter->NdisMiniportBlock.ResetStatus = NdisStatus;
1335  KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
1336 
1338 
1339  if (NdisStatus != NDIS_STATUS_PENDING)
1340  MiniResetComplete(Adapter, NdisStatus, AddressingReset);
1341  break;
1342 
1344  break;
1345 
1347  break;
1348 
1349  case NdisWorkItemRequest:
1350  NdisStatus = MiniDoRequest(Adapter, (PNDIS_REQUEST)WorkItemContext);
1351 
1352  if (NdisStatus == NDIS_STATUS_PENDING)
1353  break;
1354 
1355  Adapter->NdisMiniportBlock.PendingRequest = (PNDIS_REQUEST)WorkItemContext;
1356  switch (((PNDIS_REQUEST)WorkItemContext)->RequestType)
1357  {
1359  NdisMQueryInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
1360  break;
1361 
1363  NdisMSetInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
1364  break;
1365 
1366  default:
1367  NDIS_DbgPrint(MIN_TRACE, ("Unknown NDIS request type.\n"));
1368  break;
1369  }
1370  Adapter->NdisMiniportBlock.PendingRequest = NULL;
1371  break;
1372 
1373  default:
1374  NDIS_DbgPrint(MIN_TRACE, ("Unknown NDIS work item type (%d).\n", WorkItemType));
1375  break;
1376  }
1377  }
1378 }
1379 
1380 
1381 VOID
1382 NTAPI
1384  IN NDIS_HANDLE MiniportHandle,
1388 {
1389  PLOGICAL_ADAPTER Adapter = MiniportHandle;
1390  PLIST_ENTRY CurrentEntry;
1391  PADAPTER_BINDING AdapterBinding;
1392  KIRQL OldIrql;
1393 
1395 
1396  CurrentEntry = Adapter->ProtocolListHead.Flink;
1397 
1398  while (CurrentEntry != &Adapter->ProtocolListHead)
1399  {
1400  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
1401 
1402  (*AdapterBinding->ProtocolBinding->Chars.StatusHandler)(
1403  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
1404  GeneralStatus,
1405  StatusBuffer,
1407 
1408  CurrentEntry = CurrentEntry->Flink;
1409  }
1410 
1412 }
1413 
1414 VOID
1415 NTAPI
1418 {
1420  PLIST_ENTRY CurrentEntry;
1421  PADAPTER_BINDING AdapterBinding;
1422  KIRQL OldIrql;
1423 
1425 
1426  CurrentEntry = Adapter->ProtocolListHead.Flink;
1427 
1428  while (CurrentEntry != &Adapter->ProtocolListHead)
1429  {
1430  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
1431 
1432  (*AdapterBinding->ProtocolBinding->Chars.StatusCompleteHandler)(
1433  AdapterBinding->NdisOpenBlock.ProtocolBindingContext);
1434 
1435  CurrentEntry = CurrentEntry->Flink;
1436  }
1437 
1439 }
1440 
1441 /*
1442  * @implemented
1443  */
1444 VOID
1445 EXPORT
1448 {
1449  PNDIS_LOG Log = (PNDIS_LOG)LogHandle;
1450  PNDIS_MINIPORT_BLOCK Miniport = Log->Miniport;
1451  KIRQL OldIrql;
1452 
1453  NDIS_DbgPrint(MAX_TRACE, ("called: LogHandle 0x%x\n", LogHandle));
1454 
1455  KeAcquireSpinLock(&(Miniport)->Lock, &OldIrql);
1456  Miniport->Log = NULL;
1457  KeReleaseSpinLock(&(Miniport)->Lock, OldIrql);
1458 
1459  ExFreePool(Log);
1460 }
1461 
1462 /*
1463  * @implemented
1464  */
1466 EXPORT
1469  IN UINT Size,
1471 {
1473  PNDIS_LOG Log;
1474  KIRQL OldIrql;
1475 
1476  NDIS_DbgPrint(MAX_TRACE, ("called: MiniportAdapterHandle 0x%x, Size %ld\n", MiniportAdapterHandle, Size));
1477 
1479 
1480  if (Adapter->NdisMiniportBlock.Log)
1481  {
1482  *LogHandle = NULL;
1483  return NDIS_STATUS_FAILURE;
1484  }
1485 
1486  Log = ExAllocatePool(NonPagedPool, Size + sizeof(NDIS_LOG));
1487  if (!Log)
1488  {
1489  *LogHandle = NULL;
1490  return NDIS_STATUS_RESOURCES;
1491  }
1492 
1493  Adapter->NdisMiniportBlock.Log = Log;
1494 
1496 
1497  Log->Miniport = &Adapter->NdisMiniportBlock;
1498  Log->TotalSize = Size;
1499  Log->CurrentSize = 0;
1500  Log->OutPtr = 0;
1501  Log->InPtr = 0;
1502  Log->Irp = NULL;
1503 
1504  *LogHandle = Log;
1505 
1507 
1508  return NDIS_STATUS_SUCCESS;
1509 }
1510 
1511 /*
1512  * @implemented
1513  */
1514 VOID
1515 EXPORT
1517  IN NDIS_HANDLE MiniportHandle)
1518 /*
1519  * FUNCTION: de-registers a shutdown handler
1520  * ARGUMENTS: MiniportHandle: Handle passed into MiniportInitialize
1521  */
1522 {
1523  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
1524 
1525  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1526 
1527  if(Adapter->BugcheckContext->ShutdownHandler) {
1530  }
1531 }
1532 
1533 /*
1534  * @implemented
1535  */
1536 VOID
1537 EXPORT
1540 {
1541  PNDIS_LOG Log = (PNDIS_LOG) LogHandle;
1542  KIRQL OldIrql;
1543 
1544  NDIS_DbgPrint(MAX_TRACE, ("called: LogHandle 0x%x\n", LogHandle));
1545 
1546  /* Lock object */
1548 
1549  /* Set buffers size */
1550  Log->CurrentSize = 0;
1551  Log->OutPtr = 0;
1552  Log->InPtr = 0;
1553 
1554  /* Unlock object */
1556 }
1557 
1558 /*
1559  * @implemented
1560  */
1561 #undef NdisMIndicateStatus
1562 VOID
1563 EXPORT
1569 {
1571 }
1572 
1573 /*
1574  * @implemented
1575  */
1576 #undef NdisMIndicateStatusComplete
1577 VOID
1578 EXPORT
1581 {
1583 }
1584 
1585 /*
1586  * @implemented
1587  */
1588 VOID
1589 EXPORT
1591  OUT PNDIS_HANDLE NdisWrapperHandle,
1592  IN PVOID SystemSpecific1,
1595 /*
1596  * FUNCTION: Notifies the NDIS library that a new miniport is initializing
1597  * ARGUMENTS:
1598  * NdisWrapperHandle = Address of buffer to place NDIS wrapper handle
1599  * SystemSpecific1 = Pointer to the driver's driver object
1600  * SystemSpecific2 = Pointer to the driver's registry path
1601  * SystemSpecific3 = Always NULL
1602  * NOTES:
1603  * - SystemSpecific2 goes invalid so we copy it
1604  */
1605 {
1606  PNDIS_M_DRIVER_BLOCK Miniport;
1608  WCHAR *RegistryBuffer;
1609 
1610  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1611 
1612  ASSERT(NdisWrapperHandle);
1613 
1614  *NdisWrapperHandle = NULL;
1615 
1616 #if BREAK_ON_MINIPORT_INIT
1617  DbgBreakPoint();
1618 #endif
1619 
1620  Miniport = ExAllocatePool(NonPagedPool, sizeof(NDIS_M_DRIVER_BLOCK));
1621 
1622  if (!Miniport)
1623  {
1624  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1625  return;
1626  }
1627 
1628  RtlZeroMemory(Miniport, sizeof(NDIS_M_DRIVER_BLOCK));
1629 
1630  KeInitializeSpinLock(&Miniport->Lock);
1631 
1632  Miniport->DriverObject = (PDRIVER_OBJECT)SystemSpecific1;
1633 
1634  /* set the miniport's driver registry path */
1636  if(!RegistryPath)
1637  {
1638  ExFreePool(Miniport);
1639  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1640  return;
1641  }
1642 
1644  RegistryPath->MaximumLength = RegistryPath->Length + sizeof(WCHAR); /* room for 0-term */
1645 
1646  RegistryBuffer = ExAllocatePool(PagedPool, RegistryPath->MaximumLength);
1647  if(!RegistryBuffer)
1648  {
1649  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1650  ExFreePool(Miniport);
1652  return;
1653  }
1654 
1656  RegistryBuffer[RegistryPath->Length/sizeof(WCHAR)] = 0;
1657 
1658  RegistryPath->Buffer = RegistryBuffer;
1659  Miniport->RegistryPath = RegistryPath;
1660 
1661  InitializeListHead(&Miniport->DeviceList);
1662 
1663  /* Put miniport in global miniport list */
1665 
1666  *NdisWrapperHandle = Miniport;
1667 }
1668 
1670  IN PVOID Buffer,
1671  IN ULONG Length)
1672 /*
1673  * FUNCTION: Internal callback for handling bugchecks - calls adapter's shutdown handler
1674  * ARGUMENTS:
1675  * Buffer: Pointer to a bugcheck callback context
1676  * Length: Unused
1677  */
1678 {
1681 
1682  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1683 
1684  if(sh)
1685  sh(Context->DriverContext);
1686 }
1687 
1688 /*
1689  * @implemented
1690  */
1691 VOID
1692 EXPORT
1694  IN NDIS_HANDLE MiniportHandle,
1695  IN PVOID ShutdownContext,
1697 /*
1698  * FUNCTION: Register a shutdown handler for an adapter
1699  * ARGUMENTS:
1700  * MiniportHandle: Handle originally passed into MiniportInitialize
1701  * ShutdownContext: Pre-initialized bugcheck context
1702  * ShutdownHandler: Function to call to handle the bugcheck
1703  * NOTES:
1704  * - I'm not sure about ShutdownContext
1705  */
1706 {
1707  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
1708  PMINIPORT_BUGCHECK_CONTEXT BugcheckContext;
1709 
1710  NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
1711 
1712  if (Adapter->BugcheckContext != NULL)
1713  {
1714  NDIS_DbgPrint(MIN_TRACE, ("Attempted to register again for a shutdown callback\n"));
1715  return;
1716  }
1717 
1718  BugcheckContext = ExAllocatePool(NonPagedPool, sizeof(MINIPORT_BUGCHECK_CONTEXT));
1719  if(!BugcheckContext)
1720  {
1721  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1722  return;
1723  }
1724 
1725  BugcheckContext->ShutdownHandler = ShutdownHandler;
1726  BugcheckContext->DriverContext = ShutdownContext;
1727 
1729  if (!BugcheckContext->CallbackRecord) {
1730  ExFreePool(BugcheckContext);
1731  return;
1732  }
1733 
1734  Adapter->BugcheckContext = BugcheckContext;
1735 
1736  KeInitializeCallbackRecord(BugcheckContext->CallbackRecord);
1737 
1739  BugcheckContext, sizeof(*BugcheckContext), (PUCHAR)"Ndis Miniport");
1740 
1742 }
1743 
1746  PLOGICAL_ADAPTER Adapter,
1747  NDIS_OID AddressOID)
1748 /*
1749  * FUNCTION: Queries miniport for information
1750  * ARGUMENTS:
1751  * Adapter = Pointer to logical adapter
1752  * AddressOID = OID to use to query for current address
1753  * RETURNS:
1754  * Status of operation
1755  */
1756 {
1758  NDIS_STATUS NdisStatus;
1759 
1760  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1761 
1762  /* Get MAC options for adapter */
1763  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAC_OPTIONS, sizeof(UINT),
1764  &Adapter->NdisMiniportBlock.MacOptions,
1765  &BytesWritten);
1766 
1767  if (NdisStatus != NDIS_STATUS_SUCCESS)
1768  {
1769  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAC_OPTIONS failed. NdisStatus (0x%X).\n", NdisStatus));
1770  return NdisStatus;
1771  }
1772 
1773  NDIS_DbgPrint(DEBUG_MINIPORT, ("MacOptions (0x%X).\n", Adapter->NdisMiniportBlock.MacOptions));
1774 
1775  /* Get current hardware address of adapter */
1776  NdisStatus = MiniQueryInformation(Adapter, AddressOID, Adapter->AddressLength,
1777  &Adapter->Address, &BytesWritten);
1778 
1779  if (NdisStatus != NDIS_STATUS_SUCCESS)
1780  {
1781  NDIS_DbgPrint(MIN_TRACE, ("Address OID (0x%X) failed. NdisStatus (0x%X).\n", AddressOID, NdisStatus));
1782  return NdisStatus;
1783  }
1784 
1785 #if DBG
1786  {
1787  /* 802.3 only */
1788 
1789  PUCHAR A = (PUCHAR)&Adapter->Address.Type.Medium802_3;
1790 
1791  NDIS_DbgPrint(MAX_TRACE, ("Adapter address is (%02X %02X %02X %02X %02X %02X).\n", A[0], A[1], A[2], A[3], A[4], A[5]));
1792  }
1793 #endif /* DBG */
1794 
1795  /* Get maximum lookahead buffer size of adapter */
1796  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAXIMUM_LOOKAHEAD, sizeof(ULONG),
1798 
1799  if (NdisStatus != NDIS_STATUS_SUCCESS)
1800  {
1801  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAXIMUM_LOOKAHEAD failed. NdisStatus (0x%X).\n", NdisStatus));
1802  return NdisStatus;
1803  }
1804 
1805  NDIS_DbgPrint(DEBUG_MINIPORT, ("MaxLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.MaximumLookahead));
1806 
1807  /* Get current lookahead buffer size of adapter */
1808  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_CURRENT_LOOKAHEAD, sizeof(ULONG),
1810 
1811  if (NdisStatus != NDIS_STATUS_SUCCESS)
1812  {
1813  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_CURRENT_LOOKAHEAD failed. NdisStatus (0x%X).\n", NdisStatus));
1814  return NdisStatus;
1815  }
1816 
1817  NdisStatus = MiniQueryInformation(Adapter, OID_GEN_MAXIMUM_SEND_PACKETS, sizeof(ULONG),
1819 
1820  if (NdisStatus != NDIS_STATUS_SUCCESS)
1821  {
1822  NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_MAXIMUM_SEND_PACKETS failed. NdisStatus (0x%X).\n", NdisStatus));
1823 
1824  /* Set it to 1 if it fails because some drivers don't support this (?)*/
1825  Adapter->NdisMiniportBlock.MaxSendPackets = 1;
1826  }
1827 
1828  NDIS_DbgPrint(DEBUG_MINIPORT, ("CurLookaheadLength (0x%X).\n", Adapter->NdisMiniportBlock.CurrentLookahead));
1829 
1830  return STATUS_SUCCESS;
1831 }
1832 
1833 NTSTATUS
1834 NTAPI
1836  PDEVICE_OBJECT Fdo,
1837  PIRP Irp,
1838  PVOID Context)
1839 {
1840  PKEVENT Event = Context;
1841 
1842  if (Irp->PendingReturned)
1844 
1846 }
1847 
1848 NTSTATUS
1849 NTAPI
1851 {
1852  KEVENT Event;
1853  NTSTATUS Status;
1854 
1858  TRUE, TRUE, TRUE);
1860  if (Status == STATUS_PENDING)
1861  {
1863  Status = Irp->IoStatus.Status;
1864  }
1865  return Status;
1866 }
1867 
1868 NTSTATUS
1869 NTAPI
1872  IN PIRP Irp)
1873 {
1874  Irp->IoStatus.Status = STATUS_SUCCESS;
1875  Irp->IoStatus.Information = 0;
1876 
1878 
1879  return STATUS_SUCCESS;
1880 }
1881 
1882 NTSTATUS
1883 NTAPI
1886  PIRP Irp)
1887 /*
1888  * FUNCTION: Handle the PnP start device event
1889  * ARGUMENTS:
1890  * DeviceObject = Functional Device Object
1891  * Irp = IRP_MN_START_DEVICE I/O request packet
1892  * RETURNS:
1893  * Status of operation
1894  */
1895 {
1898  NDIS_WRAPPER_CONTEXT WrapperContext;
1899  NDIS_STATUS NdisStatus;
1901  NTSTATUS Status;
1903  NDIS_OID AddressOID;
1904  BOOLEAN Success = FALSE;
1906  ULONG ResourceListSize;
1907  UNICODE_STRING ParamName;
1908  PNDIS_CONFIGURATION_PARAMETER ConfigParam;
1909  NDIS_HANDLE ConfigHandle;
1910  ULONG Size;
1912  UINT MaxMulticastAddresses;
1914  PLIST_ENTRY CurrentEntry;
1915  PPROTOCOL_BINDING ProtocolBinding;
1916 
1917  /*
1918  * Prepare wrapper context used by HW and configuration routines.
1919  */
1920 
1921  NDIS_DbgPrint(DEBUG_MINIPORT, ("Start Device %wZ\n", &Adapter->NdisMiniportBlock.MiniportName));
1922 
1923  NDIS_DbgPrint(MAX_TRACE, ("Inserting adapter 0x%x into adapter list\n", Adapter));
1924 
1925  /* Put adapter in global adapter list */
1927 
1930  KEY_ALL_ACCESS, &WrapperContext.RegistryHandle);
1931  if (!NT_SUCCESS(Status))
1932  {
1933  NDIS_DbgPrint(MIN_TRACE,("failed to open adapter-specific reg key\n"));
1935  return Status;
1936  }
1937 
1938  NDIS_DbgPrint(MAX_TRACE, ("opened device reg key\n"));
1939 
1940  WrapperContext.DeviceObject = Adapter->NdisMiniportBlock.DeviceObject;
1941 
1942  /*
1943  * Store the adapter resources used by HW routines such as
1944  * NdisMQueryAdapterResources.
1945  */
1946 
1947  if (Stack->Parameters.StartDevice.AllocatedResources != NULL)
1948  {
1949  ResourceCount = Stack->Parameters.StartDevice.AllocatedResources->List[0].
1950  PartialResourceList.Count;
1951  ResourceListSize =
1952  FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
1953  PartialDescriptors[ResourceCount]);
1954 
1955  Adapter->NdisMiniportBlock.AllocatedResources =
1956  ExAllocatePool(PagedPool, ResourceListSize);
1957  if (Adapter->NdisMiniportBlock.AllocatedResources == NULL)
1958  {
1959  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1962  }
1963 
1964  Adapter->NdisMiniportBlock.Resources =
1965  ExAllocatePool(PagedPool, ResourceListSize);
1966  if (!Adapter->NdisMiniportBlock.Resources)
1967  {
1968  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1969  ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
1972  }
1973 
1975  Stack->Parameters.StartDevice.AllocatedResources,
1976  ResourceListSize);
1977 
1978  RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResources,
1979  Stack->Parameters.StartDevice.AllocatedResources,
1980  ResourceListSize);
1981  }
1982 
1983  if (Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
1984  {
1985  ResourceCount = Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].
1986  PartialResourceList.Count;
1987  ResourceListSize =
1988  FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
1989  PartialDescriptors[ResourceCount]);
1990 
1991  Adapter->NdisMiniportBlock.AllocatedResourcesTranslated =
1992  ExAllocatePool(PagedPool, ResourceListSize);
1993  if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated == NULL)
1994  {
1995  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
1998  }
1999 
2000  RtlCopyMemory(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated,
2001  Stack->Parameters.StartDevice.AllocatedResourcesTranslated,
2002  ResourceListSize);
2003  }
2004 
2005  /*
2006  * Store the Bus Type, Bus Number and Slot information. It's used by
2007  * the hardware routines then.
2008  */
2009 
2010  NdisOpenConfiguration(&NdisStatus, &ConfigHandle, (NDIS_HANDLE)&WrapperContext);
2011  if (NdisStatus != NDIS_STATUS_SUCCESS)
2012  {
2013  NDIS_DbgPrint(MIN_TRACE, ("Failed to open configuration key\n"));
2015  return NdisStatus;
2016  }
2017 
2018  Size = sizeof(ULONG);
2021  &Adapter->NdisMiniportBlock.BusType, &Size);
2023  {
2024  NdisInitUnicodeString(&ParamName, L"BusType");
2025  NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2026  &ParamName, NdisParameterInteger);
2027  if (NdisStatus == NDIS_STATUS_SUCCESS)
2028  Adapter->NdisMiniportBlock.BusType = ConfigParam->ParameterData.IntegerData;
2029  else
2030  Adapter->NdisMiniportBlock.BusType = Isa;
2031  }
2032 
2035  &Adapter->NdisMiniportBlock.BusNumber, &Size);
2036  if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.BusNumber == 0xFFFFFFF0)
2037  {
2038  NdisInitUnicodeString(&ParamName, L"BusNumber");
2039  NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2040  &ParamName, NdisParameterInteger);
2041  if (NdisStatus == NDIS_STATUS_SUCCESS)
2042  Adapter->NdisMiniportBlock.BusNumber = ConfigParam->ParameterData.IntegerData;
2043  else
2044  Adapter->NdisMiniportBlock.BusNumber = 0;
2045  }
2046  WrapperContext.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
2047 
2050  &Adapter->NdisMiniportBlock.SlotNumber, &Size);
2051  if (!NT_SUCCESS(Status) || Adapter->NdisMiniportBlock.SlotNumber == (NDIS_INTERFACE_TYPE)-1)
2052  {
2053  NdisInitUnicodeString(&ParamName, L"SlotNumber");
2054  NdisReadConfiguration(&NdisStatus, &ConfigParam, ConfigHandle,
2055  &ParamName, NdisParameterInteger);
2056  if (NdisStatus == NDIS_STATUS_SUCCESS)
2057  Adapter->NdisMiniportBlock.SlotNumber = ConfigParam->ParameterData.IntegerData;
2058  else
2059  Adapter->NdisMiniportBlock.SlotNumber = 0;
2060  }
2061  else
2062  {
2063  /* Convert slotnumber to PCI_SLOT_NUMBER */
2064  ULONG PciSlotNumber = Adapter->NdisMiniportBlock.SlotNumber;
2066 
2067  SlotNumber.u.AsULONG = 0;
2068  SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
2069  SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
2070 
2071  Adapter->NdisMiniportBlock.SlotNumber = SlotNumber.u.AsULONG;
2072  }
2073  WrapperContext.SlotNumber = Adapter->NdisMiniportBlock.SlotNumber;
2074 
2075  NdisCloseConfiguration(ConfigHandle);
2076 
2077  /* Set handlers (some NDIS macros require these) */
2090 
2091  /*
2092  * Call MiniportInitialize.
2093  */
2094 
2095  NDIS_DbgPrint(MID_TRACE, ("calling MiniportInitialize\n"));
2096  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.InitializeHandler)(
2098  MEDIA_ARRAY_SIZE, Adapter, (NDIS_HANDLE)&WrapperContext);
2099 
2100  ZwClose(WrapperContext.RegistryHandle);
2101 
2102  if (NdisStatus != NDIS_STATUS_SUCCESS)
2103  {
2104  NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() failed for an adapter (%lx).\n", NdisStatus));
2106  if (Adapter->NdisMiniportBlock.Interrupt)
2107  {
2108  KeBugCheckEx(BUGCODE_ID_DRIVER,
2109  (ULONG_PTR)Adapter,
2111  (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
2112  1);
2113  }
2114  if (Adapter->NdisMiniportBlock.TimerQueue)
2115  {
2116  KeBugCheckEx(BUGCODE_ID_DRIVER,
2117  (ULONG_PTR)Adapter,
2119  (ULONG_PTR)Adapter->NdisMiniportBlock.TimerQueue,
2120  1);
2121  }
2122  return NdisStatus;
2123  }
2124 
2126  {
2127  NDIS_DbgPrint(MIN_TRACE, ("MiniportInitialize() selected a bad index\n"));
2130  }
2131 
2133 
2134  switch (Adapter->NdisMiniportBlock.MediaType)
2135  {
2136  case NdisMedium802_3:
2137  Adapter->MediumHeaderSize = 14; /* XXX figure out what to do about LLC */
2138  AddressOID = OID_802_3_CURRENT_ADDRESS;
2140  NdisStatus = DoQueries(Adapter, AddressOID);
2141  if (NdisStatus == NDIS_STATUS_SUCCESS)
2142  {
2143  NdisStatus = MiniQueryInformation(Adapter, OID_802_3_MAXIMUM_LIST_SIZE, sizeof(UINT),
2144  &MaxMulticastAddresses, &BytesWritten);
2145 
2146  if (NdisStatus != NDIS_STATUS_SUCCESS)
2147  {
2149  NDIS_DbgPrint(MIN_TRACE, ("MiniQueryInformation failed (%x)\n", NdisStatus));
2150  return NdisStatus;
2151  }
2152 
2153  Success = EthCreateFilter(MaxMulticastAddresses,
2154  Adapter->Address.Type.Medium802_3,
2155  &Adapter->NdisMiniportBlock.EthDB);
2156  if (Success)
2157  ((PETHI_FILTER)Adapter->NdisMiniportBlock.EthDB)->Miniport = (PNDIS_MINIPORT_BLOCK)Adapter;
2158  else
2159  NdisStatus = NDIS_STATUS_RESOURCES;
2160  }
2161  break;
2162 
2163  default:
2164  /* FIXME: Support other types of media */
2165  NDIS_DbgPrint(MIN_TRACE, ("error: unsupported media\n"));
2166  ASSERT(FALSE);
2168  return STATUS_UNSUCCESSFUL;
2169  }
2170 
2171  if (NdisStatus != NDIS_STATUS_SUCCESS)
2172  {
2173  NDIS_DbgPrint(MIN_TRACE, ("couldn't create filter (%x)\n", NdisStatus));
2174  return NdisStatus;
2175  }
2176 
2177  /* Check for a hang every two seconds if it wasn't set in MiniportInitialize */
2178  if (Adapter->NdisMiniportBlock.CheckForHangSeconds == 0)
2180 
2181  Adapter->NdisMiniportBlock.OldPnPDeviceState = Adapter->NdisMiniportBlock.PnPDeviceState;
2182  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStarted;
2183 
2185 
2186  Timeout.QuadPart = Int32x32To64(Adapter->NdisMiniportBlock.CheckForHangSeconds, -1000000);
2188  Adapter->NdisMiniportBlock.CheckForHangSeconds * 1000,
2190 
2191  /* Put adapter in adapter list for this miniport */
2193 
2194  /* Refresh bindings for all protocols */
2195  CurrentEntry = ProtocolListHead.Flink;
2196  while (CurrentEntry != &ProtocolListHead)
2197  {
2198  ProtocolBinding = CONTAINING_RECORD(CurrentEntry, PROTOCOL_BINDING, ListEntry);
2199 
2200  ndisBindMiniportsToProtocol(&NdisStatus, ProtocolBinding);
2201 
2202  CurrentEntry = CurrentEntry->Flink;
2203  }
2204 
2205  return STATUS_SUCCESS;
2206 }
2207 
2208 NTSTATUS
2209 NTAPI
2212  PIRP Irp)
2213 /*
2214  * FUNCTION: Handle the PnP stop device event
2215  * ARGUMENTS:
2216  * DeviceObject = Functional Device Object
2217  * Irp = IRP_MN_STOP_DEVICE I/O request packet
2218  * RETURNS:
2219  * Status of operation
2220  */
2221 {
2223 
2224  /* Remove adapter from adapter list for this miniport */
2226 
2227  /* Remove adapter from global adapter list */
2229 
2231 
2232  /* Set this here so MiniportISR will be forced to run for interrupts generated in MiniportHalt */
2233  Adapter->NdisMiniportBlock.OldPnPDeviceState = Adapter->NdisMiniportBlock.PnPDeviceState;
2234  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStopped;
2235 
2236  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.HaltHandler)(Adapter);
2237 
2239 
2240  if (Adapter->NdisMiniportBlock.AllocatedResources)
2241  {
2242  ExFreePool(Adapter->NdisMiniportBlock.AllocatedResources);
2243  Adapter->NdisMiniportBlock.AllocatedResources = NULL;
2244  }
2245  if (Adapter->NdisMiniportBlock.AllocatedResourcesTranslated)
2246  {
2247  ExFreePool(Adapter->NdisMiniportBlock.AllocatedResourcesTranslated);
2248  Adapter->NdisMiniportBlock.AllocatedResourcesTranslated = NULL;
2249  }
2250 
2251  if (Adapter->NdisMiniportBlock.Resources)
2252  {
2254  Adapter->NdisMiniportBlock.Resources = NULL;
2255  }
2256 
2257  if (Adapter->NdisMiniportBlock.EthDB)
2258  {
2259  EthDeleteFilter(Adapter->NdisMiniportBlock.EthDB);
2260  Adapter->NdisMiniportBlock.EthDB = NULL;
2261  }
2262 
2263  return STATUS_SUCCESS;
2264 }
2265 
2266 NTSTATUS
2267 NTAPI
2270  PIRP Irp)
2271 {
2275 
2277 
2278  ShutdownHandler(Context->DriverContext);
2279 
2280  Irp->IoStatus.Status = STATUS_SUCCESS;
2281  Irp->IoStatus.Information = 0;
2282 
2284 
2285  return STATUS_SUCCESS;
2286 }
2287 
2288 NTSTATUS
2289 NTAPI
2292  PIRP Irp)
2293 {
2298  ULONG Written;
2299 
2300  Irp->IoStatus.Information = 0;
2301 
2302  ASSERT(Adapter);
2303 
2304  ControlCode = Stack->Parameters.DeviceIoControl.IoControlCode;
2305  switch (ControlCode)
2306  {
2308  Status = MiniQueryInformation(Adapter,
2309  *(PNDIS_OID)Irp->AssociatedIrp.SystemBuffer,
2310  Stack->Parameters.DeviceIoControl.OutputBufferLength,
2311  MmGetSystemAddressForMdl(Irp->MdlAddress),
2312  &Written);
2313  Irp->IoStatus.Information = Written;
2314  break;
2315 
2316  default:
2317  NDIS_DbgPrint(MIN_TRACE, ("NdisIDeviceIoControl: unsupported control code 0x%lx\n", ControlCode));
2318  break;
2319  }
2320 
2321  if (Status != NDIS_STATUS_PENDING)
2322  {
2323  Irp->IoStatus.Status = Status;
2325  }
2326  else
2328 
2329  return Status;
2330 }
2331 
2332 NTSTATUS
2333 NTAPI
2336  PIRP Irp)
2337 {
2340  NTSTATUS Status;
2341 
2342  switch (Stack->MinorFunction)
2343  {
2344  case IRP_MN_START_DEVICE:
2345  Status = NdisIForwardIrpAndWait(Adapter, Irp);
2346  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
2347  {
2349  }
2350  else
2351  NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed device start\n"));
2352  Irp->IoStatus.Status = Status;
2354  return Status;
2355 
2356  case IRP_MN_STOP_DEVICE:
2358  if (!NT_SUCCESS(Status))
2359  NDIS_DbgPrint(MIN_TRACE, ("WARNING: Ignoring halt device failure! Passing the IRP down anyway\n"));
2360  Irp->IoStatus.Status = STATUS_SUCCESS;
2361  break;
2362 
2366  Irp->IoStatus.Status = Status;
2367  if (Status != STATUS_SUCCESS)
2368  {
2370  NDIS_DbgPrint(MIN_TRACE, ("Failing miniport halt request\n"));
2371  return Status;
2372  }
2373  break;
2374 
2377  Status = NdisIForwardIrpAndWait(Adapter, Irp);
2378  if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
2379  {
2381  }
2382  else
2383  {
2384  NDIS_DbgPrint(MIN_TRACE, ("Lower driver failed cancel stop/remove request\n"));
2385  }
2386  Irp->IoStatus.Status = Status;
2388  return Status;
2389 
2392  Irp->IoStatus.Status = Status;
2393  Irp->IoStatus.Information |= Adapter->NdisMiniportBlock.PnPFlags;
2394  break;
2395 
2396  default:
2397  break;
2398  }
2399 
2402 }
2403 
2404 NTSTATUS
2405 NTAPI
2408  _In_ PIRP Irp)
2409 {
2411 
2415 }
2416 
2417 NTSTATUS
2418 NTAPI
2422 /*
2423  * FUNCTION: Create a device for an adapter found using PnP
2424  * ARGUMENTS:
2425  * DriverObject = Pointer to the miniport driver object
2426  * PhysicalDeviceObject = Pointer to the PDO for our adapter
2427  */
2428 {
2429  static const WCHAR ClassKeyName[] = {'C','l','a','s','s','\\'};
2430  static const WCHAR LinkageKeyName[] = {'\\','L','i','n','k','a','g','e',0};
2431  PNDIS_M_DRIVER_BLOCK Miniport;
2432  PNDIS_M_DRIVER_BLOCK *MiniportPtr;
2433  WCHAR *LinkageKeyBuffer;
2434  ULONG DriverKeyLength;
2436  UNICODE_STRING ExportName;
2438  PLOGICAL_ADAPTER Adapter;
2439  NTSTATUS Status;
2440 
2441  /*
2442  * Gain the access to the miniport data structure first.
2443  */
2444 
2445  MiniportPtr = IoGetDriverObjectExtension(DriverObject, (PVOID)'NMID');
2446  if (MiniportPtr == NULL)
2447  {
2448  NDIS_DbgPrint(MIN_TRACE, ("Can't get driver object extension.\n"));
2449  return NDIS_STATUS_FAILURE;
2450  }
2451  Miniport = *MiniportPtr;
2452 
2453  /*
2454  * Get name of the Linkage registry key for our adapter. It's located under
2455  * the driver key for our driver and so we have basicly two ways to do it.
2456  * Either we can use IoOpenDriverRegistryKey or compose it using information
2457  * gathered by IoGetDeviceProperty. I chose the second because
2458  * IoOpenDriverRegistryKey wasn't implemented at the time of writing.
2459  */
2460 
2462  0, NULL, &DriverKeyLength);
2464  {
2465  NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key length.\n"));
2466  return Status;
2467  }
2468 
2469  LinkageKeyBuffer = ExAllocatePool(PagedPool, DriverKeyLength +
2470  sizeof(ClassKeyName) + sizeof(LinkageKeyName));
2471  if (LinkageKeyBuffer == NULL)
2472  {
2473  NDIS_DbgPrint(MIN_TRACE, ("Can't allocate memory for driver key name.\n"));
2475  }
2476 
2478  DriverKeyLength, LinkageKeyBuffer +
2479  (sizeof(ClassKeyName) / sizeof(WCHAR)),
2480  &DriverKeyLength);
2481  if (!NT_SUCCESS(Status))
2482  {
2483  NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport driver key.\n"));
2484  ExFreePool(LinkageKeyBuffer);
2485  return Status;
2486  }
2487 
2488  /* Compose the linkage key name. */
2489  RtlCopyMemory(LinkageKeyBuffer, ClassKeyName, sizeof(ClassKeyName));
2490  RtlCopyMemory(LinkageKeyBuffer + ((sizeof(ClassKeyName) + DriverKeyLength) /
2491  sizeof(WCHAR)) - 1, LinkageKeyName, sizeof(LinkageKeyName));
2492 
2493  NDIS_DbgPrint(DEBUG_MINIPORT, ("LinkageKey: %S.\n", LinkageKeyBuffer));
2494 
2495  /*
2496  * Now open the linkage key and read the "Export" and "RootDevice" values
2497  * which contains device name and root service respectively.
2498  */
2499 
2501  RtlInitUnicodeString(&ExportName, NULL);
2503  QueryTable[0].Name = L"Export";
2504  QueryTable[0].EntryContext = &ExportName;
2505 
2507  QueryTable, NULL, NULL);
2508  ExFreePool(LinkageKeyBuffer);
2509  if (!NT_SUCCESS(Status))
2510  {
2511  NDIS_DbgPrint(MIN_TRACE, ("Can't get miniport device name. (%x)\n", Status));
2512  return Status;
2513  }
2514 
2515  /*
2516  * Create the device object.
2517  */
2518 
2519  NDIS_DbgPrint(MAX_TRACE, ("creating device %wZ\n", &ExportName));
2520 
2521  Status = IoCreateDevice(Miniport->DriverObject, sizeof(LOGICAL_ADAPTER),
2522  &ExportName, FILE_DEVICE_PHYSICAL_NETCARD,
2523  0, FALSE, &DeviceObject);
2524  if (!NT_SUCCESS(Status))
2525  {
2526  NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n"));
2527  RtlFreeUnicodeString(&ExportName);
2528  return Status;
2529  }
2530 
2531  /*
2532  * Initialize the adapter structure.
2533  */
2534 
2538 
2540  &GUID_DEVINTERFACE_NET,
2541  NULL,
2543 
2544  if (!NT_SUCCESS(Status))
2545  {
2546  NDIS_DbgPrint(MIN_TRACE, ("Could not create device interface.\n"));
2548  RtlFreeUnicodeString(&ExportName);
2549  return Status;
2550  }
2551 
2552  Adapter->NdisMiniportBlock.DriverHandle = Miniport;
2553  Adapter->NdisMiniportBlock.MiniportName = ExportName;
2559 
2560  Adapter->NdisMiniportBlock.OldPnPDeviceState = 0;
2561  Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceAdded;
2562 
2565 
2567 
2568  return STATUS_SUCCESS;
2569 }
2570 
2571 NTSTATUS
2572 NTAPI
2575  IN PIRP Irp)
2576 {
2578 
2579  /* Use the characteristics to classify the device */
2580  if (DeviceObject->DeviceType == FILE_DEVICE_PHYSICAL_NETCARD)
2581  {
2582  if ((IrpSp->MajorFunction == IRP_MJ_CREATE) ||
2585  {
2587  }
2588  else if (IrpSp->MajorFunction == IRP_MJ_PNP)
2589  {
2591  }
2592  else if (IrpSp->MajorFunction == IRP_MJ_SHUTDOWN)
2593  {
2594  return NdisIShutdown(DeviceObject, Irp);
2595  }
2597  {
2599  }
2600  else if (IrpSp->MajorFunction == IRP_MJ_POWER)
2601  {
2602  return NdisIPower(DeviceObject, Irp);
2603  }
2604  NDIS_DbgPrint(MIN_TRACE, ("Unexpected IRP MajorFunction 0x%x\n", IrpSp->MajorFunction));
2605  ASSERT(FALSE);
2606  }
2607  else if (DeviceObject->DeviceType == FILE_DEVICE_NETWORK)
2608  {
2610 
2611  ASSERT(DeviceBlock->DeviceObject == DeviceObject);
2612 
2613  if (DeviceBlock->MajorFunction[IrpSp->MajorFunction] != NULL)
2614  {
2615  return DeviceBlock->MajorFunction[IrpSp->MajorFunction](DeviceObject, Irp);
2616  }
2617  }
2618  else
2619  {
2620  ASSERT(FALSE);
2621  }
2622 
2623  Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
2624  Irp->IoStatus.Information = 0;
2625 
2627 
2629 }
2630 
2631 /*
2632  * @implemented
2633  */
2635 EXPORT
2637  IN NDIS_HANDLE NdisWrapperHandle,
2638  IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics,
2640 /*
2641  * FUNCTION: Registers a miniport's MiniportXxx entry points with the NDIS library
2642  * ARGUMENTS:
2643  * NdisWrapperHandle = Pointer to handle returned by NdisMInitializeWrapper
2644  * MiniportCharacteristics = Pointer to a buffer with miniport characteristics
2645  * CharacteristicsLength = Number of bytes in characteristics buffer
2646  * RETURNS:
2647  * Status of operation
2648  */
2649 {
2650  UINT MinSize;
2651  PNDIS_M_DRIVER_BLOCK Miniport = GET_MINIPORT_DRIVER(NdisWrapperHandle);
2652  PNDIS_M_DRIVER_BLOCK *MiniportPtr;
2653  NTSTATUS Status;
2654  ULONG i;
2655 
2656  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
2657 
2658  switch (MiniportCharacteristics->MajorNdisVersion)
2659  {
2660  case 0x03:
2661  MinSize = sizeof(NDIS30_MINIPORT_CHARACTERISTICS);
2662  break;
2663 
2664  case 0x04:
2665  MinSize = sizeof(NDIS40_MINIPORT_CHARACTERISTICS);
2666  break;
2667 
2668  case 0x05:
2669  switch (MiniportCharacteristics->MinorNdisVersion)
2670  {
2671  case 0x00:
2672  MinSize = sizeof(NDIS50_MINIPORT_CHARACTERISTICS);
2673  break;
2674 
2675  case 0x01:
2676  MinSize = sizeof(NDIS51_MINIPORT_CHARACTERISTICS);
2677  break;
2678 
2679  default:
2680  NDIS_DbgPrint(MIN_TRACE, ("Bad 5.x minor characteristics version.\n"));
2681  return NDIS_STATUS_BAD_VERSION;
2682  }
2683  break;
2684 
2685  default:
2686  NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics version.\n"));
2687  return NDIS_STATUS_BAD_VERSION;
2688  }
2689 
2690  NDIS_DbgPrint(MID_TRACE, ("Initializing an NDIS %u.%u miniport\n",
2691  MiniportCharacteristics->MajorNdisVersion,
2692  MiniportCharacteristics->MinorNdisVersion));
2693 
2694  if (CharacteristicsLength < MinSize)
2695  {
2696  NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics length.\n"));
2698  }
2699 
2700  /* Check if mandatory MiniportXxx functions are specified */
2701  if ((!MiniportCharacteristics->HaltHandler) ||
2702  (!MiniportCharacteristics->InitializeHandler)||
2703  (!MiniportCharacteristics->ResetHandler))
2704  {
2705  NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics.\n"));
2707  }
2708 
2709  if (MiniportCharacteristics->MajorNdisVersion < 0x05)
2710  {
2711  if ((!MiniportCharacteristics->QueryInformationHandler) ||
2712  (!MiniportCharacteristics->SetInformationHandler))
2713  {
2714  NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (Set/Query)\n"));
2716  }
2717  }
2718  else
2719  {
2720  if (((!MiniportCharacteristics->QueryInformationHandler) ||
2721  (!MiniportCharacteristics->SetInformationHandler)) &&
2722  (!MiniportCharacteristics->CoRequestHandler))
2723  {
2724  NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (Set/Query)\n"));
2726  }
2727  }
2728 
2729  if (MiniportCharacteristics->MajorNdisVersion == 0x03)
2730  {
2731  if (!MiniportCharacteristics->SendHandler)
2732  {
2733  NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (NDIS 3.0)\n"));
2735  }
2736  }
2737  else if (MiniportCharacteristics->MajorNdisVersion == 0x04)
2738  {
2739  /* NDIS 4.0 */
2740  if ((!MiniportCharacteristics->SendHandler) &&
2741  (!MiniportCharacteristics->SendPacketsHandler))
2742  {
2743  NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (NDIS 4.0)\n"));
2745  }
2746  }
2747  else if (MiniportCharacteristics->MajorNdisVersion == 0x05)
2748  {
2749  /* TODO: Add more checks here */
2750 
2751  if ((!MiniportCharacteristics->SendHandler) &&
2752  (!MiniportCharacteristics->SendPacketsHandler) &&
2753  (!MiniportCharacteristics->CoSendPacketsHandler))
2754  {
2755  NDIS_DbgPrint(MIN_TRACE, ("Bad miniport characteristics. (NDIS 5.0)\n"));
2757  }
2758  }
2759 
2760  RtlCopyMemory(&Miniport->MiniportCharacteristics, MiniportCharacteristics, MinSize);
2761 
2762  /*
2763  * NOTE: This is VERY unoptimal! Should we store the NDIS_M_DRIVER_BLOCK
2764  * structure in the driver extension or what?
2765  */
2766 
2768  sizeof(PNDIS_M_DRIVER_BLOCK), (PVOID*)&MiniportPtr);
2769  if (!NT_SUCCESS(Status))
2770  {
2771  NDIS_DbgPrint(MIN_TRACE, ("Can't allocate driver object extension.\n"));
2772  return NDIS_STATUS_RESOURCES;
2773  }
2774 
2775  *MiniportPtr = Miniport;
2776 
2777  /* We have to register for all of these so handler registered in NdisMRegisterDevice work */
2778  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
2779  {
2781  }
2782 
2784 
2785  return NDIS_STATUS_SUCCESS;
2786 }
2787 
2788 /*
2789  * @implemented
2790  */
2791 #undef NdisMResetComplete
2792 VOID
2793 EXPORT
2797  IN BOOLEAN AddressingReset)
2798 {
2799  MiniResetComplete(MiniportAdapterHandle, Status, AddressingReset);
2800 }
2801 
2802 /*
2803  * @implemented
2804  */
2805 #undef NdisMSendComplete
2806 VOID
2807 EXPORT
2812 /*
2813  * FUNCTION: Forwards a message to the initiating protocol saying
2814  * that a packet was handled
2815  * ARGUMENTS:
2816  * NdisAdapterHandle = Handle input to MiniportInitialize
2817  * Packet = Pointer to NDIS packet that was sent
2818  * Status = Status of send operation
2819  */
2820 {
2822 }
2823 
2824 /*
2825  * @implemented
2826  */
2827 #undef NdisMSendResourcesAvailable
2828 VOID
2829 EXPORT
2832 {
2834 }
2835 
2836 /*
2837  * @implemented
2838  */
2839 #undef NdisMTransferDataComplete
2840 VOID
2841 EXPORT
2846  IN UINT BytesTransferred)
2847 {
2849 }
2850 
2851 /*
2852  * @implemented
2853  */
2854 #undef NdisMSetAttributes
2855 VOID
2856 EXPORT
2859  IN NDIS_HANDLE MiniportAdapterContext,
2860  IN BOOLEAN BusMaster,
2862 /*
2863  * FUNCTION: Informs the NDIS library of significant features of the caller's NIC
2864  * ARGUMENTS:
2865  * MiniportAdapterHandle = Handle input to MiniportInitialize
2866  * MiniportAdapterContext = Pointer to context information
2867  * BusMaster = Specifies TRUE if the caller's NIC is a busmaster DMA device
2868  * AdapterType = Specifies the I/O bus interface of the caller's NIC
2869  */
2870 {
2871  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
2872  NdisMSetAttributesEx(MiniportAdapterHandle, MiniportAdapterContext, 0,
2873  BusMaster ? NDIS_ATTRIBUTE_BUS_MASTER : 0,
2874  AdapterType);
2875 }
2876 
2877 /*
2878  * @implemented
2879  */
2880 VOID
2881 EXPORT
2884  IN NDIS_HANDLE MiniportAdapterContext,
2885  IN UINT CheckForHangTimeInSeconds OPTIONAL,
2886  IN ULONG AttributeFlags,
2888 /*
2889  * FUNCTION: Informs the NDIS library of significant features of the caller's NIC
2890  * ARGUMENTS:
2891  * MiniportAdapterHandle = Handle input to MiniportInitialize
2892  * MiniportAdapterContext = Pointer to context information
2893  * CheckForHangTimeInSeconds = Specifies interval in seconds at which
2894  * MiniportCheckForHang should be called
2895  * AttributeFlags = Bitmask that indicates specific attributes
2896  * AdapterType = Specifies the I/O bus interface of the caller's NIC
2897  */
2898 {
2900 
2901  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
2902 
2903  Adapter->NdisMiniportBlock.MiniportAdapterContext = MiniportAdapterContext;
2904  Adapter->NdisMiniportBlock.Flags = AttributeFlags;
2906  if (CheckForHangTimeInSeconds > 0)
2907  Adapter->NdisMiniportBlock.CheckForHangSeconds = CheckForHangTimeInSeconds;
2908  if (AttributeFlags & NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER)
2909  NDIS_DbgPrint(MIN_TRACE, ("Intermediate drivers not supported yet.\n"));
2910 
2911  NDIS_DbgPrint(MID_TRACE, ("Miniport attribute flags: 0x%x\n", AttributeFlags));
2912 
2913  if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.AdapterShutdownHandler)
2914  {
2915  NDIS_DbgPrint(MAX_TRACE, ("Miniport set AdapterShutdownHandler in MiniportCharacteristics\n"));
2918  Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.AdapterShutdownHandler);
2919  }
2920 }
2921 
2922 /*
2923  * @implemented
2924  */
2925 VOID
2926 EXPORT
2928  IN ULONG MicrosecondsToSleep)
2929 /*
2930  * FUNCTION: delay the thread's execution for MicrosecondsToSleep
2931  * ARGUMENTS:
2932  * MicrosecondsToSleep: duh...
2933  * NOTES:
2934  * - Because this is a blocking call, current IRQL must be < DISPATCH_LEVEL
2935  */
2936 {
2937  KTIMER Timer;
2939 
2940  PAGED_CODE();
2941 
2942  DueTime.QuadPart = (-1) * 10 * MicrosecondsToSleep;
2943 
2945  KeSetTimer(&Timer, DueTime, 0);
2947 }
2948 
2949 /*
2950  * @implemented
2951  */
2952 BOOLEAN
2953 EXPORT
2955  IN PNDIS_MINIPORT_INTERRUPT Interrupt,
2956  IN PVOID SynchronizeFunction,
2958 {
2959  return(KeSynchronizeExecution(Interrupt->InterruptObject,
2960  (PKSYNCHRONIZE_ROUTINE)SynchronizeFunction,
2962 }
2963 
2964 /*
2965  * @unimplemented
2966  */
2968 EXPORT
2971  IN PVOID LogBuffer,
2973 {
2974  PUCHAR Buffer = LogBuffer;
2975  UINT i, j, idx;
2976 
2977  UNIMPLEMENTED;
2978  for (i = 0; i < LogBufferSize; i += 16)
2979  {
2980  DbgPrint("%08x |", i);
2981  for (j = 0; j < 16; j++)
2982  {
2983  idx = i + j;
2984  if (idx < LogBufferSize)
2985  DbgPrint(" %02x", Buffer[idx]);
2986  else
2987  DbgPrint(" ");
2988  }
2989  DbgPrint(" | ");
2990  for (j = 0; j < 16; j++)
2991  {
2992  idx = i + j;
2993  if (idx == LogBufferSize)
2994  break;
2995  if (Buffer[idx] >= ' ') /* FIXME: not portable! replace by if (isprint(Buffer[idx])) ? */
2996  DbgPrint("%c", Buffer[idx]);
2997  else
2998  DbgPrint(".");
2999  }
3000  DbgPrint("\n");
3001  }
3002 
3003  return NDIS_STATUS_FAILURE;
3004 }
3005 
3006 /*
3007  * @implemented
3008  */
3009 VOID
3010 EXPORT
3012  IN NDIS_HANDLE NdisWrapperHandle,
3014 /*
3015  * FUNCTION: Releases resources allocated by a call to NdisInitializeWrapper
3016  * ARGUMENTS:
3017  * NdisWrapperHandle = Handle returned by NdisInitializeWrapper (NDIS_M_DRIVER_BLOCK)
3018  * SystemSpecific = Always NULL
3019  */
3020 {
3021  PNDIS_M_DRIVER_BLOCK Miniport = GET_MINIPORT_DRIVER(NdisWrapperHandle);
3022 
3023  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3024 
3025  ExFreePool(Miniport->RegistryPath->Buffer);
3026  ExFreePool(Miniport->RegistryPath);
3028  ExFreePool(Miniport);
3029 }
3030 
3031 
3032 /*
3033  * @implemented
3034  */
3036 EXPORT
3038  OUT PNDIS_STRING AdapterInstanceName,
3040 /*
3041  * FUNCTION:
3042  * ARGUMENTS:
3043  * NOTES:
3044  * NDIS 5.0
3045  */
3046 {
3049 
3050  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3051 
3052  AdapterName.Length = 0;
3053  AdapterName.MaximumLength = Adapter->NdisMiniportBlock.MiniportName.MaximumLength;
3054  AdapterName.Buffer = ExAllocatePool(PagedPool, AdapterName.MaximumLength);
3055  if (!AdapterName.Buffer) {
3056  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
3057  return NDIS_STATUS_RESOURCES;
3058  }
3059 
3061 
3062  *AdapterInstanceName = AdapterName;
3063 
3064  return NDIS_STATUS_SUCCESS;
3065 }
3066 
3067 /*
3068  * @implemented
3069  */
3070 VOID
3071 EXPORT
3073  IN NDIS_HANDLE NdisAdapterHandle)
3074 /*
3075  * FUNCTION:
3076  * ARGUMENTS:
3077  * NOTES:
3078  * NDIS 4.0
3079  */
3080 {
3081  NdisMDeregisterAdapterShutdownHandler(NdisAdapterHandle);
3082 }
3083 
3084 
3085 /*
3086  * @implemented
3087  */
3088 VOID
3089 EXPORT
3091  IN NDIS_HANDLE NdisAdapterHandle,
3092  IN PVOID ShutdownContext,
3094 /*
3095  * FUNCTION:
3096  * ARGUMENTS:
3097  * NOTES:
3098  * NDIS 4.0
3099  */
3100 {
3101  NdisMRegisterAdapterShutdownHandler(NdisAdapterHandle,
3102  ShutdownContext,
3103  ShutdownHandler);
3104 }
3105 
3106 /*
3107  * @implemented
3108  */
3109 VOID
3110 EXPORT
3118 /*
3119  * FUNCTION:
3120  * ARGUMENTS:
3121  * NOTES:
3122  * NDIS 5.0
3123  */
3124 {
3126 
3127  NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
3128 
3129  if (PhysicalDeviceObject != NULL)
3131 
3134 
3135  if (NextDeviceObject != NULL)
3137 
3138  if (AllocatedResources != NULL)
3139  *AllocatedResources = Adapter->NdisMiniportBlock.AllocatedResources;
3140 
3142  *AllocatedResourcesTranslated = Adapter->NdisMiniportBlock.AllocatedResourcesTranslated;
3143 }
3144 
3145 /*
3146  * @implemented
3147  */
3148 VOID
3149 EXPORT
3151  IN NDIS_HANDLE NdisWrapperHandle,
3153 /*
3154  * FUNCTION:
3155  * ARGUMENTS:
3156  * NOTES:
3157  * NDIS 5.0
3158  */
3159 {
3160  PNDIS_M_DRIVER_BLOCK DriverBlock = NdisWrapperHandle;
3161 
3162  NDIS_DbgPrint(MAX_TRACE, ("Miniport registered unload handler\n"));
3163 
3164  DriverBlock->DriverObject->DriverUnload = UnloadHandler;
3165 }
3166 
3167 /*
3168  * @implemented
3169  */
3171 EXPORT
3173  IN NDIS_HANDLE NdisWrapperHandle,
3176  IN PDRIVER_DISPATCH MajorFunctions[],
3179 /*
3180  * FUNCTION:
3181  * ARGUMENTS:
3182  * NOTES:
3183  * NDIS 5.0
3184  */
3185 {
3186  PNDIS_M_DRIVER_BLOCK DriverBlock = NdisWrapperHandle;
3187  PNDIS_M_DEVICE_BLOCK DeviceBlock;
3190  UINT i;
3191 
3192  NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
3193 
3194  Status = IoCreateDevice(DriverBlock->DriverObject,
3195  sizeof(NDIS_M_DEVICE_BLOCK),
3196  DeviceName,
3198  0,
3199  FALSE,
3200  &DeviceObject);
3201 
3202  if (!NT_SUCCESS(Status))
3203  {
3204  NDIS_DbgPrint(MIN_TRACE, ("IoCreateDevice failed (%x)\n", Status));
3205  return Status;
3206  }
3207 
3209 
3210  if (!NT_SUCCESS(Status))
3211  {
3212  NDIS_DbgPrint(MIN_TRACE, ("IoCreateSymbolicLink failed (%x)\n", Status));
3214  return Status;
3215  }
3216 
3217  DeviceBlock = DeviceObject->DeviceExtension;
3218 
3219  if (!DeviceBlock)
3220  {
3221  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
3224  return NDIS_STATUS_RESOURCES;
3225  }
3226 
3227  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
3228  DeviceBlock->MajorFunction[i] = MajorFunctions[i];
3229 
3230  DeviceBlock->DeviceObject = DeviceObject;
3231  DeviceBlock->SymbolicName = SymbolicName;
3232 
3234  *NdisDeviceHandle = DeviceBlock;
3235 
3236  return NDIS_STATUS_SUCCESS;
3237 }
3238 
3239 /*
3240  * @implemented
3241  */
3243 EXPORT
3246 /*
3247  * FUNCTION:
3248  * ARGUMENTS:
3249  * NOTES:
3250  * NDIS 5.0
3251  */
3252 {
3253  PNDIS_M_DEVICE_BLOCK DeviceBlock = NdisDeviceHandle;
3254 
3255  IoDeleteDevice(DeviceBlock->DeviceObject);
3256 
3257  IoDeleteSymbolicLink(DeviceBlock->SymbolicName);
3258 
3259  return NDIS_STATUS_SUCCESS;
3260 }
3261 
3262 /*
3263  * @implemented
3264  */
3266 EXPORT
3268  OUT PNDIS_STRING AdapterInstanceName,
3270 /*
3271  * FUNCTION:
3272  * ARGUMENTS:
3273  * NOTES:
3274  * NDIS 5.0
3275  */
3276 {
3277  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3278  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3279 
3280  return NdisMQueryAdapterInstanceName(AdapterInstanceName,
3281  Adapter);
3282 }
3283 
3284 /*
3285  * @implemented
3286  */
3287 VOID
3288 EXPORT
3293 /*
3294  * FUNCTION:
3295  * ARGUMENTS:
3296  * NOTES:
3297  * NDIS 5.0
3298  */
3299 {
3300  PIRP Irp = (PIRP)NetPnPEvent->NdisReserved[0];
3301  PLIST_ENTRY CurrentEntry = (PLIST_ENTRY)NetPnPEvent->NdisReserved[1];
3302  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3303  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3304  NDIS_STATUS NdisStatus;
3305 
3306  if (Status != NDIS_STATUS_SUCCESS)
3307  {
3308  if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3310  Irp->IoStatus.Status = Status;
3312  return;
3313  }
3314 
3315  while (CurrentEntry != &Adapter->ProtocolListHead)
3316  {
3317  AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
3318 
3319  NdisStatus = (*AdapterBinding->ProtocolBinding->Chars.PnPEventHandler)(
3320  AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
3321  NetPnPEvent);
3322 
3323  if (NdisStatus == NDIS_STATUS_PENDING)
3324  {
3325  NetPnPEvent->NdisReserved[1] = (ULONG_PTR)CurrentEntry->Flink;
3326  return;
3327  }
3328  else if (NdisStatus != NDIS_STATUS_SUCCESS)
3329  {
3330  if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3332  Irp->IoStatus.Status = NdisStatus;
3334  return;
3335  }
3336 
3337  CurrentEntry = CurrentEntry->Flink;
3338  }
3339 
3340  if (NetPnPEvent->Buffer) ExFreePool(NetPnPEvent->Buffer);
3342 
3343  Irp->IoStatus.Status = NDIS_STATUS_SUCCESS;
3345 }
3346 
3347 /*
3348  * @implemented
3349  */
3350 VOID
3351 EXPORT
3354  IN PVOID CancelId)
3355 {
3356  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3357  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3358 
3359  NDIS_DbgPrint(MAX_TRACE, ("Called for ID %x.\n", CancelId));
3360 
3361  if (Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CancelSendPacketsHandler)
3362  {
3363  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.CancelSendPacketsHandler)(
3365  CancelId);
3366  }
3367 }
3368 
3369 
3370 /*
3371  * @implemented
3372  */
3374 EXPORT
3377 /*
3378  * FUNCTION:
3379  * ARGUMENTS:
3380  * NOTES:
3381  * NDIS 5.0
3382  */
3383 {
3384  PADAPTER_BINDING AdapterBinding = NdisBindingHandle;
3385  PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
3386 
3387  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3388 
3389  return Adapter->NdisMiniportBlock.DeviceContext;
3390 }
3391 
3392 
3393 /*
3394  * @implemented
3395  */
3397 EXPORT
3400 /*
3401  * FUNCTION:
3402  * ARGUMENTS:
3403  * NOTES:
3404  * NDIS 5.0
3405  */
3406 {
3408 
3409  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
3410 
3411  return Adapter->NdisMiniportBlock.DeviceContext;
3412 }
3413 
3414 /* EOF */
_In_ PPNDIS_PACKET _In_ UINT NumberOfPackets
Definition: ndis.h:5102
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
LIST_ENTRY DeviceList
Definition: miniport.h:25
PKBUGCHECK_CALLBACK_RECORD CallbackRecord
Definition: miniport.h:60
LIST_ENTRY MiniportListEntry
Definition: miniport.h:93
#define IRP_MN_CANCEL_REMOVE_DEVICE
NDIS_M_REQ_COMPLETE_HANDLER QueryCompleteHandler
Definition: ndis.h:2567
VOID EXPORT NdisMSendComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status)
Definition: miniport.c:2808
UINT MaximumLookahead
Definition: ndis.h:2552
NDIS_M_TD_COMPLETE_HANDLER TDCompleteHandler
Definition: ndis.h:2566
VOID EXPORT NdisMSetInformationComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
Definition: miniport.c:1186
#define ExInterlockedRemoveEntryList(_List, _Lock)
Definition: ndissys.h:37
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:3988
#define IN
Definition: typedefs.h:38
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4661
ADAPTER_SHUTDOWN_HANDLER ShutdownHandler
Definition: miniport.h:59
NTSTATUS NTAPI NdisIAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: miniport.c:2419
PDEVICE_OBJECT PhysicalDeviceObject
Definition: ndis.h:2535
struct _NDIS51_MINIPORT_CHARACTERISTICS NDIS51_MINIPORT_CHARACTERISTICS
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
_In_opt_ NDIS_HANDLE _In_opt_ NDIS_HANDLE _Inout_ PNDIS_REQUEST NdisRequest
Definition: ndis.h:1553
PLOGICAL_ADAPTER MiniLocateDevice(PNDIS_STRING AdapterName)
Definition: miniport.c:689
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
VOID MiniWorkItemComplete(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType)
Definition: miniport.c:963
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
#define MID_TRACE
Definition: debug.h:15
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
NDIS_OPEN_BLOCK NdisOpenBlock
Definition: protocol.h:22
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
PNDIS_MINIPORT_TIMER TimerQueue
Definition: ndis.h:2546
enum _INTERFACE_TYPE INTERFACE_TYPE
PMINIPORT_BUGCHECK_CONTEXT BugcheckContext
Definition: miniport.h:98
NTSTATUS NTAPI NdisIPnPQueryStopDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: protocol.c:154
NDIS_STATUS DoQueries(PLOGICAL_ADAPTER Adapter, NDIS_OID AddressOID)
Definition: miniport.c:1745
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS OpenErrorStatus
Definition: ndis.h:5990
#define FILE_DEVICE_NETWORK
Definition: winioctl.h:123
Type
Definition: Type.h:6
VOID EXPORT NdisMResetComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset)
Definition: miniport.c:2794
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1530
VOID NTAPI EthFilterDprIndicateReceiveComplete(IN PETH_FILTER Filter)
Definition: efilter.c:113
#define IOCTL_NDIS_QUERY_GLOBAL_STATS
Definition: ntddndis.h:348
NDIS_INTERFACE_TYPE AdapterType
Definition: ndis.h:2533
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1755
enum _NDIS_MEDIUM NDIS_MEDIUM
#define DbgPrint
Definition: loader.c:25
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define NDIS_ATTRIBUTE_DESERIALIZE
Definition: ndis.h:588
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
NTSTATUS NTAPI PoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: power.c:485
NDIS_STATUS ResetStatus
Definition: ndis.h:2523
VOID EXPORT NdisMCloseLog(IN NDIS_HANDLE LogHandle)
Definition: miniport.c:1446
VOID EXPORT NdisMDeregisterAdapterShutdownHandler(IN NDIS_HANDLE MiniportHandle)
Definition: miniport.c:1516
#define IRP_MJ_SHUTDOWN
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4622
UINT CurrentSize
Definition: ndis.h:2461
_In_ PIRP Irp
Definition: csq.h:116
struct _MINIPORT_BUGCHECK_CONTEXT * PMINIPORT_BUGCHECK_CONTEXT
LIST_ENTRY ProtocolListHead
Definition: protocol.c:19
PNDIS_MINIPORT_WORK_ITEM WorkQueueHead
Definition: miniport.h:90
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
VOID EXPORT NdisOpenConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: config.c:197
MDL * PNDIS_BUFFER
Definition: ndis.h:343
NTSTATUS NTAPI NdisIForwardIrpAndWaitCompletionRoutine(PDEVICE_OBJECT Fdo, PIRP Irp, PVOID Context)
Definition: miniport.c:1835
_In_opt_ PVOID SystemSpecific
Definition: ndis.h:5822
NTSTATUS NTAPI NdisIPnPStopDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2210
unsigned char * PUCHAR
Definition: retypes.h:3
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
VOID EXPORT NdisMTransferDataComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred)
Definition: miniport.c:2842
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_In_ PNDIS_STRING _In_ PNDIS_STRING SymbolicName
Definition: ndis.h:4658
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:225
VOID MiniDoAddressingReset(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:887
#define IRP_MJ_MAXIMUM_FUNCTION
LONG NTSTATUS
Definition: precomp.h:26
#define KeInitializeCallbackRecord(CallbackRecord)
Definition: kefuncs.h:1479
ULONG NDIS_OID
Definition: ntddndis.h:204
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4650
#define NDIS_STATUS_RESET_START
Definition: ndis.h:354
PNDIS_MINIPORT_WORK_ITEM MiniGetFirstWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
Definition: miniport.c:125
_In_ PVOID _In_ PVOID _In_ PVOID SystemSpecific3
Definition: ndis.h:637
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
struct _NDIS_REQUEST * PNDIS_REQUEST
_In_opt_ PVOID _In_ PIO_WORKITEM IoWorkItem
Definition: iotypes.h:487
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS GeneralStatus
Definition: ndis.h:1537
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT SelectedMediumIndex
Definition: ndis.h:5990
#define RTL_REGISTRY_CONTROL
Definition: nt_native.h:163
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define NDIS_STATUS_UNSUPPORTED_MEDIA
Definition: ndis.h:490
#define DEBUG_MINIPORT
Definition: debug.h:17
PIRP Irp
Definition: ndis.h:2459
NDIS_M_REQ_COMPLETE_HANDLER SetCompleteHandler
Definition: ndis.h:2568
void DbgBreakPoint()
Definition: mach.c:558
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NDIS_HANDLE EXPORT NdisIMGetDeviceContext(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:3398
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FASTCALL
Definition: nt_native.h:50
LONG CancelId
Definition: main.c:23
KSPIN_LOCK LogLock
Definition: ndis.h:2458
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
NDIS_STATUS EXPORT NdisMCreateLog(IN NDIS_HANDLE MiniportAdapterHandle, IN UINT Size, OUT PNDIS_HANDLE LogHandle)
Definition: miniport.c:1467
_In_ NDIS_HANDLE _In_ PNET_PNP_EVENT NetPnPEvent
Definition: ndis.h:6063
#define PAGED_CODE()
Definition: video.h:57
VOID EXPORT NdisInitializeWrapper(OUT PNDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific1, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
Definition: miniport.c:1590
STATUS_HANDLER StatusHandler
Definition: ndis.h:1875
VOID NTAPI EthFilterDprIndicateReceive(IN PETH_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, IN PCHAR Address, IN PVOID HeaderBuffer, IN UINT HeaderBufferSize, IN PVOID LookaheadBuffer, IN UINT LookaheadBufferSize, IN UINT PacketSize)
Definition: efilter.c:69
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
VOID EXPORT NdisMRegisterUnloadHandler(IN NDIS_HANDLE NdisWrapperHandle, IN PDRIVER_UNLOAD UnloadHandler)
Definition: miniport.c:3150
DRIVER_UNLOAD * PDRIVER_UNLOAD
Definition: iotypes.h:2144
int NDIS_STATUS
Definition: ntddndis.h:380
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
enum _NDIS_WORK_ITEM_TYPE NDIS_WORK_ITEM_TYPE
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define GET_LOGICAL_ADAPTER(Handle)
Definition: miniport.h:101
HARDWARE_ADDRESS Address
Definition: miniport.h:96
NTSTATUS NTAPI NdisICreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: miniport.c:1870
NTSTATUS NTAPI NdisGenericIrpHandler(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: miniport.c:2573
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5155
FILTERDBS_S FILTER_PACKET_INDICATION_HANDLER PacketIndicateHandler
Definition: ndis.h:2526
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
UCHAR KIRQL
Definition: env_spec_w32.h:591
NDIS_STATUS FASTCALL MiniDequeueWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE *WorkItemType, PVOID *WorkItemContext)
Definition: miniport.c:1049
NDIS_WORK_ITEM_TYPE WorkItemType
Definition: ndis.h:2292
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:279
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID EXPORT NdisMFlushLog(IN NDIS_HANDLE LogHandle)
Definition: miniport.c:1538
#define MEDIA_ARRAY_SIZE
Definition: miniport.c:31
ETH_RCV_COMPLETE_HANDLER EthRxCompleteHandler
Definition: ndis.h:2561
VOID NTAPI MiniResetComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset)
Definition: miniport.c:434
VOID EXPORT NdisReadConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue, IN NDIS_HANDLE ConfigurationHandle, IN PNDIS_STRING Keyword, IN NDIS_PARAMETER_TYPE ParameterType)
Definition: config.c:414
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ PPNDIS_PACKET PacketArray
Definition: ndis.h:5102
#define IRP_MN_QUERY_REMOVE_DEVICE
NDIS_STATUS MiniSetInformation(PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesRead)
Definition: miniport.c:755
_In_ PDRIVER_UNLOAD UnloadHandler
Definition: ndis.h:4670
VOID NTAPI MiniTransferDataComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred)
Definition: miniport.c:591
_In_ ULONG BufferLength
Definition: usbdlib.h:225
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2492
PNDIS_MINIPORT_BLOCK Miniport
Definition: ndis.h:2457
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2173
UINT TotalSize
Definition: ndis.h:2460
LIST_ENTRY MiniportListHead
Definition: miniport.c:53
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResourcesTranslated
Definition: ndis.h:4622
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:211
VOID NTAPI MiniStatus(IN NDIS_HANDLE MiniportHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1383
unsigned int idx
Definition: utils.c:41
PNDIS_MINIPORT_INTERRUPT Interrupt
Definition: ndis.h:2504
W_SEND_PACKETS_HANDLER SendPacketsHandler
Definition: ndis.h:2556
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
struct _NDIS_LOG * PNDIS_LOG
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
NDIS_M_SEND_RESOURCES_HANDLER SendResourcesHandler
Definition: ndis.h:2528
BOOLEAN MiniIsBusy(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE Type)
Definition: miniport.c:143
smooth NULL
Definition: ftsmooth.c:416
KSYNCHRONIZE_ROUTINE * PKSYNCHRONIZE_ROUTINE
Definition: ketypes.h:863
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define IoCompleteRequest
Definition: irp.c:1240
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
NTSTATUS NTAPI NdisIShutdown(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2268
VOID EXPORT NdisMGetDeviceProperty(IN NDIS_HANDLE MiniportAdapterHandle, IN OUT PDEVICE_OBJECT *PhysicalDeviceObject OPTIONAL, IN OUT PDEVICE_OBJECT *FunctionalDeviceObject OPTIONAL, IN OUT PDEVICE_OBJECT *NextDeviceObject OPTIONAL, IN OUT PCM_RESOURCE_LIST *AllocatedResources OPTIONAL, IN OUT PCM_RESOURCE_LIST *AllocatedResourcesTranslated OPTIONAL)
Definition: miniport.c:3111
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4202
VOID EXPORT NdisCancelSendPackets(IN NDIS_HANDLE NdisBindingHandle, IN PVOID CancelId)
Definition: miniport.c:3352
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
Definition: bufpool.h:45
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
#define GET_MINIPORT_DRIVER(Handle)
Definition: miniport.h:84
switch(r->id)
Definition: btrfs.c:2691
RESET_COMPLETE_HANDLER ResetCompleteHandler
Definition: ndis.h:1868
#define FILE_DEVICE_PHYSICAL_NETCARD
Definition: winioctl.h:128
void * PVOID
Definition: retypes.h:9
ULONG AddressLength
Definition: miniport.h:97
NTSTATUS NTAPI NdisIPnPCancelStopDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: protocol.c:172
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
VOID EXPORT NdisGetFirstBufferFromPacket(IN PNDIS_PACKET _Packet, OUT PNDIS_BUFFER *_FirstBuffer, OUT PVOID *_FirstBufferVA, OUT PUINT _FirstBufferLength, OUT PUINT _TotalBufferLength)
Definition: buffer.c:871
#define UlongToPtr(u)
Definition: config.h:106
#define PtrToUlong(u)
Definition: config.h:107
VOID EXPORT NdisMIndicateStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1579
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
VOID EXPORT NdisCloseConfiguration(IN NDIS_HANDLE ConfigurationHandle)
Definition: config.c:136
VOID EXPORT NdisMSetAttributes(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE MiniportAdapterContext, IN BOOLEAN BusMaster, IN NDIS_INTERFACE_TYPE AdapterType)
Definition: miniport.c:2857
#define IRP_MN_QUERY_STOP_DEVICE
ULONG DebugTraceLevel
Definition: ndis.c:13
VOID EXPORT NdisRegisterAdapterShutdownHandler(IN NDIS_HANDLE NdisAdapterHandle, IN PVOID ShutdownContext, IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler)
Definition: miniport.c:3090
PPROTOCOL_BINDING ProtocolBinding
Definition: protocol.h:28
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
BOOLEAN MiniAdapterHasAddress(PLOGICAL_ADAPTER Adapter, PNDIS_PACKET Packet)
Definition: miniport.c:615
NTSTATUS NTAPI NdisIPower(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: miniport.c:2406
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
ULONG * PNDIS_OID
Definition: ntddndis.h:204
VOID NTAPI MiniRequestComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
Definition: miniport.c:480
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:524
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
VOID EXPORT NdisTerminateWrapper(IN NDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific)
Definition: miniport.c:3011
#define NDIS_GET_PACKET_STATUS(_Packet)
Definition: ndis.h:3418
VOID(NTAPI * ADAPTER_SHUTDOWN_HANDLER)(_In_ PVOID ShutdownContext)
Definition: ndis.h:2007
NDIS_MEDIUM MediaType
Definition: ndis.h:2530
VOID NTAPI MiniIndicateReceivePacket(IN NDIS_HANDLE MiniportAdapterHandle, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets)
Definition: miniport.c:292
#define IRP_MN_STOP_DEVICE
#define NDIS_ATTRIBUTE_BUS_MASTER
Definition: ndis.h:586
LIST_ENTRY List
Definition: psmgr.c:57
TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler
Definition: ndis.h:1865
if(!(yy_init))
Definition: macro.lex.yy.c:714
NDIS_STATUS MiniDoRequest(PLOGICAL_ADAPTER Adapter, PNDIS_REQUEST NdisRequest)
Definition: miniport.c:1106
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID NTAPI MiniportHangDpc(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
Definition: miniport.c:948
PDEVICE_OBJECT NextDeviceObject
Definition: ndis.h:2536
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
KDPC Dpc
Definition: ndis.h:644
VOID NTAPI MiniSendResourcesAvailable(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:582
ULONG CheckForHangSeconds
Definition: ndis.h:2520
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define IRP_MN_START_DEVICE
USHORT MaxSendPackets
Definition: ndis.h:2542
NDIS_M_STS_COMPLETE_HANDLER StatusCompleteHandler
Definition: ndis.h:2565
struct _NDIS30_MINIPORT_CHARACTERISTICS NDIS30_MINIPORT_CHARACTERISTICS
VOID NTAPI IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1724
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
RECEIVE_PACKET_HANDLER ReceivePacketHandler
Definition: ndis.h:1878
PNDIS_PACKET FirstPendingPacket
Definition: ndis.h:2508
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
LIST_ENTRY ListEntry
Definition: miniport.h:92
VOID NTAPI NdisIBugcheckCallback(IN PVOID Buffer, IN ULONG Length)
Definition: miniport.c:1669
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID EXPORT NdisReturnPackets(IN PNDIS_PACKET *PacketsToReturn, IN UINT NumberOfPackets)
Definition: miniport.c:257
KSPIN_LOCK MiniportListLock
Definition: miniport.c:54
struct _NDIS_REQUEST_MAC_BLOCK * PNDIS_REQUEST_MAC_BLOCK
STATUS_COMPLETE_HANDLER StatusCompleteHandler
Definition: ndis.h:1876
KSPIN_LOCK Lock
Definition: miniport.h:21
VOID MiniDisplayPacket2(PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookaheadBuffer, UINT LookaheadBufferSize)
Definition: miniport.c:89
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PLOGICAL_ADAPTER Adapter
Definition: protocol.h:29
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
ULONG_PTR Reserved[2]
Definition: ndis.h:749
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
VOID MiniDisplayPacket(PNDIS_PACKET Packet, PCSTR Reason)
Definition: miniport.c:61
static ULONG ResourceCount
Definition: inbv.c:47
LIST_ENTRY ProtocolListHead
Definition: miniport.h:94
PNDIS_OPEN_BLOCK Binding
Definition: protocol.h:34
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:636
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * NextDeviceObject
Definition: ndis.h:4622
PCM_RESOURCE_LIST Resources
Definition: ndis.h:2516
#define IRP_MJ_POWER
Definition: ttei1.cpp:12
UCHAR WrapperReserved[2 *sizeof(PVOID)]
Definition: ndis.h:739
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
VOID NTAPI MiniSendComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status)
Definition: miniport.c:529
VOID EXPORT NdisInitUnicodeString(IN OUT PNDIS_STRING DestinationString, IN PCWSTR SourceString)
Definition: string.c:130
VOID NTAPI MiniStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1416
#define NDIS_GET_PACKET_HEADER_SIZE(_Packet)
Definition: ndis.h:3409
static const WCHAR L[]
Definition: oid.c:1250
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: ketypes.h:687
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2179
#define NDIS_SET_PACKET_STATUS(_Packet, _Status)
Definition: ndis.h:3491
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
RECEIVE_HANDLER ReceiveHandler
Definition: ndis.h:1871
VOID NTAPI ProSendPackets(IN NDIS_HANDLE NdisBindingHandle, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets)
Definition: protocol.c:575
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1833
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
NTSTATUS NTAPI NdisIDispatchPnp(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2334
_In_ PVOID _In_ PVOID SystemSpecific2
Definition: ndis.h:637
UNICODE_STRING MiniportName
Definition: ndis.h:2493
Definition: typedefs.h:117
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
struct _NDIS_MINIPORT_BLOCK * PNDIS_MINIPORT_BLOCK
Definition: ndis.h:319
BOOLEAN NTAPI KeDeregisterBugCheckCallback(IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
Definition: bug.c:1246
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
BOOLEAN NTAPI EthCreateFilter(IN UINT MaximumMulticastAddresses, IN PUCHAR AdapterAddress, OUT PETH_FILTER *Filter)
Definition: efilter.c:16
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: miniport.h:37
NDIS_HANDLE DeviceContext
Definition: ndis.h:2497
UINT InPtr
Definition: ndis.h:2462
struct _NDIS40_MINIPORT_CHARACTERISTICS NDIS40_MINIPORT_CHARACTERISTICS
VOID EXPORT NdisDeregisterAdapterShutdownHandler(IN NDIS_HANDLE NdisAdapterHandle)
Definition: miniport.c:3072
NDIS_STATUS MiniQueryInformation(PLOGICAL_ADAPTER Adapter, NDIS_OID Oid, ULONG Size, PVOID Buffer, PULONG BytesWritten)
Definition: miniport.c:804
KSPIN_LOCK AdapterListLock
Definition: miniport.c:58
Status
Definition: gdiplustypes.h:24
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
struct _NDIS_MINIPORT_WORK_ITEM * PNDIS_MINIPORT_WORK_ITEM
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
short sh
Definition: format.c:272
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
#define _In_
Definition: no_sal2.h:204
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_In_ PKSYNCHRONIZE_ROUTINE _In_opt_ __drv_aliasesMem PVOID SynchronizeContext
Definition: kefuncs.h:549
VOID NTAPI EthDeleteFilter(IN PETH_FILTER Filter)
Definition: efilter.c:57
PNDIS_REQUEST PendingRequest
Definition: ndis.h:2548
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
SEND_COMPLETE_HANDLER SendCompleteHandler
Definition: ndis.h:1861
PDRIVER_ADD_DEVICE AddDevice
Definition: iotypes.h:2111
UINT CopyBufferChainToBuffer(PUCHAR DstData, PNDIS_BUFFER SrcBuffer, UINT SrcOffset, UINT Length)
Definition: buffer.c:111
struct _SINGLE_LIST_ENTRY * PSINGLE_LIST_ENTRY
DRIVER_DISPATCH * PDRIVER_DISPATCH
Definition: iotypes.h:2153
VOID NTAPI ndisBindMiniportsToProtocol(OUT PNDIS_STATUS Status, IN PPROTOCOL_BINDING Protocol)
Definition: protocol.c:906
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:227
BOOLEAN EXPORT NdisMSynchronizeWithInterrupt(IN PNDIS_MINIPORT_INTERRUPT Interrupt, IN PVOID SynchronizeFunction, IN PVOID SynchronizeContext)
Definition: miniport.c:2954
UINT Timer
Definition: capclock.c:11
static ULONG Timeout
Definition: ping.c:61
KTIMER Timer
Definition: ndis.h:643
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
UINT CurrentLookahead
Definition: ndis.h:2551
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID _In_ UINT StatusBufferSize
Definition: ndis.h:1537
_Out_ PNDIS_HANDLE _In_ PNDIS_PROTOCOL_CHARACTERISTICS _In_ UINT CharacteristicsLength
Definition: ndis.h:6116
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define MAX_TRACE
Definition: debug.h:16
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
VOID EXPORT NdisMSleep(IN ULONG MicrosecondsToSleep)
Definition: miniport.c:2927
_In_ USHORT PacketSize
Definition: iofuncs.h:1056
struct _NDIS50_MINIPORT_CHARACTERISTICS NDIS50_MINIPORT_CHARACTERISTICS
VOID MiniIndicateData(PLOGICAL_ADAPTER Adapter, NDIS_HANDLE MacReceiveContext, PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookaheadBuffer, UINT LookaheadBufferSize, UINT PacketSize)
Definition: miniport.c:176
UINT CopyPacketToBuffer(PUCHAR DstData, PNDIS_PACKET SrcPacket, UINT SrcOffset, UINT Length)
Definition: buffer.c:170
VOID EXPORT NdisMSendResourcesAvailable(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:2830
PNDIS_MINIPORT_WORK_ITEM WorkQueueTail
Definition: miniport.h:91
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
#define NDIS_STATUS_RESET_END
Definition: ndis.h:355
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT * FunctionalDeviceObject
Definition: ndis.h:4622
PDEVICE_OBJECT DeviceObject
Definition: ndis.h:2534
PUNICODE_STRING RegistryPath
Definition: miniport.h:26
LIST_ENTRY ListEntry
Definition: miniport.h:20
KSPIN_LOCK Lock
Definition: ndis.h:2502
unsigned int * PULONG
Definition: retypes.h:1
#define ETH_LENGTH_OF_ADDRESS
Definition: efilter.h:16
unsigned int UINT
Definition: ndis.h:50
NTSTATUS NTAPI NdisIDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:2290
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
NDIS_M_SEND_COMPLETE_HANDLER SendCompleteHandler
Definition: ndis.h:2527
VOID EXPORT NdisCompletePnPEvent(IN NDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, IN PNET_PNP_EVENT NetPnPEvent)
Definition: miniport.c:3289
struct _ADAPTER_BINDING * PADAPTER_BINDING
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
SINGLE_LIST_ENTRY Link
Definition: ndis.h:2291
#define NDIS_STATUS_BAD_VERSION
Definition: ndis.h:468
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID StatusBuffer
Definition: ndis.h:1537
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:4557
NDIS_STATUS EXPORT NdisMDeregisterDevice(IN NDIS_HANDLE NdisDeviceHandle)
Definition: miniport.c:3244
#define NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER
Definition: ndis.h:587
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NTSTATUS NTAPI NdisIForwardIrpAndWait(PLOGICAL_ADAPTER Adapter, PIRP Irp)
Definition: miniport.c:1850
static __inline VOID NdisQueryPacket(IN PNDIS_PACKET Packet, OUT PUINT PhysicalBufferCount OPTIONAL, OUT PUINT BufferCount OPTIONAL, OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, OUT PUINT TotalPacketLength OPTIONAL)
Definition: ndis.h:3575
NDIS_M_RESET_COMPLETE_HANDLER ResetCompleteHandler
Definition: ndis.h:2529
enum _NDIS_INTERFACE_TYPE NDIS_INTERFACE_TYPE
_In_ UINT LogBufferSize
Definition: ndis.h:5804
NTSTATUS NTAPI IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1693
struct _NDIS_PACKET * PNDIS_PACKET
PDEVICE_OBJECT DeviceObject
Definition: miniport.h:35
NDIS_TIMER WakeUpDpcTimer
Definition: ndis.h:2517
BOOLEAN NTAPI KeRegisterBugCheckCallback(IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord, IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, IN PVOID Buffer, IN ULONG Length, IN PUCHAR Component)
Definition: bug.c:1301
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:953
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT _Out_ NDIS_HANDLE * NdisDeviceHandle
Definition: ndis.h:4661
#define IRP_MJ_CLEANUP
#define DEBUG_PACKET
Definition: debug.h:19
NDIS_STATUS EXPORT NdisMQueryAdapterInstanceName(OUT PNDIS_STRING AdapterInstanceName, IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:3037
#define OUT
Definition: typedefs.h:39
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2180
UNICODE_STRING SymbolicLinkName
Definition: ndis.h:2519
PVOID PIRP
Definition: usb.h:38
struct _SCATTER_GATHER_LIST * PSCATTER_GATHER_LIST
Definition: iotypes.h:2095
struct tagContext Context
Definition: acpixf.h:1012
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
PDRIVER_OBJECT DriverObject
Definition: miniport.h:24
VOID EXPORT NdisMRegisterAdapterShutdownHandler(IN NDIS_HANDLE MiniportHandle, IN PVOID ShutdownContext, IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler)
Definition: miniport.c:1693
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:114
#define MmGetSystemAddressForMdl(Mdl)
LIST_ENTRY AdapterListHead
Definition: miniport.c:57
ETH_RCV_INDICATE_HANDLER EthRxIndicateHandler
Definition: ndis.h:2558
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MIN_TRACE
Definition: debug.h:14
#define ULONG_PTR
Definition: config.h:101
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
Definition: interrupt.c:142
BOOLEAN MiniCheckForHang(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:864
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:277
UINT OutPtr
Definition: ndis.h:2463
NDIS_STATUS EXPORT NdisMRegisterDevice(IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_STRING DeviceName, IN PNDIS_STRING SymbolicName, IN PDRIVER_DISPATCH MajorFunctions[], OUT PDEVICE_OBJECT *pDeviceObject, OUT NDIS_HANDLE *NdisDeviceHandle)
Definition: miniport.c:3172
const char * PCSTR
Definition: typedefs.h:51
#define IRP_MN_CANCEL_STOP_DEVICE
NDIS_STATUS EXPORT NdisMWriteLogData(IN NDIS_HANDLE LogHandle, IN PVOID LogBuffer, IN UINT LogBufferSize)
Definition: miniport.c:2969
_In_ UINT _Out_ PNDIS_HANDLE LogHandle
Definition: ndis.h:5363
GLfloat GLfloat p
Definition: glext.h:8902
VOID FASTCALL MiniQueueWorkItem(PLOGICAL_ADAPTER Adapter, NDIS_WORK_ITEM_TYPE WorkItemType, PVOID WorkItemContext, BOOLEAN Top)
Definition: miniport.c:981
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
NDIS_STATUS EXPORT NdisMRegisterMiniport(IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, IN UINT CharacteristicsLength)
Definition: miniport.c:2636
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE _In_ PNDIS_STRING AdapterName
Definition: ndis.h:5995
#define NDIS_STATUS_BAD_CHARACTERISTICS
Definition: ndis.h:469
ULONG MediumHeaderSize
Definition: miniport.h:95
NDIS_STATUS EXPORT NdisQueryAdapterInstanceName(OUT PNDIS_STRING AdapterInstanceName, IN NDIS_HANDLE NdisBindingHandle)
Definition: miniport.c:3267
NTSTATUS NTAPI NdisIPnPStartDevice(IN PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: miniport.c:1884
return STATUS_SUCCESS
Definition: btrfs.c:2725
_Must_inspect_result_ _In_ NDIS_HANDLE NdisBindingHandle
Definition: ndis.h:4717
IoMarkIrpPending(Irp)
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:45
#define RTL_QUERY_REGISTRY_REQUIRED
Definition: nt_native.h:132
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2491
NDIS_INTERFACE_TYPE BusType
Definition: ndis.h:2532
static LPHIST_ENTRY Top
Definition: history.c:53
#define NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, InfoType)
Definition: ndis.h:1333
UCHAR Medium802_3[ETH_LENGTH_OF_ADDRESS]
Definition: miniport.h:14
VOID EXPORT NdisMIndicateStatus(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1564
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:221
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define Int32x32To64(a, b)
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
VOID EXPORT NdisMSetAttributesEx(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE MiniportAdapterContext, IN UINT CheckForHangTimeInSeconds OPTIONAL, IN ULONG AttributeFlags, IN NDIS_INTERFACE_TYPE AdapterType)
Definition: miniport.c:2882
struct _DRIVER_OBJECT * PDRIVER_OBJECT
NDIS_STATUS MiniReset(PLOGICAL_ADAPTER Adapter)
Definition: miniport.c:901
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
static NDIS_MEDIUM MediaArray[MEDIA_ARRAY_SIZE]
Definition: miniport.c:33
PNP_EVENT_HANDLER PnPEventHandler
Definition: ndis.h:1881
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
VOID EXPORT NdisMQueryInformationComplete(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status)
Definition: miniport.c:1206
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
LONGLONG QuadPart
Definition: typedefs.h:112
NDIS_PROTOCOL_CHARACTERISTICS Chars
Definition: protocol.h:13
NDIS_HANDLE EXPORT NdisIMGetBindingContext(IN NDIS_HANDLE NdisBindingHandle)
Definition: miniport.c:3375
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
struct ETHI_FILTER * PETHI_FILTER
union _HARDWARE_ADDRESS::@965 Type
VOID NTAPI MiniportWorker(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
Definition: miniport.c:1222
NDIS_M_STATUS_HANDLER StatusHandler
Definition: ndis.h:2564
NDIS_STATUS ProIndicatePacket(PLOGICAL_ADAPTER Adapter, PNDIS_PACKET Packet)
Definition: protocol.c:243
PNDIS_STRING SymbolicName
Definition: miniport.h:36
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675