Start removing dead code and ReactOS specific structure fields (the NDIS structures are official, documented and contain all we need).
Modified: trunk/reactos/drivers/net/ndis/include/debug.h
Modified: trunk/reactos/drivers/net/ndis/include/miniport.h
Modified: trunk/reactos/drivers/net/ndis/include/ndissys.h
Modified: trunk/reactos/drivers/net/ndis/include/protocol.h
Modified: trunk/reactos/drivers/net/ndis/ndis/hardware.c
Modified: trunk/reactos/drivers/net/ndis/ndis/io.c
Modified: trunk/reactos/drivers/net/ndis/ndis/memory.c
Modified: trunk/reactos/drivers/net/ndis/ndis/miniport.c
Modified: trunk/reactos/drivers/net/ndis/ndis/protocol.c

Modified: trunk/reactos/drivers/net/ndis/include/debug.h
--- trunk/reactos/drivers/net/ndis/include/debug.h	2005-08-24 00:04:21 UTC (rev 17496)
+++ trunk/reactos/drivers/net/ndis/include/debug.h	2005-08-24 01:51:49 UTC (rev 17497)
@@ -14,7 +14,6 @@
 #define MID_TRACE      0x00000002
 #define MAX_TRACE      0x00000003
 
-#define DEBUG_REFCOUNT 0x00000100
 #define DEBUG_MINIPORT 0x00000200
 #define DEBUG_PROTOCOL 0x00000400
 #define DEBUG_PACKET   0x00000800

Modified: trunk/reactos/drivers/net/ndis/include/miniport.h
--- trunk/reactos/drivers/net/ndis/include/miniport.h	2005-08-24 00:04:21 UTC (rev 17496)
+++ trunk/reactos/drivers/net/ndis/include/miniport.h	2005-08-24 01:51:49 UTC (rev 17497)
@@ -19,16 +19,15 @@
 } HARDWARE_ADDRESS, *PHARDWARE_ADDRESS;
 
 /* Information about a miniport */
-typedef struct _MINIPORT_DRIVER {
-    LIST_ENTRY                      ListEntry;          /* Entry on global list */
-    KSPIN_LOCK                      Lock;               /* Protecting spin lock */
-    ULONG                           RefCount;           /* Reference count */
-    NDIS_MINIPORT_CHARACTERISTICS   Chars;              /* Miniport characteristics */
-    WORK_QUEUE_ITEM                 WorkItem;           /* Work item */
-    PDRIVER_OBJECT                  DriverObject;       /* Driver object of miniport */
-    LIST_ENTRY                      AdapterListHead;    /* Adapters created by miniport */
-    PUNICODE_STRING                 RegistryPath;       /* SCM Registry key */
-} MINIPORT_DRIVER, *PMINIPORT_DRIVER;
+typedef struct _NDIS_M_DRIVER_BLOCK {
+    LIST_ENTRY                      ListEntry;                /* Entry on global list */
+    KSPIN_LOCK                      Lock;                     /* Protecting spin lock */
+    NDIS_MINIPORT_CHARACTERISTICS   MiniportCharacteristics;  /* Miniport characteristics */
+    WORK_QUEUE_ITEM                 WorkItem;                 /* Work item */
+    PDRIVER_OBJECT                  DriverObject;             /* Driver object of miniport */
+    LIST_ENTRY                      DeviceList;               /* Adapters created by miniport */
+    PUNICODE_STRING                 RegistryPath;             /* SCM Registry key */
+} NDIS_M_DRIVER_BLOCK, *PNDIS_M_DRIVER_BLOCK;
 
 /* resources allocated on behalf on the miniport */
 #define MINIPORT_RESOURCE_TYPE_MEMORY 0
@@ -69,25 +68,18 @@
     ULONG             BusNumber;
 } NDIS_WRAPPER_CONTEXT, *PNDIS_WRAPPER_CONTEXT;
 
-#define GET_MINIPORT_DRIVER(Handle)((PMINIPORT_DRIVER)Handle)
+#define GET_MINIPORT_DRIVER(Handle)((PNDIS_M_DRIVER_BLOCK)Handle)
 
 /* Information about a logical adapter */
 typedef struct _LOGICAL_ADAPTER
 {
     NDIS_MINIPORT_BLOCK         NdisMiniportBlock;      /* NDIS defined fields */
-    KDPC                        MiniportDpc;            /* DPC routine for adapter */
     BOOLEAN                     MiniportBusy;           /* A MiniportXxx routine is executing */
-    ULONG                       WorkQueueLevel;         /* Number of used work item buffers */
-    INTERNAL_NDIS_MINIPORT_WORK_ITEM     WorkQueue[NDIS_MINIPORT_WORK_QUEUE_SIZE];
-    PINTERNAL_NDIS_MINIPORT_WORK_ITEM    WorkQueueHead;          /* Head of work queue */
-    PINTERNAL_NDIS_MINIPORT_WORK_ITEM    WorkQueueTail;          /* Tail of work queue */
+    PNDIS_MINIPORT_WORK_ITEM    WorkQueueHead;          /* Head of work queue */
+    PNDIS_MINIPORT_WORK_ITEM    WorkQueueTail;          /* Tail of work queue */
     LIST_ENTRY                  ListEntry;              /* Entry on global list */
     LIST_ENTRY                  MiniportListEntry;      /* Entry on miniport driver list */
     LIST_ENTRY                  ProtocolListHead;       /* List of bound protocols */
-    ULONG                       RefCount;               /* Reference count */
-    PMINIPORT_DRIVER            Miniport;               /* Miniport owning this adapter */
-    ULONG                       Attributes;             /* Attributes of adapter */
-    BOOLEAN                     AttributesSet;          /* Whether NdisMSetAttributes(Ex) has been called */
     PVOID                       QueryBuffer;            /* Buffer to use for queries */
     ULONG                       QueryBufferLength;      /* Length of QueryBuffer */
     ULONG                       MediumHeaderSize;       /* Size of medium header */
@@ -95,12 +87,7 @@
     ULONG                       AddressLength;          /* Length of hardware address */
     PUCHAR                      LookaheadBuffer;        /* Pointer to lookahead buffer */
     ULONG                       LookaheadLength;        /* Length of lookahead buffer */
-    PNDIS_PACKET                PacketQueueHead;        /* Head of packet queue */
-    PNDIS_PACKET                PacketQueueTail;        /* Head of packet queue */
-    PNDIS_PACKET                LoopPacket;             /* Current packet beeing looped */
     PMINIPORT_BUGCHECK_CONTEXT  BugcheckContext;        /* Adapter's shutdown handler */
-    KEVENT                      DmaEvent;               /* Event to support DMA register allocation */
-    KSPIN_LOCK                  DmaLock;                /* Spinlock to protect the dma list */
 } LOGICAL_ADAPTER, *PLOGICAL_ADAPTER;
 
 #define GET_LOGICAL_ADAPTER(Handle)((PLOGICAL_ADAPTER)Handle)
@@ -146,7 +133,7 @@
 NDIS_STATUS
 FASTCALL
 MiniQueueWorkItem(
-    struct _ADAPTER_BINDING *AdapterBinding,
+    PLOGICAL_ADAPTER    Adapter,
     NDIS_WORK_ITEM_TYPE WorkItemType,
     PVOID               WorkItemContext);
 
@@ -154,13 +141,12 @@
 FASTCALL
 MiniDequeueWorkItem(
     PLOGICAL_ADAPTER    Adapter,
-    struct _ADAPTER_BINDING **AdapterBinding,
     NDIS_WORK_ITEM_TYPE *WorkItemType,
     PVOID               *WorkItemContext);
 
 NDIS_STATUS
 MiniDoRequest(
-    struct _ADAPTER_BINDING *AdapterBinding,
+    PNDIS_MINIPORT_BLOCK Adapter,
     PNDIS_REQUEST NdisRequest);
 
 BOOLEAN

Modified: trunk/reactos/drivers/net/ndis/include/ndissys.h
--- trunk/reactos/drivers/net/ndis/include/ndissys.h	2005-08-24 00:04:21 UTC (rev 17496)
+++ trunk/reactos/drivers/net/ndis/include/ndissys.h	2005-08-24 01:51:49 UTC (rev 17497)
@@ -30,16 +30,8 @@
 #include <ndk/ntndk.h>
 #endif
 
-#define NDIS_MINIPORT_WORK_QUEUE_SIZE 10
-
 struct _ADAPTER_BINDING;
 
-typedef struct _INTERNAL_NDIS_MINIPORT_WORK_ITEM {
-    SINGLE_LIST_ENTRY Link;
-    struct _ADAPTER_BINDING *AdapterBinding;
-    NDIS_MINIPORT_WORK_ITEM RealWorkItem;
-} INTERNAL_NDIS_MINIPORT_WORK_ITEM, *PINTERNAL_NDIS_MINIPORT_WORK_ITEM;
-
 typedef struct _NDISI_PACKET_POOL {
   NDIS_SPIN_LOCK  SpinLock;
   struct _NDIS_PACKET *FreeList;
@@ -60,50 +52,6 @@
 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
 #define NDIS_TAG  0x4e4d4953
 
-#ifdef DBG
-
-#define DEBUG_REFCHECK(Object) {            \
-    if ((Object)->RefCount <= 0) {          \
-        NDIS_DbgPrint(MIN_TRACE, ("Object at (0x%X) has invalid reference count (%d).\n", \
-            (Object), (Object)->RefCount)); \
-        }                                   \
-}
-
-#else
-
-#define DEBUG_REFCHECK(Object)
-
-#endif
-
-
-/*
- * VOID ReferenceObject(
- *     PVOID Object)
- */
-#define ReferenceObject(Object)                         \
-{                                                       \
-    DEBUG_REFCHECK(Object);                             \
-    NDIS_DbgPrint(DEBUG_REFCOUNT, ("Referencing object at (0x%X). RefCount (%d).\n", \
-        (Object), (Object)->RefCount));                 \
-                                                        \
-    InterlockedIncrement((PLONG)&((Object)->RefCount)); \
-}
-
-/*
- * VOID DereferenceObject(
- *     PVOID Object)
- */
-#define DereferenceObject(Object)                                \
-{                                                                \
-    DEBUG_REFCHECK(Object);                                      \
-    NDIS_DbgPrint(DEBUG_REFCOUNT, ("Dereferencing object at (0x%X). RefCount (%d).\n", \
-        (Object), (Object)->RefCount));                          \
-                                                                 \
-    if (InterlockedDecrement((PLONG)&((Object)->RefCount)) == 0) \
-        PoolFreeBuffer(Object);                                  \
-}
-
-
 #define MIN(value1, value2) \
     ((value1 < value2)? value1 : value2)
 

Modified: trunk/reactos/drivers/net/ndis/include/protocol.h
--- trunk/reactos/drivers/net/ndis/include/protocol.h	2005-08-24 00:04:21 UTC (rev 17496)
+++ trunk/reactos/drivers/net/ndis/include/protocol.h	2005-08-24 01:51:49 UTC (rev 17497)
@@ -11,7 +11,6 @@
 typedef struct _PROTOCOL_BINDING {
     LIST_ENTRY                    ListEntry;        /* Entry on global list */
     KSPIN_LOCK                    Lock;             /* Protecting spin lock */
-    ULONG                         RefCount;         /* Reference count */
     NDIS_PROTOCOL_CHARACTERISTICS Chars;            /* Characteristics */
     WORK_QUEUE_ITEM               WorkItem;         /* Work item */
     LIST_ENTRY                    AdapterListHead;  /* List of adapter bindings */
@@ -27,11 +26,17 @@
     LIST_ENTRY        ProtocolListEntry;        /* Entry on protocol binding adapter list */
     LIST_ENTRY        AdapterListEntry;         /* Entry on logical adapter list */
     KSPIN_LOCK        Lock;                     /* Protecting spin lock */
-    ULONG             RefCount;                 /* Reference count */
     PPROTOCOL_BINDING ProtocolBinding;          /* Protocol that opened adapter */
     PLOGICAL_ADAPTER  Adapter;                  /* Adapter opened by protocol */
 } ADAPTER_BINDING, *PADAPTER_BINDING;
 
+typedef struct _NDIS_REQUEST_MAC_BLOCK {
+    PVOID Unknown1;
+    PNDIS_OPEN_BLOCK Binding;
+    PVOID Unknown3;
+    PVOID Unknown4;
+} NDIS_REQUEST_MAC_BLOCK, *PNDIS_REQUEST_MAC_BLOCK;
+
 #define GET_ADAPTER_BINDING(Handle)((PADAPTER_BINDING)Handle)
 
 

Modified: trunk/reactos/drivers/net/ndis/ndis/hardware.c
--- trunk/reactos/drivers/net/ndis/ndis/hardware.c	2005-08-24 00:04:21 UTC (rev 17496)
+++ trunk/reactos/drivers/net/ndis/ndis/hardware.c	2005-08-24 01:51:49 UTC (rev 17497)
@@ -61,7 +61,7 @@
     IN  ULONG                   SlotNumber,
     OUT PNDIS_RESOURCE_LIST     *AssignedResources)
 {
-  PNDIS_MINIPORT_BLOCK MiniportBlock = &((PLOGICAL_ADAPTER)MiniportHandle)->NdisMiniportBlock;
+  PNDIS_MINIPORT_BLOCK MiniportBlock = (PNDIS_MINIPORT_BLOCK)MiniportHandle;
 
   if (MiniportBlock->BusType != PCIBus ||
       MiniportBlock->AllocatedResources == NULL)
@@ -196,11 +196,10 @@
     IN  PVOID       Buffer,
     IN  ULONG       Length)
 {
-  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)NdisAdapterHandle;
+  PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)NdisAdapterHandle;
   /* Slot number is ignored since W2K for all NDIS drivers. */
   return HalGetBusDataByOffset(PCIConfiguration,
-                               Adapter->NdisMiniportBlock.BusNumber,
-                               Adapter->NdisMiniportBlock.SlotNumber,
+                               Adapter->BusNumber, Adapter->SlotNumber,
                                Buffer, Offset, Length);
 }
 
@@ -217,11 +216,10 @@
     IN  PVOID       Buffer,
     IN  ULONG       Length)
 {
-  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)NdisAdapterHandle;
+  PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)NdisAdapterHandle;
   /* Slot number is ignored since W2K for all NDIS drivers. */
   return HalSetBusDataByOffset(PCIConfiguration,
-                               Adapter->NdisMiniportBlock.BusNumber,
-                               Adapter->NdisMiniportBlock.SlotNumber,
+                               Adapter->BusNumber, Adapter->SlotNumber,
                                Buffer, Offset, Length);
 }
 

Modified: trunk/reactos/drivers/net/ndis/ndis/io.c
--- trunk/reactos/drivers/net/ndis/ndis/io.c	2005-08-24 00:04:21 UTC (rev 17496)
+++ trunk/reactos/drivers/net/ndis/ndis/io.c	2005-08-24 01:51:49 UTC (rev 17497)
@@ -44,14 +44,14 @@
   KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
 
   /* Call the deferred interrupt service handler for this adapter */
-  (*Adapter->Miniport->Chars.HandleInterruptHandler)(
+  (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.HandleInterruptHandler)(
       Adapter->NdisMiniportBlock.MiniportAdapterContext);
 
   KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
     {
       if ((!WasBusy) && (Adapter->WorkQueueHead))
         {
-          KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
+          KeInsertQueueDpc(&Adapter->NdisMiniportBlock.DeferredDpc, NULL, NULL);
         }
       else
         {
@@ -62,8 +62,8 @@
 
   /* re-enable the interrupt */
   NDIS_DbgPrint(MAX_TRACE, ("re-enabling the interrupt\n"));
-  if(Adapter->Miniport->Chars.EnableInterruptHandler)
-    (*Adapter->Miniport->Chars.EnableInterruptHandler)(
+  if(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.EnableInterruptHandler)
+    (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.EnableInterruptHandler)(
         Adapter->NdisMiniportBlock.MiniportAdapterContext);
 
   NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
@@ -84,18 +84,19 @@
 {
   BOOLEAN InterruptRecognized;
   BOOLEAN QueueMiniportHandleInterrupt;
-  PLOGICAL_ADAPTER Adapter = GET_LOGICAL_ADAPTER(ServiceContext);
+  PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)ServiceContext;
 
   NDIS_DbgPrint(MAX_TRACE, ("Called. Adapter (0x%X)\n", Adapter));
 
-  (*Adapter->Miniport->Chars.ISRHandler)(&InterruptRecognized,
+  (*Adapter->DriverHandle->MiniportCharacteristics.ISRHandler)(
+      &InterruptRecognized,
       &QueueMiniportHandleInterrupt,
-      Adapter->NdisMiniportBlock.MiniportAdapterContext);
+      Adapter->MiniportAdapterContext);
 
   if (QueueMiniportHandleInterrupt)
     {
       NDIS_DbgPrint(MAX_TRACE, ("Queueing DPC.\n"));
-      KeInsertQueueDpc(&Adapter->NdisMiniportBlock.Interrupt->InterruptDpc, NULL, NULL);
+      KeInsertQueueDpc(&Adapter->Interrupt->InterruptDpc, NULL, NULL);
     }
 
   NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
@@ -228,15 +229,15 @@
  *     - Called at IRQL = DISPATCH_LEVEL
  */
 {
-  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)Context;
+  PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)Context;
 
   NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
 
-  Adapter->NdisMiniportBlock.MapRegisters[Adapter->NdisMiniportBlock.CurrentMapRegister].MapRegister = MapRegisterBase;
+  Adapter->MapRegisters[Adapter->CurrentMapRegister].MapRegister = MapRegisterBase;
 
   NDIS_DbgPrint(MAX_TRACE, ("setting event and leaving.\n"));
 
-  KeSetEvent(&Adapter->DmaEvent, 0, FALSE);
+  KeSetEvent(Adapter->AllocationEvent, 0, FALSE);
 
   /* this is only the thing to do for busmaster NICs */
   return DeallocateObjectKeepRegisters;
@@ -284,33 +285,34 @@
  *       map registers to 32.
  */
 {
-  DEVICE_DESCRIPTION Description;
-  PDMA_ADAPTER       AdapterObject = 0;
-  UINT               MapRegistersPerBaseRegister = 0;
-  ULONG              AvailableMapRegisters;
-  NTSTATUS           NtStatus;
-  PLOGICAL_ADAPTER   Adapter = 0;
-  PDEVICE_OBJECT     DeviceObject = 0;
-  KIRQL              OldIrql;
+  DEVICE_DESCRIPTION   Description;
+  PDMA_ADAPTER         AdapterObject = 0;
+  UINT                 MapRegistersPerBaseRegister = 0;
+  ULONG                AvailableMapRegisters;
+  NTSTATUS             NtStatus;
+  PNDIS_MINIPORT_BLOCK Adapter = 0;
+  PDEVICE_OBJECT       DeviceObject = 0;
+  KEVENT               AllocationEvent;
+  KIRQL                OldIrql;
 
   NDIS_DbgPrint(MAX_TRACE, ("called: Handle 0x%x, DmaChannel 0x%x, DmaSize 0x%x, BaseMapRegsNeeded: 0x%x, MaxBuffer: 0x%x.\n",
                             MiniportAdapterHandle, DmaChannel, DmaSize, BaseMapRegistersNeeded, MaximumBufferSize));
 
   memset(&Description,0,sizeof(Description));
 
-  Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
+  Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
 
   ASSERT(Adapter);
 
   /* only bus masters may call this routine */
-  ASSERT(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER);
-  if(!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER))
+  ASSERT(Adapter->Flags & NDIS_ATTRIBUTE_BUS_MASTER);
+  if(!(Adapter->Flags & NDIS_ATTRIBUTE_BUS_MASTER))
     return NDIS_STATUS_SUCCESS;
 
-  DeviceObject = Adapter->NdisMiniportBlock.DeviceObject;
+  DeviceObject = Adapter->DeviceObject;
 
-  KeInitializeEvent(&Adapter->DmaEvent, NotificationEvent, FALSE);
-  KeInitializeSpinLock(&Adapter->DmaLock);
+  KeInitializeEvent(&AllocationEvent, NotificationEvent, FALSE);
+  Adapter->AllocationEvent = &AllocationEvent;
 
   /*
   * map registers correlate to physical pages.  ndis documents a
@@ -330,12 +332,12 @@
   Description.Master = TRUE;                         /* implied by calling this function */
   Description.ScatterGather = TRUE;                  /* XXX UNTRUE: All BM DMA are S/G (ms seems to do this) */
   Description.Dma32BitAddresses = DmaSize;
-  Description.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
-  Description.InterfaceType = Adapter->NdisMiniportBlock.BusType;
+  Description.BusNumber = Adapter->BusNumber;
+  Description.InterfaceType = Adapter->BusType;
   Description.DmaChannel = DmaChannel;
   Description.MaximumLength = MaximumBufferSize;
 
-  if(Adapter->NdisMiniportBlock.AdapterType == Isa)
+  if(Adapter->AdapterType == Isa)
     {
       /* system dma */
       if(DmaChannel < 4)
@@ -345,7 +347,7 @@
 
       Description.DmaSpeed = Compatible;
     }
-  else if(Adapter->NdisMiniportBlock.AdapterType == PCIBus)
+  else if(Adapter->AdapterType == PCIBus)
     {
       if(DmaSize == NDIS_DMA_64BITS)
         Description.Dma64BitAddresses = TRUE;
@@ -359,8 +361,7 @@
     }
 
   AdapterObject = IoGetDmaAdapter(
-    Adapter->NdisMiniportBlock.PhysicalDeviceObject,
-    &Description, &AvailableMapRegisters);
+    Adapter->PhysicalDeviceObject, &Description, &AvailableMapRegisters);
 
   if(!AdapterObject)
     {
@@ -368,7 +369,7 @@
       return NDIS_STATUS_RESOURCES;
     }
 
-  Adapter->NdisMiniportBlock.SystemAdapterObject = AdapterObject;
+  Adapter->SystemAdapterObject = AdapterObject;
 
   if(AvailableMapRegisters < MapRegistersPerBaseRegister)
     {
@@ -379,22 +380,22 @@
     }
 
   /* allocate & zero space in the miniport block for the registers */
-  Adapter->NdisMiniportBlock.MapRegisters = ExAllocatePool(NonPagedPool, BaseMapRegistersNeeded * sizeof(MAP_REGISTER_ENTRY));
-  if(!Adapter->NdisMiniportBlock.MapRegisters)
+  Adapter->MapRegisters = ExAllocatePool(NonPagedPool, BaseMapRegistersNeeded * sizeof(MAP_REGISTER_ENTRY));
+  if(!Adapter->MapRegisters)
     {
       NDIS_DbgPrint(MIN_TRACE, ("insufficient resources.\n"));
       return NDIS_STATUS_RESOURCES;
     }
 
-  memset(Adapter->NdisMiniportBlock.MapRegisters, 0, BaseMapRegistersNeeded * sizeof(MAP_REGISTER_ENTRY));
-  Adapter->NdisMiniportBlock.BaseMapRegistersNeeded = (USHORT)BaseMapRegistersNeeded;
+  memset(Adapter->MapRegisters, 0, BaseMapRegistersNeeded * sizeof(MAP_REGISTER_ENTRY));
+  Adapter->BaseMapRegistersNeeded = (USHORT)BaseMapRegistersNeeded;
 
   while(BaseMapRegistersNeeded)
     {
       NDIS_DbgPrint(MAX_TRACE, ("iterating, basemapregistersneeded = %d\n", BaseMapRegistersNeeded));
 
       BaseMapRegistersNeeded--;
-      Adapter->NdisMiniportBlock.CurrentMapRegister = (USHORT)BaseMapRegistersNeeded;
+      Adapter->CurrentMapRegister = (USHORT)BaseMapRegistersNeeded;
       KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
         {
           NtStatus = AdapterObject->DmaOperations->AllocateAdapterChannel(
@@ -411,7 +412,7 @@
 
       NDIS_DbgPrint(MAX_TRACE, ("waiting on event\n"));
 
-      NtStatus = KeWaitForSingleObject(&Adapter->DmaEvent, Executive, KernelMode, FALSE, 0);
+      NtStatus = KeWaitForSingleObject(&AllocationEvent, Executive, KernelMode, FALSE, 0);
 
       if(!NT_SUCCESS(NtStatus))
         {
@@ -421,7 +422,7 @@
 
       NDIS_DbgPrint(MAX_TRACE, ("resetting event\n"));
 
-      KeResetEvent(&Adapter->DmaEvent);
+      KeResetEvent(&AllocationEvent);
     }
 
   NDIS_DbgPrint(MAX_TRACE, ("returning success\n"));
@@ -458,7 +459,7 @@
  *     - The caller supplies storage for the physical address array.
  */
 {
-  PLOGICAL_ADAPTER Adapter = 0;
+  PNDIS_MINIPORT_BLOCK Adapter;
   PVOID CurrentVa;
   ULONG TotalLength;
   PHYSICAL_ADDRESS ReturnedAddress;
@@ -467,7 +468,7 @@
   ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
   ASSERT(MiniportAdapterHandle && Buffer && PhysicalAddressArray && ArraySize);
 
-  Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
+  Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
   CurrentVa = MmGetMdlVirtualAddress(Buffer);
   TotalLength = MmGetMdlByteCount(Buffer);
 
@@ -475,12 +476,12 @@
     {
       ULONG Length = TotalLength;
 
-      ReturnedAddress = Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->MapTransfer(
-          Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer,
-          Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].MapRegister,
+      ReturnedAddress = Adapter->SystemAdapterObject->DmaOperations->MapTransfer(
+          Adapter->SystemAdapterObject, Buffer,
+          Adapter->MapRegisters[PhysicalMapRegister].MapRegister,
           CurrentVa, &Length, WriteToDevice);
 
-      Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].WriteToDevice = WriteToDevice;
+      Adapter->MapRegisters[PhysicalMapRegister].WriteToDevice = WriteToDevice;
 
       PhysicalAddressArray[LoopCount].PhysicalAddress = ReturnedAddress;
       PhysicalAddressArray[LoopCount].Length = Length;
@@ -514,22 +515,22 @@
  *     - May be called at IRQL <= DISPATCH_LEVEL
  */
 {
-  PLOGICAL_ADAPTER Adapter = 0;
+  PNDIS_MINIPORT_BLOCK Adapter;
   VOID *CurrentVa;
   ULONG Length;
 
   ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
   ASSERT(MiniportAdapterHandle && Buffer);
 
-  Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
+  Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
   CurrentVa = MmGetMdlVirtualAddress(Buffer);
   Length = MmGetMdlByteCount(Buffer);
 
-  Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->FlushAdapterBuffers(
-      Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer,
-      Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].MapRegister,
+  Adapter->SystemAdapterObject->DmaOperations->FlushAdapterBuffers(
+      Adapter->SystemAdapterObject, Buffer,
+      Adapter->MapRegisters[PhysicalMapRegister].MapRegister,
       CurrentVa, Length,
-      Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].WriteToDevice);
+      Adapter->MapRegisters[PhysicalMapRegister].WriteToDevice);
 }
 
 
@@ -600,42 +601,42 @@
  * NOTES:
  */
 {
-  KIRQL            OldIrql;
-  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
-  PDMA_ADAPTER     AdapterObject;
-  UINT             MapRegistersPerBaseRegister;
-  UINT             i;
+  KIRQL                OldIrql;
+  PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+  PDMA_ADAPTER         AdapterObject;
+  UINT                 MapRegistersPerBaseRegister;
+  UINT                 i;
 
   NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
 
   ASSERT(Adapter);
 
   /* only bus masters may call this routine */
-  ASSERT(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER);
-  if(!(Adapter->NdisMiniportBlock.Flags & NDIS_ATTRIBUTE_BUS_MASTER) ||
-     Adapter->NdisMiniportBlock.SystemAdapterObject == NULL)
+  ASSERT(Adapter->Flags & NDIS_ATTRIBUTE_BUS_MASTER);
+  if(!(Adapter->Flags & NDIS_ATTRIBUTE_BUS_MASTER) ||
+     Adapter->SystemAdapterObject == NULL)
     return;
 
-  MapRegistersPerBaseRegister = ((Adapter->NdisMiniportBlock.MaximumPhysicalMapping - 2) / PAGE_SIZE) + 2;
+  MapRegistersPerBaseRegister = ((Adapter->MaximumPhysicalMapping - 2) / PAGE_SIZE) + 2;
 
-  AdapterObject = Adapter->NdisMiniportBlock.SystemAdapterObject;
+  AdapterObject = Adapter->SystemAdapterObject;
 
   KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
     {
-      for(i = 0; i < Adapter->NdisMiniportBlock.BaseMapRegistersNeeded; i++)
+      for(i = 0; i < Adapter->BaseMapRegistersNeeded; i++)
         {
           AdapterObject->DmaOperations->FreeMapRegisters(
-              Adapter->NdisMiniportBlock.SystemAdapterObject,
-              Adapter->NdisMiniportBlock.MapRegisters[i].MapRegister,
+              Adapter->SystemAdapterObject,
+              Adapter->MapRegisters[i].MapRegister,
               MapRegistersPerBaseRegister);
         }
     }
  KeLowerIrql(OldIrql);
 
  AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
- Adapter->NdisMiniportBlock.SystemAdapterObject = NULL;
+ Adapter->SystemAdapterObject = NULL;
 
- ExFreePool(Adapter->NdisMiniportBlock.MapRegisters);
+ ExFreePool(Adapter->MapRegisters);
 }
 
 
@@ -771,7 +772,7 @@
   ULONG MappedIRQ;
   KIRQL DIrql;
   KAFFINITY Affinity;
-  PLOGICAL_ADAPTER Adapter = GET_LOGICAL_ADAPTER(MiniportAdapterHandle);
+  PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
 
   NDIS_DbgPrint(MAX_TRACE, ("Called. InterruptVector (0x%X)  InterruptLevel (0x%X)  "
       "SharedInterrupt (%d)  InterruptMode (0x%X)\n",
@@ -787,10 +788,9 @@
 
   Interrupt->SharedInterrupt = SharedInterrupt;
 
-  Adapter->NdisMiniportBlock.Interrupt = Interrupt;
+  Adapter->Interrupt = Interrupt;
 
-  MappedIRQ = HalGetInterruptVector(Adapter->NdisMiniportBlock.BusType,
-                                    Adapter->NdisMiniportBlock.BusNumber,
+  MappedIRQ = HalGetInterruptVector(Adapter->BusType, Adapter->BusNumber,
                                     InterruptLevel, InterruptVector, &DIrql,
                                     &Affinity);
 
@@ -837,9 +837,9 @@
  *     Status of operation
  */
 {
-  PHYSICAL_ADDRESS PortAddress, TranslatedAddress;
-  PLOGICAL_ADAPTER Adapter  = GET_LOGICAL_ADAPTER(MiniportAdapterHandle);
-  ULONG            AddressSpace = 1;    /* FIXME The HAL handles this wrong atm */
+  PHYSICAL_ADDRESS     PortAddress, TranslatedAddress;
+  PNDIS_MINIPORT_BLOCK Adapter  = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
+  ULONG                AddressSpace = 1;    /* FIXME The HAL handles this wrong atm */
 
   NDIS_DbgPrint(MAX_TRACE, ("Called - InitialPort 0x%x, NumberOfPorts 0x%x\n", InitialPort, NumberOfPorts));
 
@@ -858,8 +858,7 @@
 
   NDIS_DbgPrint(MAX_TRACE, ("Translating address 0x%x 0x%x\n", PortAddress.u.HighPart, PortAddress.u.LowPart));
 
-  if(!HalTranslateBusAddress(Adapter->NdisMiniportBlock.BusType,
-                             Adapter->NdisMiniportBlock.BusNumber,
+  if(!HalTranslateBusAddress(Adapter->BusType, Adapter->BusNumber,
                              PortAddress, &AddressSpace, &TranslatedAddress))
     {
       NDIS_DbgPrint(MIN_TRACE, ("Unable to translate address\n"));

Modified: trunk/reactos/drivers/net/ndis/ndis/memory.c
--- trunk/reactos/drivers/net/ndis/ndis/memory.c	2005-08-24 00:04:21 UTC (rev 17496)
+++ trunk/reactos/drivers/net/ndis/ndis/memory.c	2005-08-24 01:51:49 UTC (rev 17497)
@@ -189,12 +189,12 @@
  *     - Cached is ignored; we always allocate non-cached
  */
 {
-  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
+  PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
 
   NDIS_DbgPrint(MAX_TRACE,("Called.\n"));
 
-  *VirtualAddress = Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->AllocateCommonBuffer(
-      Adapter->NdisMiniportBlock.SystemAdapterObject, Length, PhysicalAddress, Cached);
+  *VirtualAddress = Adapter->SystemAdapterObject->DmaOperations->AllocateCommonBuffer(
+      Adapter->SystemAdapterObject, Length, PhysicalAddress, Cached);
 }
 
 
@@ -267,7 +267,7 @@
  */
 {
   HANDLE ThreadHandle;
-  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
+  PNDIS_MINIPORT_BLOCK Adapter = (PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle;
   PMINIPORT_SHARED_MEMORY Memory;
 
   NDIS_DbgPrint(MAX_TRACE,("Called.\n"));
@@ -283,7 +283,7 @@
       return;
     }
 
-  Memory->AdapterObject = Adapter->NdisMiniportBlock.SystemAdapterObject;
+  Memory->AdapterObject = Adapter->SystemAdapterObject;
   Memory->Length = Length;
   Memory->PhysicalAddress = PhysicalAddress;
   Memory->VirtualAddress = VirtualAddress;

Modified: trunk/reactos/drivers/net/ndis/ndis/miniport.c
--- trunk/reactos/drivers/net/ndis/ndis/miniport.c	2005-08-24 00:04:21 UTC (rev 17496)
+++ trunk/reactos/drivers/net/ndis/ndis/miniport.c	2005-08-24 01:51:49 UTC (rev 17497)
@@ -330,15 +330,17 @@
 
 VOID NTAPI
 MiniRequestComplete(
-    IN PADAPTER_BINDING AdapterBinding,
+    IN PNDIS_MINIPORT_BLOCK Adapter,
     IN PNDIS_REQUEST Request,
-    IN  NDIS_STATUS Status)
+    IN NDIS_STATUS Status)
 {
+    PNDIS_REQUEST_MAC_BLOCK MacBlock = (PNDIS_REQUEST_MAC_BLOCK)Request->MacReserved;
+
     NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
 
-    if( AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler ) {
-        (*AdapterBinding->ProtocolBinding->Chars.RequestCompleteHandler)(
-            AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
+    if( MacBlock->Binding->RequestCompleteHandler ) {
+        (*MacBlock->Binding->RequestCompleteHandler)(
+            MacBlock->Binding->ProtocolBindingContext,
             Request,
             Status);
     }
@@ -518,7 +520,6 @@
 
               if (RtlCompareUnicodeString(AdapterName, &Adapter->NdisMiniportBlock.MiniportName, TRUE) == 0)
                 {
-                  ReferenceObject(Adapter);
                   break;
                 }
 
@@ -588,7 +589,7 @@
   BytesNeeded = (Size == 0)? Adapter->QueryBufferLength : Size;
 
   /* call the miniport's queryinfo handler */
-  NdisStatus = (*Adapter->Miniport->Chars.QueryInformationHandler)(
+  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
       Adapter->NdisMiniportBlock.MiniportAdapterContext,
       Oid,
       Adapter->QueryBuffer,
@@ -616,7 +617,7 @@
           return NDIS_STATUS_RESOURCES;
         }
 
-      NdisStatus = (*Adapter->Miniport->Chars.QueryInformationHandler)(
+      NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
           Adapter->NdisMiniportBlock.MiniportAdapterContext,
           Oid,
           Adapter->QueryBuffer,
@@ -632,9 +633,9 @@
 NDIS_STATUS
 FASTCALL
 MiniQueueWorkItem(
-    PADAPTER_BINDING    AdapterBinding,
-    NDIS_WORK_ITEM_TYPE WorkItemType,
-    PVOID               WorkItemContext)
+    PLOGICAL_ADAPTER     Adapter,
+    NDIS_WORK_ITEM_TYPE  WorkItemType,
+    PVOID                WorkItemContext)
 /*
  * FUNCTION: Queues a work item for execution at a later time
  * ARGUMENTS:
@@ -647,34 +648,22 @@
  *     Status of operation
  */
 {
-    PINTERNAL_NDIS_MINIPORT_WORK_ITEM Item;
-    PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
+    PNDIS_MINIPORT_WORK_ITEM Item;
 
     NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
     
     ASSERT(Adapter);
     ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
     
-#if 0
-    if (Adapter->WorkQueueLevel < NDIS_MINIPORT_WORK_QUEUE_SIZE - 1)
+    Item = ExAllocatePool(NonPagedPool, sizeof(NDIS_MINIPORT_WORK_ITEM));
+    if (Item == NULL)
     {
-        Item = &Adapter->WorkQueue[Adapter->WorkQueueLevel];
-        Adapter->WorkQueueLevel++;
+        NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
+        return NDIS_STATUS_RESOURCES;
     }
-    else
-#endif
-    {
-        Item = ExAllocatePool(NonPagedPool, sizeof(INTERNAL_NDIS_MINIPORT_WORK_ITEM));
-        if (Item == NULL)
-        {
-            NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-            return NDIS_STATUS_RESOURCES;
-        }
-    }
     
-    Item->AdapterBinding = AdapterBinding;
-    Item->RealWorkItem.WorkItemType    = WorkItemType;
-    Item->RealWorkItem.WorkItemContext = WorkItemContext;
+    Item->WorkItemType    = WorkItemType;
+    Item->WorkItemContext = WorkItemContext;
     
     /* safe due to adapter lock held */
     Item->Link.Next = NULL;
@@ -689,7 +678,7 @@
         Adapter->WorkQueueTail = Item;
     }
     
-    KeInsertQueueDpc(&Adapter->MiniportDpc, NULL, NULL);
+    KeInsertQueueDpc(&Adapter->NdisMiniportBlock.DeferredDpc, NULL, NULL);
     
     return NDIS_STATUS_SUCCESS;
 }
@@ -699,7 +688,6 @@
 FASTCALL
 MiniDequeueWorkItem(
     PLOGICAL_ADAPTER    Adapter,
-    PADAPTER_BINDING    *AdapterBinding,
     NDIS_WORK_ITEM_TYPE *WorkItemType,
     PVOID               *WorkItemContext)
 /*
@@ -715,7 +703,7 @@
  *     Status of operation
  */
 {
-    PINTERNAL_NDIS_MINIPORT_WORK_ITEM Item;
+    PNDIS_MINIPORT_WORK_ITEM Item;
     
     NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
     
@@ -724,14 +712,13 @@
     if (Item)
     {
         /* safe due to adapter lock held */
-        Adapter->WorkQueueHead = (PINTERNAL_NDIS_MINIPORT_WORK_ITEM)Item->Link.Next;
+        Adapter->WorkQueueHead = (PNDIS_MINIPORT_WORK_ITEM)Item->Link.Next;
         
         if (Item == Adapter->WorkQueueTail)
             Adapter->WorkQueueTail = NULL;
         
-        *AdapterBinding  = Item->AdapterBinding;
-        *WorkItemType    = Item->RealWorkItem.WorkItemType;
-        *WorkItemContext = Item->RealWorkItem.WorkItemContext;
+        *WorkItemType    = Item->WorkItemType;
+        *WorkItemContext = Item->WorkItemContext;
         
         ExFreePool(Item);
         
@@ -744,7 +731,7 @@
 
 NDIS_STATUS
 MiniDoRequest(
-    PADAPTER_BINDING AdapterBinding,
+    PNDIS_MINIPORT_BLOCK Adapter,
     PNDIS_REQUEST NdisRequest)
 /*
  * FUNCTION: Sends a request to a miniport
@@ -755,17 +742,15 @@
  *     Status of operation
  */
 {
-    PLOGICAL_ADAPTER Adapter = AdapterBinding->Adapter;
-
     NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
     
-    Adapter->NdisMiniportBlock.MediaRequest = NdisRequest;
+    Adapter->MediaRequest = NdisRequest;
     
     switch (NdisRequest->RequestType)
     {
     case NdisRequestQueryInformation:
-        return (*Adapter->Miniport->Chars.QueryInformationHandler)(
-            Adapter->NdisMiniportBlock.MiniportAdapterContext,
+        return (*Adapter->DriverHandle->MiniportCharacteristics.QueryInformationHandler)(
+            Adapter->MiniportAdapterContext,
             NdisRequest->DATA.QUERY_INFORMATION.Oid,
             NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
             NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
@@ -774,8 +759,8 @@
         break;
         
     case NdisRequestSetInformation:
-        return (*Adapter->Miniport->Chars.SetInformationHandler)(
-            Adapter->NdisMiniportBlock.MiniportAdapterContext,
+        return (*Adapter->DriverHandle->MiniportCharacteristics.SetInformationHandler)(
+            Adapter->MiniportAdapterContext,
             NdisRequest->DATA.SET_INFORMATION.Oid,
             NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
             NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
@@ -824,14 +809,13 @@
   NDIS_STATUS NdisStatus;
   PVOID WorkItemContext;
   NDIS_WORK_ITEM_TYPE WorkItemType;
-  PADAPTER_BINDING AdapterBinding;
   PLOGICAL_ADAPTER Adapter = GET_LOGICAL_ADAPTER(DeferredContext);
 
   NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
 
   NdisStatus = 
       MiniDequeueWorkItem
-      (Adapter, &AdapterBinding, &WorkItemType, &WorkItemContext);
+      (Adapter, &WorkItemType, &WorkItemContext);
 
   if (NdisStatus == NDIS_STATUS_SUCCESS)
     {
@@ -844,7 +828,7 @@
 #ifdef DBG
             MiniDisplayPacket((PNDIS_PACKET)WorkItemContext);
 #endif
-            if(Adapter->Miniport->Chars.SendPacketsHandler)
+            if(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)
               {
                 NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's SendPackets handler\n"));
 
@@ -852,7 +836,7 @@
                  * XXX assumes single-packet - prolly OK since we'll call something
                  * different on multi-packet sends
                  */
-                (*Adapter->Miniport->Chars.SendPacketsHandler)(
+                (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendPacketsHandler)(
                     Adapter->NdisMiniportBlock.MiniportAdapterContext, (PPNDIS_PACKET)&WorkItemContext, 1);
 		NdisStatus =
 		    NDIS_GET_PACKET_STATUS((PNDIS_PACKET)WorkItemContext);
@@ -863,7 +847,7 @@
               {
                 NDIS_DbgPrint(MAX_TRACE, ("Calling miniport's Send handler\n"));
 
-                NdisStatus = (*Adapter->Miniport->Chars.SendHandler)(
+                NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.SendHandler)(
                     Adapter->NdisMiniportBlock.MiniportAdapterContext, (PNDIS_PACKET)WorkItemContext, 0);
 
                 NDIS_DbgPrint(MAX_TRACE, ("back from miniport's Send handler\n"));
@@ -897,7 +881,7 @@
             break;
 
           case NdisWorkItemRequest:
-            NdisStatus = MiniDoRequest(AdapterBinding, (PNDIS_REQUEST)WorkItemContext);
+            NdisStatus = MiniDoRequest(&Adapter->NdisMiniportBlock, (PNDIS_REQUEST)WorkItemContext);
 
             if (NdisStatus == NDIS_STATUS_PENDING)
               break;
@@ -906,12 +890,12 @@
               {
                 case NdisRequestQueryInformation:
 		  NdisMQueryInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
-                  MiniRequestComplete( AdapterBinding, (PNDIS_REQUEST)WorkItemContext, NdisStatus );
+                  MiniRequestComplete( &Adapter->NdisMiniportBlock, (PNDIS_REQUEST)WorkItemContext, NdisStatus );
                   break;
 
                 case NdisRequestSetInformation:
                   NdisMSetInformationComplete((NDIS_HANDLE)Adapter, NdisStatus);
-                  MiniRequestComplete( AdapterBinding, (PNDIS_REQUEST)WorkItemContext, NdisStatus );
+                  MiniRequestComplete( &Adapter->NdisMiniportBlock, (PNDIS_REQUEST)WorkItemContext, NdisStatus );
                   break;
 
                 default:
@@ -1037,7 +1021,7 @@
  *     - SystemSpecific2 goes invalid so we copy it
  */
 {
-  PMINIPORT_DRIVER Miniport;
+  PNDIS_M_DRIVER_BLOCK Miniport;
   PUNICODE_STRING RegistryPath;
   WCHAR *RegistryBuffer;
 
@@ -1051,7 +1035,7 @@
   __asm__ ("int $3\n");
 #endif
 
-  Miniport = ExAllocatePool(NonPagedPool, sizeof(MINIPORT_DRIVER));
+  Miniport = ExAllocatePool(NonPagedPool, sizeof(NDIS_M_DRIVER_BLOCK));
 
   if (!Miniport)
     {
@@ -1059,12 +1043,10 @@
       return;
     }
 
-  RtlZeroMemory(Miniport, sizeof(MINIPORT_DRIVER));
+  RtlZeroMemory(Miniport, sizeof(NDIS_M_DRIVER_BLOCK));
 
   KeInitializeSpinLock(&Miniport->Lock);
 
-  Miniport->RefCount = 1;
-
   Miniport->DriverObject = (PDRIVER_OBJECT)SystemSpecific1;
 
   /* set the miniport's driver registry path */
@@ -1091,7 +1073,7 @@
   RegistryPath->Buffer = RegistryBuffer;
   Miniport->RegistryPath = RegistryPath;
 
-  InitializeListHead(&Miniport->AdapterListHead);
+  InitializeListHead(&Miniport->DeviceList);
 
   /* Put miniport in global miniport list */
   ExInterlockedInsertTailList(&MiniportListHead, &Miniport->ListEntry, &MiniportListLock);
@@ -1438,7 +1420,7 @@
    */
 
   NDIS_DbgPrint(MID_TRACE, ("calling MiniportInitialize\n"));
-  NdisStatus = (*Adapter->Miniport->Chars.InitializeHandler)(
+  NdisStatus = (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.InitializeHandler)(
     &OpenErrorStatus, &SelectedMediumIndex, &MediaArray[0],
     MEDIA_ARRAY_SIZE, Adapter, (NDIS_HANDLE)&WrapperContext);
 
@@ -1505,7 +1487,7 @@
   Adapter->NdisMiniportBlock.PnPDeviceState = NdisPnPDeviceStarted;
 
   /* Put adapter in adapter list for this miniport */
-  ExInterlockedInsertTailList(&Adapter->Miniport->AdapterListHead, &Adapter->MiniportListEntry, &Adapter->Miniport->Lock);
+  ExInterlockedInsertTailList(&Adapter->NdisMiniportBlock.DriverHandle->DeviceList, &Adapter->MiniportListEntry, &Adapter->NdisMiniportBlock.DriverHandle->Lock);
 
   /* Put adapter in global adapter list */
   ExInterlockedInsertTailList(&AdapterListHead, &Adapter->ListEntry, &AdapterListLock);
@@ -1532,16 +1514,16 @@
   KIRQL OldIrql;
 
   /* Remove adapter from adapter list for this miniport */
-  KeAcquireSpinLock(&Adapter->Miniport->Lock, &OldIrql);
+  KeAcquireSpinLock(&Adapter->NdisMiniportBlock.DriverHandle->Lock, &OldIrql);
   RemoveEntryList(&Adapter->MiniportListEntry);
-  KeReleaseSpinLock(&Adapter->Miniport->Lock, OldIrql);
+  KeReleaseSpinLock(&Adapter->NdisMiniportBlock.DriverHandle->Lock, OldIrql);
 
[truncated at 1000 lines; 289 more skipped]