remove internal files
authorLuigi Rizzo <rizzo@iet.unipi.it>
Mon, 22 Sep 2014 13:17:01 +0000 (15:17 +0200)
committerLuigi Rizzo <rizzo@iet.unipi.it>
Mon, 22 Sep 2014 13:17:01 +0000 (15:17 +0200)
16 files changed:
modified_passthru/miniport.c [deleted file]
modified_passthru/passthru.c [deleted file]
modified_passthru/passthru.h [deleted file]
modified_passthru/precomp.h [deleted file]
modified_passthru/protocol.c [deleted file]
original_passthru/makefile [deleted file]
original_passthru/miniport.c [deleted file]
original_passthru/netsf.inf [deleted file]
original_passthru/netsf_m.inf [deleted file]
original_passthru/passthru.c [deleted file]
original_passthru/passthru.h [deleted file]
original_passthru/passthru.htm [deleted file]
original_passthru/passthru.rc [deleted file]
original_passthru/precomp.h [deleted file]
original_passthru/protocol.c [deleted file]
original_passthru/sources [deleted file]

diff --git a/modified_passthru/miniport.c b/modified_passthru/miniport.c
deleted file mode 100644 (file)
index 3baff88..0000000
+++ /dev/null
@@ -1,1481 +0,0 @@
-/*++
-
-Copyright (c) 1992-2000  Microsoft Corporation
-
-Module Name:
-
-    miniport.c
-
-Abstract:
-
-    Ndis Intermediate Miniport driver sample. This is a passthru driver.
-
-Author:
-
-Environment:
-
-
-Revision History:
-
-
---*/
-
-#include "precomp.h"
-#pragma hdrstop
-
-
-
-NDIS_STATUS
-MPInitialize(
-    OUT PNDIS_STATUS             OpenErrorStatus,
-    OUT PUINT                    SelectedMediumIndex,
-    IN  PNDIS_MEDIUM             MediumArray,
-    IN  UINT                     MediumArraySize,
-    IN  NDIS_HANDLE              MiniportAdapterHandle,
-    IN  NDIS_HANDLE              WrapperConfigurationContext
-    )
-/*++
-
-Routine Description:
-
-    This is the initialize handler which gets called as a result of
-    the BindAdapter handler calling NdisIMInitializeDeviceInstanceEx.
-    The context parameter which we pass there is the adapter structure
-    which we retrieve here.
-
-    Arguments:
-
-    OpenErrorStatus            Not used by us.
-    SelectedMediumIndex        Place-holder for what media we are using
-    MediumArray                Array of ndis media passed down to us to pick from
-    MediumArraySize            Size of the array
-    MiniportAdapterHandle    The handle NDIS uses to refer to us
-    WrapperConfigurationContext    For use by NdisOpenConfiguration
-
-Return Value:
-
-    NDIS_STATUS_SUCCESS unless something goes wrong
-
---*/
-{
-    UINT            i;
-    PADAPT          pAdapt;
-    NDIS_STATUS     Status = NDIS_STATUS_FAILURE;
-    NDIS_MEDIUM     Medium;
-
-    UNREFERENCED_PARAMETER(WrapperConfigurationContext);
-    
-    do
-    {
-        //
-        // Start off by retrieving our adapter context and storing
-        // the Miniport handle in it.
-        //
-        pAdapt = NdisIMGetDeviceContext(MiniportAdapterHandle);
-        pAdapt->MiniportIsHalted = FALSE;
-
-        DBGPRINT(("==> Miniport Initialize: Adapt %p\n", pAdapt));
-
-        //
-        // Usually we export the medium type of the adapter below as our
-        // virtual miniport's medium type. However if the adapter below us
-        // is a WAN device, then we claim to be of medium type 802.3.
-        //
-        Medium = pAdapt->Medium;
-
-        if (Medium == NdisMediumWan)
-        {
-            Medium = NdisMedium802_3;
-        }
-
-        for (i = 0; i < MediumArraySize; i++)
-        {
-            if (MediumArray[i] == Medium)
-            {
-                *SelectedMediumIndex = i;
-                break;
-            }
-        }
-
-        if (i == MediumArraySize)
-        {
-            Status = NDIS_STATUS_UNSUPPORTED_MEDIA;
-            break;
-        }
-
-
-        //
-        // Set the attributes now. NDIS_ATTRIBUTE_DESERIALIZE enables us
-        // to make up-calls to NDIS without having to call NdisIMSwitchToMiniport
-        // or NdisIMQueueCallBack. This also forces us to protect our data using
-        // spinlocks where appropriate. Also in this case NDIS does not queue
-        // packets on our behalf. Since this is a very simple pass-thru
-        // miniport, we do not have a need to protect anything. However in
-        // a general case there will be a need to use per-adapter spin-locks
-        // for the packet queues at the very least.
-        //
-        NdisMSetAttributesEx(MiniportAdapterHandle,
-                             pAdapt,
-                             0,                                        // CheckForHangTimeInSeconds
-                             NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT    |
-                                NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT|
-                                NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER |
-                                NDIS_ATTRIBUTE_DESERIALIZE |
-                                NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND,
-                             0);
-
-        pAdapt->MiniportHandle = MiniportAdapterHandle;
-        //
-        // Initialize LastIndicatedStatus to be NDIS_STATUS_MEDIA_CONNECT
-        //
-        pAdapt->LastIndicatedStatus = NDIS_STATUS_MEDIA_CONNECT;
-        
-        //
-        // Initialize the power states for both the lower binding (PTDeviceState)
-        // and our miniport edge to Powered On.
-        //
-        pAdapt->MPDeviceState = NdisDeviceStateD0;
-        pAdapt->PTDeviceState = NdisDeviceStateD0;
-
-        //
-        // Add this adapter to the global pAdapt List
-        //
-        NdisAcquireSpinLock(&GlobalLock);
-
-        pAdapt->Next = pAdaptList;
-        pAdaptList = pAdapt;
-
-        NdisReleaseSpinLock(&GlobalLock);
-        
-        //
-        // Create an ioctl interface
-        //
-        (VOID)PtRegisterDevice();
-
-        Status = NDIS_STATUS_SUCCESS;
-    }
-    while (FALSE);
-
-    //
-    // If we had received an UnbindAdapter notification on the underlying
-    // adapter, we would have blocked that thread waiting for the IM Init
-    // process to complete. Wake up any such thread.
-    //
-    ASSERT(pAdapt->MiniportInitPending == TRUE);
-    pAdapt->MiniportInitPending = FALSE;
-    NdisSetEvent(&pAdapt->MiniportInitEvent);
-
-    if (Status == NDIS_STATUS_SUCCESS)
-    {
-        PtReferenceAdapt(pAdapt);
-    }
-
-    DBGPRINT(("<== Miniport Initialize: Adapt %p, Status %x\n", pAdapt, Status));
-
-    *OpenErrorStatus = Status;
-
-    
-    return Status;
-}
-
-
-NDIS_STATUS
-MPSend(
-    IN NDIS_HANDLE             MiniportAdapterContext,
-    IN PNDIS_PACKET            Packet,
-    IN UINT                    Flags
-    )
-/*++
-
-Routine Description:
-
-    Send Packet handler. Either this or our SendPackets (array) handler is called
-    based on which one is enabled in our Miniport Characteristics.
-
-Arguments:
-
-    MiniportAdapterContext    Pointer to the adapter
-    Packet                    Packet to send
-    Flags                     Unused, passed down below
-
-Return Value:
-
-    Return code from NdisSend
-
---*/
-{
-    PADAPT              pAdapt = (PADAPT)MiniportAdapterContext;
-    NDIS_STATUS         Status;
-    PNDIS_PACKET        MyPacket;
-    PVOID               MediaSpecificInfo = NULL;
-    ULONG               MediaSpecificInfoSize = 0;
-
-    //
-    // The driver should fail the send if the virtual miniport is in low 
-    // power state
-    //
-    if (pAdapt->MPDeviceState > NdisDeviceStateD0)
-    {
-         return NDIS_STATUS_FAILURE;
-    }
-
-#ifdef NDIS51
-    //
-    // Use NDIS 5.1 packet stacking:
-    //
-    if (0)     // XXX IPFW - make sure we don't go in here
-    {
-        PNDIS_PACKET_STACK        pStack;
-        BOOLEAN                   Remaining;
-
-        //
-        // Packet stacks: Check if we can use the same packet for sending down.
-        //
-
-        pStack = NdisIMGetCurrentPacketStack(Packet, &Remaining);
-        if (Remaining)
-        {
-            //
-            // We can reuse "Packet".
-            //
-            // NOTE: if we needed to keep per-packet information in packets
-            // sent down, we can use pStack->IMReserved[].
-            //
-            ASSERT(pStack);
-            //
-            // If the below miniport is going to low power state, stop sending down any packet.
-            //
-            NdisAcquireSpinLock(&pAdapt->Lock);
-            if (pAdapt->PTDeviceState > NdisDeviceStateD0)
-            {
-                NdisReleaseSpinLock(&pAdapt->Lock);
-                return NDIS_STATUS_FAILURE;
-            }
-            pAdapt->OutstandingSends++;
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            NdisSend(&Status,
-                     pAdapt->BindingHandle,
-                     Packet);
-
-            if (Status != NDIS_STATUS_PENDING)
-            {
-                ADAPT_DECR_PENDING_SENDS(pAdapt);
-            }
-
-            return(Status);
-        }
-    }
-#endif // NDIS51
-
-    //
-    // We are either not using packet stacks, or there isn't stack space
-    // in the original packet passed down to us. Allocate a new packet
-    // to wrap the data with.
-    //
-    //
-    // If the below miniport is going to low power state, stop sending down any packet.
-    //
-    NdisAcquireSpinLock(&pAdapt->Lock);
-    if (pAdapt->PTDeviceState > NdisDeviceStateD0)
-    {
-        NdisReleaseSpinLock(&pAdapt->Lock);
-        return NDIS_STATUS_FAILURE;
-    
-    }
-    pAdapt->OutstandingSends++;
-    NdisReleaseSpinLock(&pAdapt->Lock);
-    
-    NdisAllocatePacket(&Status,
-                       &MyPacket,
-                       pAdapt->SendPacketPoolHandle);
-
-    if (Status == NDIS_STATUS_SUCCESS)
-    {
-        PSEND_RSVD            SendRsvd;
-
-        //
-        // Save a pointer to the original packet in our reserved
-        // area in the new packet. This is needed so that we can
-        // get back to the original packet when the new packet's send
-        // is completed.
-        //
-        SendRsvd = (PSEND_RSVD)(MyPacket->ProtocolReserved);
-        SendRsvd->OriginalPkt = Packet;
-
-        NdisGetPacketFlags(MyPacket) = Flags;
-
-        //
-        // Set up the new packet so that it describes the same
-        // data as the original packet.
-        //
-        NDIS_PACKET_FIRST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_FIRST_NDIS_BUFFER(Packet);
-        NDIS_PACKET_LAST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_LAST_NDIS_BUFFER(Packet);
-#ifdef WIN9X
-        //
-        // Work around the fact that NDIS does not initialize this
-        // to FALSE on Win9x.
-        //
-        NDIS_PACKET_VALID_COUNTS(MyPacket) = FALSE;
-#endif
-
-        //
-        // Copy the OOB Offset from the original packet to the new
-        // packet.
-        //
-        NdisMoveMemory(NDIS_OOB_DATA_FROM_PACKET(MyPacket),
-                       NDIS_OOB_DATA_FROM_PACKET(Packet),
-                       sizeof(NDIS_PACKET_OOB_DATA));
-
-#ifndef WIN9X
-        //
-        // Copy the right parts of per packet info into the new packet.
-        // This API is not available on Win9x since task offload is
-        // not supported on that platform.
-        //
-        NdisIMCopySendPerPacketInfo(MyPacket, Packet);
-#endif
-        
-        //
-        // Copy the Media specific information
-        //
-        NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(Packet,
-                                            &MediaSpecificInfo,
-                                            &MediaSpecificInfoSize);
-
-        if (MediaSpecificInfo || MediaSpecificInfoSize)
-        {
-            NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket,
-                                                MediaSpecificInfo,
-                                                MediaSpecificInfoSize);
-               }
-#if 1  /* IPFW: query the firewall */
-       /* if dummynet keeps the packet, we mimic success.
-        * otherwise continue as usual.
-        */
-               {
-                       int ret = ipfw2_qhandler_w32(MyPacket, OUTGOING,
-                                       MiniportAdapterContext);
-                       if (ret != PASS) {
-                               if (ret == DROP)
-                                       return NDIS_STATUS_FAILURE;
-                               else {  //dummynet kept the packet
-#ifndef WIN9X
-                                       NdisIMCopySendCompletePerPacketInfo (Packet, MyPacket);
-#endif
-                                       return NDIS_STATUS_SUCCESS; //otherwise simply continue
-                               }
-                       }
-               }
-#endif /* end of IPFW code */
-
-        NdisSend(&Status,
-                 pAdapt->BindingHandle,
-                 MyPacket);
-
-
-        if (Status != NDIS_STATUS_PENDING)
-        {
-#ifndef WIN9X
-            NdisIMCopySendCompletePerPacketInfo (Packet, MyPacket);
-#endif
-            NdisFreePacket(MyPacket);
-            ADAPT_DECR_PENDING_SENDS(pAdapt);
-        }
-    }
-    else
-    {
-        ADAPT_DECR_PENDING_SENDS(pAdapt);
-        //
-        // We are out of packets. Silently drop it. Alternatively we can deal with it:
-        //    - By keeping separate send and receive pools
-        //    - Dynamically allocate more pools as needed and free them when not needed
-        //
-    }
-
-    return(Status);
-}
-
-
-VOID
-MPSendPackets(
-    IN NDIS_HANDLE             MiniportAdapterContext,
-    IN PPNDIS_PACKET           PacketArray,
-    IN UINT                    NumberOfPackets
-    )
-/*++
-
-Routine Description:
-
-    Send Packet Array handler. Either this or our SendPacket handler is called
-    based on which one is enabled in our Miniport Characteristics.
-
-Arguments:
-
-    MiniportAdapterContext     Pointer to our adapter
-    PacketArray                Set of packets to send
-    NumberOfPackets            Self-explanatory
-
-Return Value:
-
-    None
-
---*/
-{
-    PADAPT              pAdapt = (PADAPT)MiniportAdapterContext;
-    NDIS_STATUS         Status;
-    UINT                i;
-    PVOID               MediaSpecificInfo = NULL;
-    UINT                MediaSpecificInfoSize = 0;
-    
-
-    for (i = 0; i < NumberOfPackets; i++)
-    {
-        PNDIS_PACKET    Packet, MyPacket;
-
-        Packet = PacketArray[i];
-        //
-        // The driver should fail the send if the virtual miniport is in low 
-        // power state
-        //
-        if (pAdapt->MPDeviceState > NdisDeviceStateD0)
-        {
-            NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),
-                            Packet,
-                            NDIS_STATUS_FAILURE);
-            continue;
-        }
-
-#ifdef NDIS51
-
-        //
-        // Use NDIS 5.1 packet stacking:
-        //
-        {
-            PNDIS_PACKET_STACK        pStack;
-            BOOLEAN                   Remaining;
-
-            //
-            // Packet stacks: Check if we can use the same packet for sending down.
-            //
-            pStack = NdisIMGetCurrentPacketStack(Packet, &Remaining);
-            if (Remaining)
-            {
-                //
-                // We can reuse "Packet".
-                //
-                // NOTE: if we needed to keep per-packet information in packets
-                // sent down, we can use pStack->IMReserved[].
-                //
-                ASSERT(pStack);
-                //
-                // If the below miniport is going to low power state, stop sending down any packet.
-                //
-                NdisAcquireSpinLock(&pAdapt->Lock);
-                if (pAdapt->PTDeviceState > NdisDeviceStateD0)
-                {
-                    NdisReleaseSpinLock(&pAdapt->Lock);
-                    NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),
-                                        Packet,
-                                        NDIS_STATUS_FAILURE);
-                }
-                else
-                {
-                    pAdapt->OutstandingSends++;
-                    NdisReleaseSpinLock(&pAdapt->Lock);
-                
-                    NdisSend(&Status,
-                              pAdapt->BindingHandle,
-                              Packet);
-        
-                    if (Status != NDIS_STATUS_PENDING)
-                    {
-                        NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),
-                                            Packet,
-                                            Status);
-                   
-                        ADAPT_DECR_PENDING_SENDS(pAdapt);
-                    }
-                }
-                continue;
-            }
-        }
-#endif
-        do 
-        {
-            NdisAcquireSpinLock(&pAdapt->Lock);
-            //
-            // If the below miniport is going to low power state, stop sending down any packet.
-            //
-            if (pAdapt->PTDeviceState > NdisDeviceStateD0)
-            {
-                NdisReleaseSpinLock(&pAdapt->Lock);
-                Status = NDIS_STATUS_FAILURE;
-                break;
-            }
-            pAdapt->OutstandingSends++;
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            
-            NdisAllocatePacket(&Status,
-                               &MyPacket,
-                               pAdapt->SendPacketPoolHandle);
-
-            if (Status == NDIS_STATUS_SUCCESS)
-            {
-                PSEND_RSVD        SendRsvd;
-
-                SendRsvd = (PSEND_RSVD)(MyPacket->ProtocolReserved);
-                SendRsvd->OriginalPkt = Packet;
-
-                NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);
-
-                NDIS_PACKET_FIRST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_FIRST_NDIS_BUFFER(Packet);
-                NDIS_PACKET_LAST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_LAST_NDIS_BUFFER(Packet);
-#ifdef WIN9X
-                //
-                // Work around the fact that NDIS does not initialize this
-                // to FALSE on Win9x.
-                //
-                NDIS_PACKET_VALID_COUNTS(MyPacket) = FALSE;
-#endif // WIN9X
-
-                //
-                // Copy the OOB data from the original packet to the new
-                // packet.
-                //
-                NdisMoveMemory(NDIS_OOB_DATA_FROM_PACKET(MyPacket),
-                            NDIS_OOB_DATA_FROM_PACKET(Packet),
-                            sizeof(NDIS_PACKET_OOB_DATA));
-                //
-                // Copy relevant parts of the per packet info into the new packet
-                //
-#ifndef WIN9X
-                NdisIMCopySendPerPacketInfo(MyPacket, Packet);
-#endif
-
-                //
-                // Copy the Media specific information
-                //
-                NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(Packet,
-                                                    &MediaSpecificInfo,
-                                                    &MediaSpecificInfoSize);
-
-                if (MediaSpecificInfo || MediaSpecificInfoSize)
-                {
-                    NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket,
-                                                        MediaSpecificInfo,
-                                                        MediaSpecificInfoSize);
-                }
-
-                NdisSend(&Status,
-                         pAdapt->BindingHandle,
-                         MyPacket);
-
-                if (Status != NDIS_STATUS_PENDING)
-                {
-#ifndef WIN9X
-                    NdisIMCopySendCompletePerPacketInfo (Packet, MyPacket);
-#endif
-                    NdisFreePacket(MyPacket);
-                    ADAPT_DECR_PENDING_SENDS(pAdapt);
-                }
-            }
-            else
-            {
-                //
-                // The driver cannot allocate a packet.
-                // 
-                ADAPT_DECR_PENDING_SENDS(pAdapt);
-            }
-        }
-        while (FALSE);
-
-        if (Status != NDIS_STATUS_PENDING)
-        {
-            NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),
-                              Packet,
-                              Status);
-        }
-    }
-}
-
-
-NDIS_STATUS
-MPQueryInformation(
-    IN NDIS_HANDLE                MiniportAdapterContext,
-    IN NDIS_OID                   Oid,
-    IN PVOID                      InformationBuffer,
-    IN ULONG                      InformationBufferLength,
-    OUT PULONG                    BytesWritten,
-    OUT PULONG                    BytesNeeded
-    )
-/*++
-
-Routine Description:
-
-    Entry point called by NDIS to query for the value of the specified OID.
-    Typical processing is to forward the query down to the underlying miniport.
-
-    The following OIDs are filtered here:
-
-    OID_PNP_QUERY_POWER - return success right here
-
-    OID_GEN_SUPPORTED_GUIDS - do not forward, otherwise we will show up
-    multiple instances of private GUIDs supported by the underlying miniport.
-
-    OID_PNP_CAPABILITIES - we do send this down to the lower miniport, but
-    the values returned are postprocessed before we complete this request;
-    see PtRequestComplete.
-
-    NOTE on OID_TCP_TASK_OFFLOAD - if this IM driver modifies the contents
-    of data it passes through such that a lower miniport may not be able
-    to perform TCP task offload, then it should not forward this OID down,
-    but fail it here with the status NDIS_STATUS_NOT_SUPPORTED. This is to
-    avoid performing incorrect transformations on data.
-
-    If our miniport edge (upper edge) is at a low-power state, fail the request.
-
-    If our protocol edge (lower edge) has been notified of a low-power state,
-    we pend this request until the miniport below has been set to D0. Since
-    requests to miniports are serialized always, at most a single request will
-    be pended.
-
-Arguments:
-
-    MiniportAdapterContext    Pointer to the adapter structure
-    Oid                       Oid for this query
-    InformationBuffer         Buffer for information
-    InformationBufferLength   Size of this buffer
-    BytesWritten              Specifies how much info is written
-    BytesNeeded               In case the buffer is smaller than what we need, tell them how much is needed
-
-
-Return Value:
-
-    Return code from the NdisRequest below.
-
---*/
-{
-    PADAPT        pAdapt = (PADAPT)MiniportAdapterContext;
-    NDIS_STATUS   Status = NDIS_STATUS_FAILURE;
-
-    do
-    {
-        if (Oid == OID_PNP_QUERY_POWER)
-        {
-            //
-            //  Do not forward this.
-            //
-            Status = NDIS_STATUS_SUCCESS;
-            break;
-        }
-
-        if (Oid == OID_GEN_SUPPORTED_GUIDS)
-        {
-            //
-            //  Do not forward this, otherwise we will end up with multiple
-            //  instances of private GUIDs that the underlying miniport
-            //  supports.
-            //
-            Status = NDIS_STATUS_NOT_SUPPORTED;
-            break;
-        }
-
-        if (Oid == OID_TCP_TASK_OFFLOAD)
-        {
-            //
-            // Fail this -if- this driver performs data transformations
-            // that can interfere with a lower driver's ability to offload
-            // TCP tasks.
-            //
-            // Status = NDIS_STATUS_NOT_SUPPORTED;
-            // break;
-            //
-        }
-        //
-        // If the miniport below is unbinding, just fail any request
-        //
-        NdisAcquireSpinLock(&pAdapt->Lock);
-        if (pAdapt->UnbindingInProcess == TRUE)
-        {
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            Status = NDIS_STATUS_FAILURE;
-            break;
-        }
-        NdisReleaseSpinLock(&pAdapt->Lock);
-        //
-        // All other queries are failed, if the miniport is not at D0,
-        //
-        if (pAdapt->MPDeviceState > NdisDeviceStateD0) 
-        {
-            Status = NDIS_STATUS_FAILURE;
-            break;
-        }
-
-        pAdapt->Request.RequestType = NdisRequestQueryInformation;
-        pAdapt->Request.DATA.QUERY_INFORMATION.Oid = Oid;
-        pAdapt->Request.DATA.QUERY_INFORMATION.InformationBuffer = InformationBuffer;
-        pAdapt->Request.DATA.QUERY_INFORMATION.InformationBufferLength = InformationBufferLength;
-        pAdapt->BytesNeeded = BytesNeeded;
-        pAdapt->BytesReadOrWritten = BytesWritten;
-
-        //
-        // If the miniport below is binding, fail the request
-        //
-        NdisAcquireSpinLock(&pAdapt->Lock);
-            
-        if (pAdapt->UnbindingInProcess == TRUE)
-        {
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            Status = NDIS_STATUS_FAILURE;
-            break;
-        }
-        //
-        // If the Protocol device state is OFF, mark this request as being 
-        // pended. We queue this until the device state is back to D0. 
-        //
-        if ((pAdapt->PTDeviceState > NdisDeviceStateD0) 
-                && (pAdapt->StandingBy == FALSE))
-        {
-            pAdapt->QueuedRequest = TRUE;
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            Status = NDIS_STATUS_PENDING;
-            break;
-        }
-        //
-        // This is in the process of powering down the system, always fail the request
-        // 
-        if (pAdapt->StandingBy == TRUE)
-        {
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            Status = NDIS_STATUS_FAILURE;
-            break;
-        }
-        pAdapt->OutstandingRequests = TRUE;
-        
-        NdisReleaseSpinLock(&pAdapt->Lock);
-
-        //
-        // default case, most requests will be passed to the miniport below
-        //
-        NdisRequest(&Status,
-                    pAdapt->BindingHandle,
-                    &pAdapt->Request);
-
-
-        if (Status != NDIS_STATUS_PENDING)
-        {
-            PtRequestComplete(pAdapt, &pAdapt->Request, Status);
-            Status = NDIS_STATUS_PENDING;
-        }
-
-    } while (FALSE);
-
-    return(Status);
-
-}
-
-
-VOID
-MPQueryPNPCapabilities(
-    IN OUT PADAPT            pAdapt,
-    OUT PNDIS_STATUS         pStatus
-    )
-/*++
-
-Routine Description:
-
-    Postprocess a request for OID_PNP_CAPABILITIES that was forwarded
-    down to the underlying miniport, and has been completed by it.
-
-Arguments:
-
-    pAdapt - Pointer to the adapter structure
-    pStatus - Place to return final status
-
-Return Value:
-
-    None.
-
---*/
-
-{
-    PNDIS_PNP_CAPABILITIES           pPNPCapabilities;
-    PNDIS_PM_WAKE_UP_CAPABILITIES    pPMstruct;
-
-    if (pAdapt->Request.DATA.QUERY_INFORMATION.InformationBufferLength >= sizeof(NDIS_PNP_CAPABILITIES))
-    {
-        pPNPCapabilities = (PNDIS_PNP_CAPABILITIES)(pAdapt->Request.DATA.QUERY_INFORMATION.InformationBuffer);
-
-        //
-        // The following fields must be overwritten by an IM driver.
-        //
-        pPMstruct= & pPNPCapabilities->WakeUpCapabilities;
-        pPMstruct->MinMagicPacketWakeUp = NdisDeviceStateUnspecified;
-        pPMstruct->MinPatternWakeUp = NdisDeviceStateUnspecified;
-        pPMstruct->MinLinkChangeWakeUp = NdisDeviceStateUnspecified;
-        *pAdapt->BytesReadOrWritten = sizeof(NDIS_PNP_CAPABILITIES);
-        *pAdapt->BytesNeeded = 0;
-
-
-        //
-        // Setting our internal flags
-        // Default, device is ON
-        //
-        pAdapt->MPDeviceState = NdisDeviceStateD0;
-        pAdapt->PTDeviceState = NdisDeviceStateD0;
-
-        *pStatus = NDIS_STATUS_SUCCESS;
-    }
-    else
-    {
-        *pAdapt->BytesNeeded= sizeof(NDIS_PNP_CAPABILITIES);
-        *pStatus = NDIS_STATUS_RESOURCES;
-    }
-}
-
-
-NDIS_STATUS
-MPSetInformation(
-    IN NDIS_HANDLE                                  MiniportAdapterContext,
-    IN NDIS_OID                                     Oid,
-    __in_bcount(InformationBufferLength) IN PVOID   InformationBuffer,
-    IN ULONG                                        InformationBufferLength,
-    OUT PULONG                                      BytesRead,
-    OUT PULONG                                      BytesNeeded
-    )
-/*++
-
-Routine Description:
-
-    Miniport SetInfo handler.
-
-    In the case of OID_PNP_SET_POWER, record the power state and return the OID.    
-    Do not pass below
-    If the device is suspended, do not block the SET_POWER_OID 
-    as it is used to reactivate the Passthru miniport
-
-    
-    PM- If the MP is not ON (DeviceState > D0) return immediately  (except for 'query power' and 'set power')
-         If MP is ON, but the PT is not at D0, then queue the queue the request for later processing
-
-    Requests to miniports are always serialized
-
-
-Arguments:
-
-    MiniportAdapterContext    Pointer to the adapter structure
-    Oid                       Oid for this query
-    InformationBuffer         Buffer for information
-    InformationBufferLength   Size of this buffer
-    BytesRead                 Specifies how much info is read
-    BytesNeeded               In case the buffer is smaller than what we need, tell them how much is needed
-
-Return Value:
-
-    Return code from the NdisRequest below.
-
---*/
-{
-    PADAPT        pAdapt = (PADAPT)MiniportAdapterContext;
-    NDIS_STATUS   Status;
-
-    Status = NDIS_STATUS_FAILURE;
-
-    do
-    {
-        //
-        // The Set Power should not be sent to the miniport below the Passthru, but is handled internally
-        //
-        if (Oid == OID_PNP_SET_POWER)
-        {
-            MPProcessSetPowerOid(&Status, 
-                                 pAdapt, 
-                                 InformationBuffer, 
-                                 InformationBufferLength, 
-                                 BytesRead, 
-                                 BytesNeeded);
-            break;
-
-        }
-
-        //
-        // If the miniport below is unbinding, fail the request
-        //
-        NdisAcquireSpinLock(&pAdapt->Lock);     
-        if (pAdapt->UnbindingInProcess == TRUE)
-        {
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            Status = NDIS_STATUS_FAILURE;
-            break;
-        }
-        NdisReleaseSpinLock(&pAdapt->Lock);
-        //
-        // All other Set Information requests are failed, if the miniport is
-        // not at D0 or is transitioning to a device state greater than D0.
-        //
-        if (pAdapt->MPDeviceState > NdisDeviceStateD0)
-        {
-            Status = NDIS_STATUS_FAILURE;
-            break;
-        }
-
-        // Set up the Request and return the result
-        pAdapt->Request.RequestType = NdisRequestSetInformation;
-        pAdapt->Request.DATA.SET_INFORMATION.Oid = Oid;
-        pAdapt->Request.DATA.SET_INFORMATION.InformationBuffer = InformationBuffer;
-        pAdapt->Request.DATA.SET_INFORMATION.InformationBufferLength = InformationBufferLength;
-        pAdapt->BytesNeeded = BytesNeeded;
-        pAdapt->BytesReadOrWritten = BytesRead;
-
-        //
-        // If the miniport below is unbinding, fail the request
-        //
-        NdisAcquireSpinLock(&pAdapt->Lock);     
-        if (pAdapt->UnbindingInProcess == TRUE)
-        {
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            Status = NDIS_STATUS_FAILURE;
-            break;
-        }
-            
-        //
-        // If the device below is at a low power state, we cannot send it the
-        // request now, and must pend it.
-        //
-        if ((pAdapt->PTDeviceState > NdisDeviceStateD0) 
-                && (pAdapt->StandingBy == FALSE))
-        {
-            pAdapt->QueuedRequest = TRUE;
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            Status = NDIS_STATUS_PENDING;
-            break;
-        }
-        //
-        // This is in the process of powering down the system, always fail the request
-        // 
-        if (pAdapt->StandingBy == TRUE)
-        {
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            Status = NDIS_STATUS_FAILURE;
-            break;
-        }
-        pAdapt->OutstandingRequests = TRUE;
-        
-        NdisReleaseSpinLock(&pAdapt->Lock);
-        //
-        // Forward the request to the device below.
-        //
-        NdisRequest(&Status,
-                    pAdapt->BindingHandle,
-                    &pAdapt->Request);
-
-        if (Status != NDIS_STATUS_PENDING)
-        {
-            *BytesRead = pAdapt->Request.DATA.SET_INFORMATION.BytesRead;
-            *BytesNeeded = pAdapt->Request.DATA.SET_INFORMATION.BytesNeeded;
-            pAdapt->OutstandingRequests = FALSE;
-        }
-
-    } while (FALSE);
-
-    return(Status);
-}
-
-
-VOID
-MPProcessSetPowerOid(
-    IN OUT PNDIS_STATUS                             pNdisStatus,
-    IN PADAPT                                       pAdapt,
-    __in_bcount(InformationBufferLength) IN PVOID   InformationBuffer,
-    IN ULONG                                        InformationBufferLength,
-    OUT PULONG                                      BytesRead,
-    OUT PULONG                                      BytesNeeded
-    )
-/*++
-
-Routine Description:
-    This routine does all the procssing for a request with a SetPower Oid
-    The miniport shoud accept  the Set Power and transition to the new state
-
-    The Set Power should not be passed to the miniport below
-
-    If the IM miniport is going into a low power state, then there is no guarantee if it will ever
-    be asked go back to D0, before getting halted. No requests should be pended or queued.
-
-    
-Arguments:
-    pNdisStatus           - Status of the operation
-    pAdapt                - The Adapter structure
-    InformationBuffer     - The New DeviceState
-    InformationBufferLength
-    BytesRead             - No of bytes read
-    BytesNeeded           -  No of bytes needed
-
-
-Return Value:
-    Status  - NDIS_STATUS_SUCCESS if all the wait events succeed.
-
---*/
-{
-
-    
-    NDIS_DEVICE_POWER_STATE NewDeviceState;
-
-    DBGPRINT(("==>MPProcessSetPowerOid: Adapt %p\n", pAdapt)); 
-
-    ASSERT (InformationBuffer != NULL);
-
-    *pNdisStatus = NDIS_STATUS_FAILURE;
-
-    do 
-    {
-        //
-        // Check for invalid length
-        //
-        if (InformationBufferLength < sizeof(NDIS_DEVICE_POWER_STATE))
-        {
-            *pNdisStatus = NDIS_STATUS_INVALID_LENGTH;
-            break;
-        }
-
-        NewDeviceState = (*(PNDIS_DEVICE_POWER_STATE)InformationBuffer);
-
-        //
-        // Check for invalid device state
-        //
-        if ((pAdapt->MPDeviceState > NdisDeviceStateD0) && (NewDeviceState != NdisDeviceStateD0))
-        {
-            //
-            // If the miniport is in a non-D0 state, the miniport can only receive a Set Power to D0
-            //
-            ASSERT (!(pAdapt->MPDeviceState > NdisDeviceStateD0) && (NewDeviceState != NdisDeviceStateD0));
-
-            *pNdisStatus = NDIS_STATUS_FAILURE;
-            break;
-        }    
-
-        //
-        // Is the miniport transitioning from an On (D0) state to an Low Power State (>D0)
-        // If so, then set the StandingBy Flag - (Block all incoming requests)
-        //
-        if (pAdapt->MPDeviceState == NdisDeviceStateD0 && NewDeviceState > NdisDeviceStateD0)
-        {
-            pAdapt->StandingBy = TRUE;
-        }
-
-        //
-        // If the miniport is transitioning from a low power state to ON (D0), then clear the StandingBy flag
-        // All incoming requests will be pended until the physical miniport turns ON.
-        //
-        if (pAdapt->MPDeviceState > NdisDeviceStateD0 &&  NewDeviceState == NdisDeviceStateD0)
-        {
-            pAdapt->StandingBy = FALSE;
-        }
-        
-        //
-        // Now update the state in the pAdapt structure;
-        //
-        pAdapt->MPDeviceState = NewDeviceState;
-        
-        *pNdisStatus = NDIS_STATUS_SUCCESS;
-    
-
-    } while (FALSE);    
-        
-    if (*pNdisStatus == NDIS_STATUS_SUCCESS)
-    {
-        //
-        // The miniport resume from low power state
-        // 
-        if (pAdapt->StandingBy == FALSE)
-        {
-            //
-            // If we need to indicate the media connect state
-            // 
-            if (pAdapt->LastIndicatedStatus != pAdapt->LatestUnIndicateStatus)
-            {
-               if (pAdapt->MiniportHandle != NULL)
-               {
-                   NdisMIndicateStatus(pAdapt->MiniportHandle,
-                                            pAdapt->LatestUnIndicateStatus,
-                                            (PVOID)NULL,
-                                            0);
-                   NdisMIndicateStatusComplete(pAdapt->MiniportHandle);
-                   pAdapt->LastIndicatedStatus = pAdapt->LatestUnIndicateStatus;
-               }
-            }
-        }
-        else
-        {
-            //
-            // Initialize LatestUnIndicatedStatus
-            //
-            pAdapt->LatestUnIndicateStatus = pAdapt->LastIndicatedStatus;
-        }
-        *BytesRead = sizeof(NDIS_DEVICE_POWER_STATE);
-        *BytesNeeded = 0;
-    }
-    else
-    {
-        *BytesRead = 0;
-        *BytesNeeded = sizeof (NDIS_DEVICE_POWER_STATE);
-    }
-
-    DBGPRINT(("<==MPProcessSetPowerOid: Adapt %p\n", pAdapt)); 
-}
-
-
-VOID
-MPReturnPacket(
-    IN NDIS_HANDLE             MiniportAdapterContext,
-    IN PNDIS_PACKET            Packet
-    )
-/*++
-
-Routine Description:
-
-    NDIS Miniport entry point called whenever protocols are done with
-    a packet that we had indicated up and they had queued up for returning
-    later.
-
-Arguments:
-
-    MiniportAdapterContext    - pointer to ADAPT structure
-    Packet    - packet being returned.
-
-Return Value:
-
-    None.
-
---*/
-{
-    PADAPT            pAdapt = (PADAPT)MiniportAdapterContext;
-
-#ifdef NDIS51
-    //
-    // Packet stacking: Check if this packet belongs to us.
-    //
-    if (NdisGetPoolFromPacket(Packet) != pAdapt->RecvPacketPoolHandle)
-    {
-        //
-        // We reused the original packet in a receive indication.
-        // Simply return it to the miniport below us.
-        //
-        NdisReturnPackets(&Packet, 1);
-    }
-    else
-#endif // NDIS51
-    {
-        //
-        // This is a packet allocated from this IM's receive packet pool.
-        // Reclaim our packet, and return the original to the driver below.
-        //
-
-        PNDIS_PACKET    MyPacket;
-        PRECV_RSVD      RecvRsvd;
-    
-        RecvRsvd = (PRECV_RSVD)(Packet->MiniportReserved);
-        MyPacket = RecvRsvd->OriginalPkt;
-    
-        NdisFreePacket(Packet);
-        NdisReturnPackets(&MyPacket, 1);
-    }
-}
-
-
-NDIS_STATUS
-MPTransferData(
-    OUT PNDIS_PACKET            Packet,
-    OUT PUINT                   BytesTransferred,
-    IN NDIS_HANDLE              MiniportAdapterContext,
-    IN NDIS_HANDLE              MiniportReceiveContext,
-    IN UINT                     ByteOffset,
-    IN UINT                     BytesToTransfer
-    )
-/*++
-
-Routine Description:
-
-    Miniport's transfer data handler.
-
-Arguments:
-
-    Packet                    Destination packet
-    BytesTransferred          Place-holder for how much data was copied
-    MiniportAdapterContext    Pointer to the adapter structure
-    MiniportReceiveContext    Context
-    ByteOffset                Offset into the packet for copying data
-    BytesToTransfer           How much to copy.
-
-Return Value:
-
-    Status of transfer
-
---*/
-{
-    PADAPT        pAdapt = (PADAPT)MiniportAdapterContext;
-    NDIS_STATUS   Status;
-
-    //
-    // Return, if the device is OFF
-    //
-
-    if (IsIMDeviceStateOn(pAdapt) == FALSE)
-    {
-        return NDIS_STATUS_FAILURE;
-    }
-
-    NdisTransferData(&Status,
-                     pAdapt->BindingHandle,
-                     MiniportReceiveContext,
-                     ByteOffset,
-                     BytesToTransfer,
-                     Packet,
-                     BytesTransferred);
-
-    return(Status);
-}
-
-VOID
-MPHalt(
-    IN NDIS_HANDLE                MiniportAdapterContext
-    )
-/*++
-
-Routine Description:
-
-    Halt handler. All the hard-work for clean-up is done here.
-
-Arguments:
-
-    MiniportAdapterContext    Pointer to the Adapter
-
-Return Value:
-
-    None.
-
---*/
-{
-    PADAPT             pAdapt = (PADAPT)MiniportAdapterContext;
-    NDIS_STATUS        Status;
-    PADAPT            *ppCursor;
-
-    DBGPRINT(("==>MiniportHalt: Adapt %p\n", pAdapt));
-
-    pAdapt->MiniportHandle = NULL;
-    pAdapt->MiniportIsHalted = TRUE;
-
-    //
-    // Remove this adapter from the global list
-    //
-    NdisAcquireSpinLock(&GlobalLock);
-
-    for (ppCursor = &pAdaptList; *ppCursor != NULL; ppCursor = &(*ppCursor)->Next)
-    {
-        if (*ppCursor == pAdapt)
-        {
-            *ppCursor = pAdapt->Next;
-            break;
-        }
-    }
-
-    NdisReleaseSpinLock(&GlobalLock);
-
-    //
-    // Delete the ioctl interface that was created when the miniport
-    // was created.
-    //
-    (VOID)PtDeregisterDevice();
-
-    //
-    // If we have a valid bind, close the miniport below the protocol
-    //
-#pragma prefast(suppress: __WARNING_DEREF_NULL_PTR, "pAdapt cannot be NULL")
-    if (pAdapt->BindingHandle != NULL)
-    {
-        //
-        // Close the binding below. and wait for it to complete
-        //
-        NdisResetEvent(&pAdapt->Event);
-
-        NdisCloseAdapter(&Status, pAdapt->BindingHandle);
-
-        if (Status == NDIS_STATUS_PENDING)
-        {
-            NdisWaitEvent(&pAdapt->Event, 0);
-            Status = pAdapt->Status;
-        }
-
-        ASSERT (Status == NDIS_STATUS_SUCCESS);
-
-        pAdapt->BindingHandle = NULL;
-        
-        PtDereferenceAdapt(pAdapt);
-    }
-
-    if (PtDereferenceAdapt(pAdapt))
-    {
-        pAdapt = NULL;
-    }
-        
-    
-    DBGPRINT(("<== MiniportHalt: pAdapt %p\n", pAdapt));
-}
-
-
-#ifdef NDIS51_MINIPORT
-
-VOID
-MPCancelSendPackets(
-    IN NDIS_HANDLE            MiniportAdapterContext,
-    IN PVOID                  CancelId
-    )
-/*++
-
-Routine Description:
-
-    The miniport entry point to handle cancellation of all send packets
-    that match the given CancelId. If we have queued any packets that match
-    this, then we should dequeue them and call NdisMSendComplete for all
-    such packets, with a status of NDIS_STATUS_REQUEST_ABORTED.
-
-    We should also call NdisCancelSendPackets in turn, on each lower binding
-    that this adapter corresponds to. This is to let miniports below cancel
-    any matching packets.
-
-Arguments:
-
-    MiniportAdapterContext    - pointer to ADAPT structure
-    CancelId    - ID of packets to be cancelled.
-
-Return Value:
-
-    None
-
---*/
-{
-    PADAPT    pAdapt = (PADAPT)MiniportAdapterContext;
-
-    //
-    // If we queue packets on our adapter structure, this would be 
-    // the place to acquire a spinlock to it, unlink any packets whose
-    // Id matches CancelId, release the spinlock and call NdisMSendComplete
-    // with NDIS_STATUS_REQUEST_ABORTED for all unlinked packets.
-    //
-
-    //
-    // Next, pass this down so that we let the miniport(s) below cancel
-    // any packets that they might have queued.
-    //
-    NdisCancelSendPackets(pAdapt->BindingHandle, CancelId);
-
-    return;
-}
-
-VOID
-MPDevicePnPEvent(
-    IN NDIS_HANDLE              MiniportAdapterContext,
-    IN NDIS_DEVICE_PNP_EVENT    DevicePnPEvent,
-    IN PVOID                    InformationBuffer,
-    IN ULONG                    InformationBufferLength
-    )
-/*++
-
-Routine Description:
-
-    This handler is called to notify us of PnP events directed to
-    our miniport device object.
-
-Arguments:
-
-    MiniportAdapterContext    - pointer to ADAPT structure
-    DevicePnPEvent - the event
-    InformationBuffer - Points to additional event-specific information
-    InformationBufferLength - length of above
-
-Return Value:
-
-    None
---*/
-{
-    // TBD - add code/comments about processing this.
-
-    UNREFERENCED_PARAMETER(MiniportAdapterContext);
-    UNREFERENCED_PARAMETER(DevicePnPEvent);
-    UNREFERENCED_PARAMETER(InformationBuffer);
-    UNREFERENCED_PARAMETER(InformationBufferLength);
-    
-    return;
-}
-
-VOID
-MPAdapterShutdown(
-    IN NDIS_HANDLE                MiniportAdapterContext
-    )
-/*++
-
-Routine Description:
-
-    This handler is called to notify us of an impending system shutdown.
-
-Arguments:
-
-    MiniportAdapterContext    - pointer to ADAPT structure
-
-Return Value:
-
-    None
---*/
-{
-    UNREFERENCED_PARAMETER(MiniportAdapterContext);
-    
-    return;
-}
-
-#endif
-
-
-VOID
-MPFreeAllPacketPools(
-    IN PADAPT                    pAdapt
-    )
-/*++
-
-Routine Description:
-
-    Free all packet pools on the specified adapter.
-    
-Arguments:
-
-    pAdapt    - pointer to ADAPT structure
-
-Return Value:
-
-    None
-
---*/
-{
-    if (pAdapt->RecvPacketPoolHandle != NULL)
-    {
-        //
-        // Free the packet pool that is used to indicate receives
-        //
-        NdisFreePacketPool(pAdapt->RecvPacketPoolHandle);
-
-        pAdapt->RecvPacketPoolHandle = NULL;
-    }
-
-    if (pAdapt->SendPacketPoolHandle != NULL)
-    {
-
-        //
-        //  Free the packet pool that is used to send packets below
-        //
-
-        NdisFreePacketPool(pAdapt->SendPacketPoolHandle);
-
-        pAdapt->SendPacketPoolHandle = NULL;
-
-    }
-}
-
diff --git a/modified_passthru/passthru.c b/modified_passthru/passthru.c
deleted file mode 100644 (file)
index c366173..0000000
+++ /dev/null
@@ -1,469 +0,0 @@
-/*++
-
-Copyright (c) 1992-2000  Microsoft Corporation
-Module Name:
-    passthru.c
-
-Abstract:
-
-    Ndis Intermediate Miniport driver sample. This is a passthru driver.
-
-Author:
-
-Environment:
-
-
-Revision History:
-
-
---*/
-
-
-#include "precomp.h"
-#pragma hdrstop
-
-#pragma NDIS_INIT_FUNCTION(DriverEntry)
-
-NDIS_HANDLE         ProtHandle = NULL;
-NDIS_HANDLE         DriverHandle = NULL;
-NDIS_MEDIUM         MediumArray[4] =
-                    {
-                        NdisMedium802_3,    // Ethernet
-                        NdisMedium802_5,    // Token-ring
-                        NdisMediumFddi,     // Fddi
-                        NdisMediumWan       // NDISWAN
-                    };
-
-NDIS_SPIN_LOCK     GlobalLock;
-
-PADAPT             pAdaptList = NULL;
-LONG               MiniportCount = 0;
-
-NDIS_HANDLE        NdisWrapperHandle;
-
-//
-// To support ioctls from user-mode:
-//
-
-#define STR2(x) #x
-#define STR(x) STR2(x)
-#define DOSPREFIX "\\DosDevices\\"
-#define NTPREFIX "\\Device\\"
-#define WIDEN2(x) L ## x
-#define WIDEN(x) WIDEN2(x)
-#define LINKNAME_STRING                        WIDEN(DOSPREFIX) WIDEN(STR(MODULENAME))
-#define NTDEVICE_STRING                        WIDEN(NTPREFIX) WIDEN(STR(MODULENAME))
-#define PROTOCOLNAME_STRING            WIDEN(STR(MODULENAME))
-
-NDIS_HANDLE     NdisDeviceHandle = NULL;
-PDEVICE_OBJECT  ControlDeviceObject = NULL;
-
-enum _DEVICE_STATE
-{
-    PS_DEVICE_STATE_READY = 0,    // ready for create/delete
-    PS_DEVICE_STATE_CREATING,    // create operation in progress
-    PS_DEVICE_STATE_DELETING    // delete operation in progress
-} ControlDeviceState = PS_DEVICE_STATE_READY;
-
-
-
-NTSTATUS
-DriverEntry(
-    IN PDRIVER_OBJECT        DriverObject,
-    IN PUNICODE_STRING       RegistryPath
-    )
-/*++
-
-Routine Description:
-
-    First entry point to be called, when this driver is loaded.
-    Register with NDIS as an intermediate driver.
-
-Arguments:
-
-    DriverObject - pointer to the system's driver object structure
-        for this driver
-    
-    RegistryPath - system's registry path for this driver
-    
-Return Value:
-
-    STATUS_SUCCESS if all initialization is successful, STATUS_XXX
-    error code if not.
-
---*/
-{
-    NDIS_STATUS                        Status;
-    NDIS_PROTOCOL_CHARACTERISTICS      PChars;
-    NDIS_MINIPORT_CHARACTERISTICS      MChars;
-    NDIS_STRING                        Name;
-
-    Status = NDIS_STATUS_SUCCESS;
-    NdisAllocateSpinLock(&GlobalLock);
-
-    NdisMInitializeWrapper(&NdisWrapperHandle, DriverObject, RegistryPath, NULL);
-
-    do
-    {
-        //
-        // Register the miniport with NDIS. Note that it is the miniport
-        // which was started as a driver and not the protocol. Also the miniport
-        // must be registered prior to the protocol since the protocol's BindAdapter
-        // handler can be initiated anytime and when it is, it must be ready to
-        // start driver instances.
-        //
-
-        NdisZeroMemory(&MChars, sizeof(NDIS_MINIPORT_CHARACTERISTICS));
-
-        MChars.MajorNdisVersion = PASSTHRU_MAJOR_NDIS_VERSION;
-        MChars.MinorNdisVersion = PASSTHRU_MINOR_NDIS_VERSION;
-
-        MChars.InitializeHandler = MPInitialize;
-        MChars.QueryInformationHandler = MPQueryInformation;
-        MChars.SetInformationHandler = MPSetInformation;
-        MChars.ResetHandler = NULL;
-        MChars.TransferDataHandler = MPTransferData;
-        MChars.HaltHandler = MPHalt;
-#ifdef NDIS51_MINIPORT
-        MChars.CancelSendPacketsHandler = MPCancelSendPackets;
-        MChars.PnPEventNotifyHandler = MPDevicePnPEvent;
-        MChars.AdapterShutdownHandler = MPAdapterShutdown;
-#endif // NDIS51_MINIPORT
-
-        //
-        // We will disable the check for hang timeout so we do not
-        // need a check for hang handler!
-        //
-        MChars.CheckForHangHandler = NULL;
-        MChars.ReturnPacketHandler = MPReturnPacket;
-
-        //
-        // Either the Send or the SendPackets handler should be specified.
-        // If SendPackets handler is specified, SendHandler is ignored
-        //
-        MChars.SendHandler = MPSend;    // IPFW: use MPSend, not SendPackets
-        MChars.SendPacketsHandler = NULL;
-
-        Status = NdisIMRegisterLayeredMiniport(NdisWrapperHandle,
-                                                  &MChars,
-                                                  sizeof(MChars),
-                                                  &DriverHandle);
-        if (Status != NDIS_STATUS_SUCCESS)
-        {
-            break;
-        }
-
-#ifndef WIN9X
-        NdisMRegisterUnloadHandler(NdisWrapperHandle, PtUnload);
-#endif
-
-        //
-        // Now register the protocol.
-        //
-        NdisZeroMemory(&PChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
-        PChars.MajorNdisVersion = PASSTHRU_PROT_MAJOR_NDIS_VERSION;
-        PChars.MinorNdisVersion = PASSTHRU_PROT_MINOR_NDIS_VERSION;
-
-        //
-        // Make sure the protocol-name matches the service-name
-        // (from the INF) under which this protocol is installed.
-        // This is needed to ensure that NDIS can correctly determine
-        // the binding and call us to bind to miniports below.
-        //
-        NdisInitUnicodeString(&Name, PROTOCOLNAME_STRING);    // Protocol name
-        PChars.Name = Name;
-        PChars.OpenAdapterCompleteHandler = PtOpenAdapterComplete;
-        PChars.CloseAdapterCompleteHandler = PtCloseAdapterComplete;
-        PChars.SendCompleteHandler = PtSendComplete;
-        PChars.TransferDataCompleteHandler = PtTransferDataComplete;
-    
-        PChars.ResetCompleteHandler = PtResetComplete;
-        PChars.RequestCompleteHandler = PtRequestComplete;
-        PChars.ReceiveHandler = PtReceive;
-        PChars.ReceiveCompleteHandler = PtReceiveComplete;
-        PChars.StatusHandler = PtStatus;
-        PChars.StatusCompleteHandler = PtStatusComplete;
-        PChars.BindAdapterHandler = PtBindAdapter;
-        PChars.UnbindAdapterHandler = PtUnbindAdapter;
-        PChars.UnloadHandler = PtUnloadProtocol;
-
-        PChars.ReceivePacketHandler = PtReceivePacket;
-        PChars.PnPEventHandler= PtPNPHandler;
-
-        NdisRegisterProtocol(&Status,
-                             &ProtHandle,
-                             &PChars,
-                             sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
-
-        if (Status != NDIS_STATUS_SUCCESS)
-        {
-            NdisIMDeregisterLayeredMiniport(DriverHandle);
-            break;
-        }
-
-        NdisIMAssociateMiniport(DriverHandle, ProtHandle);
-    }
-    while (FALSE);
-
-    if (Status != NDIS_STATUS_SUCCESS)
-    {
-        NdisTerminateWrapper(NdisWrapperHandle, NULL);
-    }
-       
-    ipfw_module_init();        // IPFW - start the system
-
-    return(Status);
-}
-
-
-NDIS_STATUS
-PtRegisterDevice(
-    VOID
-    )
-/*++
-
-Routine Description:
-
-    Register an ioctl interface - a device object to be used for this
-    purpose is created by NDIS when we call NdisMRegisterDevice.
-
-    This routine is called whenever a new miniport instance is
-    initialized. However, we only create one global device object,
-    when the first miniport instance is initialized. This routine
-    handles potential race conditions with PtDeregisterDevice via
-    the ControlDeviceState and MiniportCount variables.
-
-    NOTE: do not call this from DriverEntry; it will prevent the driver
-    from being unloaded (e.g. on uninstall).
-
-Arguments:
-
-    None
-
-Return Value:
-
-    NDIS_STATUS_SUCCESS if we successfully register a device object.
-
---*/
-{
-    NDIS_STATUS            Status = NDIS_STATUS_SUCCESS;
-    UNICODE_STRING         DeviceName;
-    UNICODE_STRING         DeviceLinkUnicodeString;
-    PDRIVER_DISPATCH       DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1];
-
-    DBGPRINT(("==>PtRegisterDevice\n"));
-
-    NdisAcquireSpinLock(&GlobalLock);
-
-    ++MiniportCount;
-    
-    if (1 == MiniportCount)
-    {
-        ASSERT(ControlDeviceState != PS_DEVICE_STATE_CREATING);
-
-        //
-        // Another thread could be running PtDeregisterDevice on
-        // behalf of another miniport instance. If so, wait for
-        // it to exit.
-        //
-        while (ControlDeviceState != PS_DEVICE_STATE_READY)
-        {
-            NdisReleaseSpinLock(&GlobalLock);
-            NdisMSleep(1);
-            NdisAcquireSpinLock(&GlobalLock);
-        }
-
-        ControlDeviceState = PS_DEVICE_STATE_CREATING;
-
-        NdisReleaseSpinLock(&GlobalLock);
-
-    
-        NdisZeroMemory(DispatchTable, (IRP_MJ_MAXIMUM_FUNCTION+1) * sizeof(PDRIVER_DISPATCH));
-
-        DispatchTable[IRP_MJ_CREATE] = PtDispatch;
-        DispatchTable[IRP_MJ_CLEANUP] = PtDispatch;
-        DispatchTable[IRP_MJ_CLOSE] = PtDispatch;
-       // IPFW we use DevIoControl ?
-        DispatchTable[IRP_MJ_DEVICE_CONTROL] = DevIoControl;
-        
-
-        NdisInitUnicodeString(&DeviceName, NTDEVICE_STRING);
-        NdisInitUnicodeString(&DeviceLinkUnicodeString, LINKNAME_STRING);
-
-        //
-        // Create a device object and register our dispatch handlers
-        //
-        
-        Status = NdisMRegisterDevice(
-                    NdisWrapperHandle, 
-                    &DeviceName,
-                    &DeviceLinkUnicodeString,
-                    &DispatchTable[0],
-                    &ControlDeviceObject,
-                    &NdisDeviceHandle
-                    );
-
-        NdisAcquireSpinLock(&GlobalLock);
-
-        ControlDeviceState = PS_DEVICE_STATE_READY;
-    }
-
-    NdisReleaseSpinLock(&GlobalLock);
-
-    DBGPRINT(("<==PtRegisterDevice: %x\n", Status));
-
-    return (Status);
-}
-
-
-NTSTATUS
-PtDispatch(
-    IN PDEVICE_OBJECT    DeviceObject,
-    IN PIRP              Irp
-    )
-/*++
-Routine Description:
-
-    Process IRPs sent to this device.
-
-Arguments:
-
-    DeviceObject - pointer to a device object
-    Irp      - pointer to an I/O Request Packet
-
-Return Value:
-
-    NTSTATUS - STATUS_SUCCESS always - change this when adding
-    real code to handle ioctls.
-
---*/
-{
-    PIO_STACK_LOCATION  irpStack;
-    NTSTATUS            status = STATUS_SUCCESS;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-    
-    DBGPRINT(("==>Pt Dispatch\n"));
-    irpStack = IoGetCurrentIrpStackLocation(Irp);
-      
-
-    switch (irpStack->MajorFunction)
-    {
-        case IRP_MJ_CREATE:
-            break;
-            
-        case IRP_MJ_CLEANUP:
-            break;
-            
-        case IRP_MJ_CLOSE:
-            break;        
-                    
-               case IRP_MJ_DEVICE_CONTROL:
-           //
-           // Add code here to handle ioctl commands sent to passthru.
-           //
-                       break;
-        default:
-            break;
-    }
-
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    DBGPRINT(("<== Pt Dispatch\n"));
-
-    return status;
-
-} 
-
-
-NDIS_STATUS
-PtDeregisterDevice(
-    VOID
-    )
-/*++
-
-Routine Description:
-
-    Deregister the ioctl interface. This is called whenever a miniport
-    instance is halted. When the last miniport instance is halted, we
-    request NDIS to delete the device object
-
-Arguments:
-
-    NdisDeviceHandle - Handle returned by NdisMRegisterDevice
-
-Return Value:
-
-    NDIS_STATUS_SUCCESS if everything worked ok
-
---*/
-{
-    NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
-
-    DBGPRINT(("==>PassthruDeregisterDevice\n"));
-
-    NdisAcquireSpinLock(&GlobalLock);
-
-    ASSERT(MiniportCount > 0);
-
-    --MiniportCount;
-    
-    if (0 == MiniportCount)
-    {
-        //
-        // All miniport instances have been halted. Deregister
-        // the control device.
-        //
-
-        ASSERT(ControlDeviceState == PS_DEVICE_STATE_READY);
-
-        //
-        // Block PtRegisterDevice() while we release the control
-        // device lock and deregister the device.
-        // 
-        ControlDeviceState = PS_DEVICE_STATE_DELETING;
-
-        NdisReleaseSpinLock(&GlobalLock);
-
-        if (NdisDeviceHandle != NULL)
-        {
-            Status = NdisMDeregisterDevice(NdisDeviceHandle);
-            NdisDeviceHandle = NULL;
-        }
-
-        NdisAcquireSpinLock(&GlobalLock);
-        ControlDeviceState = PS_DEVICE_STATE_READY;
-    }
-
-    NdisReleaseSpinLock(&GlobalLock);
-
-    DBGPRINT(("<== PassthruDeregisterDevice: %x\n", Status));
-    return Status;
-    
-}
-
-VOID
-PtUnload(
-    IN PDRIVER_OBJECT        DriverObject
-    )
-//
-// PassThru driver unload function
-//
-{
-    UNREFERENCED_PARAMETER(DriverObject);
-    
-    DBGPRINT(("PtUnload: entered\n"));   
-    
-    PtUnloadProtocol();
-    
-    NdisIMDeregisterLayeredMiniport(DriverHandle);
-    
-    NdisFreeSpinLock(&GlobalLock);
-       
-    ipfw_module_exit(); // IPFW unloading dummynet
-
-    DBGPRINT(("PtUnload: done!\n"));
-}
diff --git a/modified_passthru/passthru.h b/modified_passthru/passthru.h
deleted file mode 100644 (file)
index 6e79db7..0000000
+++ /dev/null
@@ -1,500 +0,0 @@
-/*++\r
-\r
-Copyright (c) 1992-2000  Microsoft Corporation\r
-\r
-Module Name:\r
-\r
-    passthru.h\r
-\r
-Abstract:\r
-\r
-    Ndis Intermediate Miniport driver sample. This is a passthru driver.\r
-\r
-Author:\r
-\r
-Environment:\r
-\r
-\r
-Revision History:\r
-\r
\r
---*/\r
-\r
-#ifdef NDIS51_MINIPORT\r
-#define PASSTHRU_MAJOR_NDIS_VERSION            5\r
-#define PASSTHRU_MINOR_NDIS_VERSION            1\r
-#else\r
-#define PASSTHRU_MAJOR_NDIS_VERSION            4\r
-#define PASSTHRU_MINOR_NDIS_VERSION            0\r
-#endif\r
-\r
-#ifdef NDIS51\r
-#define PASSTHRU_PROT_MAJOR_NDIS_VERSION    5\r
-#define PASSTHRU_PROT_MINOR_NDIS_VERSION    0\r
-#else\r
-#define PASSTHRU_PROT_MAJOR_NDIS_VERSION    4\r
-#define PASSTHRU_PROT_MINOR_NDIS_VERSION    0\r
-#endif\r
-\r
-#define MAX_BUNDLEID_LENGTH 50\r
-\r
-#define TAG 'ImPa'\r
-#define WAIT_INFINITE 0\r
-\r
-\r
-\r
-//advance declaration\r
-typedef struct _ADAPT ADAPT, *PADAPT;\r
-\r
-DRIVER_INITIALIZE DriverEntry;\r
-extern\r
-NTSTATUS\r
-DriverEntry(\r
-    IN PDRIVER_OBJECT            DriverObject,\r
-    IN PUNICODE_STRING           RegistryPath\r
-    );\r
-\r
-DRIVER_DISPATCH PtDispatch;\r
-NTSTATUS\r
-PtDispatch(\r
-    IN PDEVICE_OBJECT            DeviceObject,\r
-    IN PIRP                      Irp\r
-    );\r
-\r
-DRIVER_DISPATCH DevIoControl;\r
-NTSTATUS\r
-DevIoControl(\r
-    IN PDEVICE_OBJECT            pDeviceObject,\r
-    IN PIRP                      pIrp\r
-    );\r
-\r
-NDIS_STATUS\r
-PtRegisterDevice(\r
-    VOID\r
-    );\r
-\r
-NDIS_STATUS\r
-PtDeregisterDevice(\r
-    VOID\r
-   );\r
-\r
-DRIVER_UNLOAD PtUnload;\r
-VOID\r
-PtUnloadProtocol(\r
-    VOID\r
-    );\r
-\r
-//\r
-// Protocol proto-types\r
-//\r
-extern\r
-VOID\r
-PtOpenAdapterComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_STATUS                Status,\r
-    IN NDIS_STATUS                OpenErrorStatus\r
-    );\r
-\r
-extern\r
-VOID\r
-PtCloseAdapterComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_STATUS                Status\r
-    );\r
-\r
-extern\r
-VOID\r
-PtResetComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_STATUS                Status\r
-    );\r
-\r
-extern\r
-VOID\r
-PtRequestComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNDIS_REQUEST              NdisRequest,\r
-    IN NDIS_STATUS                Status\r
-    );\r
-\r
-extern\r
-VOID\r
-PtStatus(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_STATUS                GeneralStatus,\r
-    IN PVOID                      StatusBuffer,\r
-    IN UINT                       StatusBufferSize\r
-    );\r
-\r
-extern\r
-VOID\r
-PtStatusComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext\r
-    );\r
-\r
-extern\r
-VOID\r
-PtSendComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNDIS_PACKET               Packet,\r
-    IN NDIS_STATUS                Status\r
-    );\r
-\r
-extern\r
-VOID\r
-PtTransferDataComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNDIS_PACKET               Packet,\r
-    IN NDIS_STATUS                Status,\r
-    IN UINT                       BytesTransferred\r
-    );\r
-\r
-extern\r
-NDIS_STATUS\r
-PtReceive(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_HANDLE                MacReceiveContext,\r
-    IN PVOID                      HeaderBuffer,\r
-    IN UINT                       HeaderBufferSize,\r
-    IN PVOID                      LookAheadBuffer,\r
-    IN UINT                       LookaheadBufferSize,\r
-    IN UINT                       PacketSize\r
-    );\r
-\r
-extern\r
-VOID\r
-PtReceiveComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext\r
-    );\r
-\r
-extern\r
-INT\r
-PtReceivePacket(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNDIS_PACKET               Packet\r
-    );\r
-\r
-extern\r
-VOID\r
-PtBindAdapter(\r
-    OUT PNDIS_STATUS              Status,\r
-    IN  NDIS_HANDLE               BindContext,\r
-    IN  PNDIS_STRING              DeviceName,\r
-    IN  PVOID                     SystemSpecific1,\r
-    IN  PVOID                     SystemSpecific2\r
-    );\r
-\r
-extern\r
-VOID\r
-PtUnbindAdapter(\r
-    OUT PNDIS_STATUS              Status,\r
-    IN  NDIS_HANDLE               ProtocolBindingContext,\r
-    IN  NDIS_HANDLE               UnbindContext\r
-    );\r
-    \r
-VOID\r
-PtUnload(\r
-    IN PDRIVER_OBJECT             DriverObject\r
-    );\r
-\r
-\r
-\r
-extern \r
-NDIS_STATUS\r
-PtPNPHandler(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNET_PNP_EVENT             pNetPnPEvent\r
-    );\r
-\r
-\r
-\r
-\r
-NDIS_STATUS\r
-PtPnPNetEventReconfigure(\r
-    IN PADAPT            pAdapt,\r
-    IN PNET_PNP_EVENT    pNetPnPEvent\r
-    );    \r
-\r
-NDIS_STATUS \r
-PtPnPNetEventSetPower (\r
-    IN PADAPT                    pAdapt,\r
-    IN PNET_PNP_EVENT            pNetPnPEvent\r
-    );\r
-    \r
-\r
-//\r
-// Miniport proto-types\r
-//\r
-NDIS_STATUS\r
-MPInitialize(\r
-    OUT PNDIS_STATUS             OpenErrorStatus,\r
-    OUT PUINT                    SelectedMediumIndex,\r
-    IN PNDIS_MEDIUM              MediumArray,\r
-    IN UINT                      MediumArraySize,\r
-    IN NDIS_HANDLE               MiniportAdapterHandle,\r
-    IN NDIS_HANDLE               WrapperConfigurationContext\r
-    );\r
-\r
-VOID\r
-MPSendPackets(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN PPNDIS_PACKET              PacketArray,\r
-    IN UINT                       NumberOfPackets\r
-    );\r
-\r
-NDIS_STATUS\r
-MPSend(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN PNDIS_PACKET               Packet,\r
-    IN UINT                       Flags\r
-    );\r
-\r
-NDIS_STATUS\r
-MPQueryInformation(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN NDIS_OID                   Oid,\r
-    IN PVOID                      InformationBuffer,\r
-    IN ULONG                      InformationBufferLength,\r
-    OUT PULONG                    BytesWritten,\r
-    OUT PULONG                    BytesNeeded\r
-    );\r
-\r
-NDIS_STATUS\r
-MPSetInformation(\r
-    IN NDIS_HANDLE                                      MiniportAdapterContext,\r
-    IN NDIS_OID                                         Oid,\r
-    __in_bcount(InformationBufferLength) IN PVOID       InformationBuffer,\r
-    IN ULONG                                            InformationBufferLength,\r
-    OUT PULONG                                          BytesRead,\r
-    OUT PULONG                                          BytesNeeded\r
-    );\r
-\r
-VOID\r
-MPReturnPacket(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN PNDIS_PACKET               Packet\r
-    );\r
-\r
-NDIS_STATUS\r
-MPTransferData(\r
-    OUT PNDIS_PACKET              Packet,\r
-    OUT PUINT                     BytesTransferred,\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN NDIS_HANDLE                MiniportReceiveContext,\r
-    IN UINT                       ByteOffset,\r
-    IN UINT                       BytesToTransfer\r
-    );\r
-\r
-VOID\r
-MPHalt(\r
-    IN NDIS_HANDLE                MiniportAdapterContext\r
-    );\r
-\r
-\r
-VOID\r
-MPQueryPNPCapabilities(  \r
-    OUT PADAPT                    MiniportProtocolContext, \r
-    OUT PNDIS_STATUS              Status\r
-    );\r
-\r
-\r
-#ifdef NDIS51_MINIPORT\r
-\r
-VOID\r
-MPCancelSendPackets(\r
-    IN NDIS_HANDLE            MiniportAdapterContext,\r
-    IN PVOID                  CancelId\r
-    );\r
-\r
-VOID\r
-MPAdapterShutdown(\r
-    IN NDIS_HANDLE                MiniportAdapterContext\r
-    );\r
-\r
-VOID\r
-MPDevicePnPEvent(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN NDIS_DEVICE_PNP_EVENT      DevicePnPEvent,\r
-    IN PVOID                      InformationBuffer,\r
-    IN ULONG                      InformationBufferLength\r
-    );\r
-\r
-#endif // NDIS51_MINIPORT\r
-\r
-VOID\r
-MPFreeAllPacketPools(\r
-    IN PADAPT                    pAdapt\r
-    );\r
-\r
-\r
-VOID\r
-MPProcessSetPowerOid(\r
-    IN OUT PNDIS_STATUS                             pNdisStatus,\r
-    IN PADAPT                                       pAdapt,\r
-    __in_bcount(InformationBufferLength) IN PVOID   InformationBuffer,\r
-    IN ULONG                                        InformationBufferLength,\r
-    OUT PULONG                                      BytesRead,\r
-    OUT PULONG                                      BytesNeeded\r
-    );\r
-\r
-VOID\r
-PtReferenceAdapt(\r
-    IN PADAPT     pAdapt\r
-    );\r
-\r
-BOOLEAN\r
-PtDereferenceAdapt(\r
-    IN PADAPT     pAdapt\r
-    );\r
-\r
-//\r
-// There should be no DbgPrint's in the Free version of the driver\r
-//\r
-#if DBG\r
-\r
-#define DBGPRINT(Fmt)                                        \\r
-    {                                                        \\r
-       DbgPrint("Passthru: ");                              \
-        DbgPrint Fmt;                                        \\r
-    }\r
-\r
-#else // if DBG\r
-\r
-#define DBGPRINT(Fmt)                                            \r
-\r
-#endif // if DBG \r
-\r
-#define    NUM_PKTS_IN_POOL    256\r
-\r
-\r
-//\r
-// Protocol reserved part of a sent packet that is allocated by us.\r
-//\r
-typedef struct _SEND_RSVD\r
-{\r
-    PNDIS_PACKET    OriginalPkt;\r
-    struct mbuf*    pMbuf; // IPFW extension, reference to the mbuf\r
-} SEND_RSVD, *PSEND_RSVD;\r
-\r
-//\r
-// Miniport reserved part of a received packet that is allocated by\r
-// us. Note that this should fit into the MiniportReserved space\r
-// in an NDIS_PACKET.\r
-//\r
-typedef struct _RECV_RSVD\r
-{\r
-    PNDIS_PACKET    OriginalPkt;\r
-    struct mbuf*    pMbuf; // IPFW extension, reference to the mbuf\r
-} RECV_RSVD, *PRECV_RSVD;\r
-\r
-C_ASSERT(sizeof(RECV_RSVD) <= sizeof(((PNDIS_PACKET)0)->MiniportReserved));\r
-\r
-//\r
-// Event Codes related to the PassthruEvent Structure\r
-//\r
-\r
-typedef enum \r
-{\r
-    Passthru_Invalid,\r
-    Passthru_SetPower,\r
-    Passthru_Unbind\r
-\r
-} PASSSTHRU_EVENT_CODE, *PPASTHRU_EVENT_CODE; \r
-\r
-//\r
-// Passthru Event with  a code to state why they have been state\r
-//\r
-\r
-typedef struct _PASSTHRU_EVENT\r
-{\r
-    NDIS_EVENT Event;\r
-    PASSSTHRU_EVENT_CODE Code;\r
-\r
-} PASSTHRU_EVENT, *PPASSTHRU_EVENT;\r
-\r
-\r
-//\r
-// Structure used by both the miniport as well as the protocol part of the intermediate driver\r
-// to represent an adapter and its corres. lower bindings\r
-//\r
-typedef struct _ADAPT\r
-{\r
-    struct _ADAPT *                Next;\r
-    \r
-    NDIS_HANDLE                    BindingHandle;    // To the lower miniport\r
-    NDIS_HANDLE                    MiniportHandle;    // NDIS Handle to for miniport up-calls\r
-    NDIS_HANDLE                    SendPacketPoolHandle;\r
-    NDIS_HANDLE                    RecvPacketPoolHandle;\r
-    NDIS_STATUS                    Status;            // Open Status\r
-    NDIS_EVENT                     Event;            // Used by bind/halt for Open/Close Adapter synch.\r
-    NDIS_MEDIUM                    Medium;\r
-    NDIS_REQUEST                   Request;        // This is used to wrap a request coming down\r
-                                                // to us. This exploits the fact that requests\r
-                                                // are serialized down to us.\r
-    PULONG                         BytesNeeded;\r
-    PULONG                         BytesReadOrWritten;\r
-    BOOLEAN                        ReceivedIndicationFlags[32];\r
-    \r
-    BOOLEAN                        OutstandingRequests;      // TRUE iff a request is pending\r
-                                                        // at the miniport below\r
-    BOOLEAN                        QueuedRequest;            // TRUE iff a request is queued at\r
-                                                        // this IM miniport\r
-\r
-    BOOLEAN                        StandingBy;                // True - When the miniport or protocol is transitioning from a D0 to Standby (>D0) State\r
-    BOOLEAN                        UnbindingInProcess;\r
-    NDIS_SPIN_LOCK                 Lock;\r
-                                                        // False - At all other times, - Flag is cleared after a transition to D0\r
-\r
-    NDIS_DEVICE_POWER_STATE        MPDeviceState;            // Miniport's Device State \r
-    NDIS_DEVICE_POWER_STATE        PTDeviceState;            // Protocol's Device State \r
-    NDIS_STRING                    DeviceName;                // For initializing the miniport edge\r
-    NDIS_EVENT                     MiniportInitEvent;        // For blocking UnbindAdapter while\r
-                                                        // an IM Init is in progress.\r
-    BOOLEAN                        MiniportInitPending;    // TRUE iff IMInit in progress\r
-    NDIS_STATUS                    LastIndicatedStatus;    // The last indicated media status\r
-    NDIS_STATUS                    LatestUnIndicateStatus; // The latest suppressed media status\r
-    ULONG                          OutstandingSends;\r
-    LONG                           RefCount;\r
-    BOOLEAN                        MiniportIsHalted;\r
-} ADAPT, *PADAPT;\r
-\r
-extern    NDIS_HANDLE                        ProtHandle, DriverHandle;\r
-extern    NDIS_MEDIUM                        MediumArray[4];\r
-extern    PADAPT                             pAdaptList;\r
-extern    NDIS_SPIN_LOCK                     GlobalLock;\r
-\r
-\r
-#define ADAPT_MINIPORT_HANDLE(_pAdapt)    ((_pAdapt)->MiniportHandle)\r
-#define ADAPT_DECR_PENDING_SENDS(_pAdapt)     \\r
-    {                                         \\r
-        NdisAcquireSpinLock(&(_pAdapt)->Lock);   \\r
-        (_pAdapt)->OutstandingSends--;           \\r
-        NdisReleaseSpinLock(&(_pAdapt)->Lock);   \\r
-    }\r
-\r
-//\r
-// Custom Macros to be used by the passthru driver \r
-//\r
-/*\r
-BOOLEAN\r
-IsIMDeviceStateOn(\r
-   PADAPT \r
-   )\r
-\r
-*/\r
-#define IsIMDeviceStateOn(_pP)        ((_pP)->MPDeviceState == NdisDeviceStateD0 && (_pP)->PTDeviceState == NdisDeviceStateD0 ) \r
-\r
-#include "winmissing.h"\r
-\r
-int ipfw_module_init(void);\r
-void ipfw_module_exit(void);\r
-int ipfw2_qhandler_w32(PNDIS_PACKET pNdisPacket, int direction,\r
-       NDIS_HANDLE Context);\r
-int ipfw2_qhandler_w32_oldstyle(int direction, NDIS_HANDLE ProtocolBindingContext,\r
-               unsigned char* HeaderBuffer, unsigned int HeaderBufferSize,\r
-               unsigned char* LookAheadBuffer, unsigned int LookAheadBufferSize,\r
-           unsigned int PacketSize);\r
-void CleanupReinjected(PNDIS_PACKET Packet, struct mbuf* m, PADAPT pAdapt);\r
-void hexdump(PUCHAR,int, const char *);\r
-void my_init();\r
-void my_exit();
\ No newline at end of file
diff --git a/modified_passthru/precomp.h b/modified_passthru/precomp.h
deleted file mode 100644 (file)
index b2870d1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma warning(disable:4214)   // bit field types other than int\r
-\r
-#pragma warning(disable:4201)   // nameless struct/union\r
-#pragma warning(disable:4115)   // named type definition in parentheses\r
-#pragma warning(disable:4127)   // conditional expression is constant\r
-#pragma warning(disable:4054)   // cast of function pointer to PVOID\r
-#pragma warning(disable:4244)   // conversion from 'int' to 'BOOLEAN', possible loss of data\r
-\r
-#include <ndis.h>\r
-#include "passthru.h"\r
-\r
diff --git a/modified_passthru/protocol.c b/modified_passthru/protocol.c
deleted file mode 100644 (file)
index 9db4c36..0000000
+++ /dev/null
@@ -1,1670 +0,0 @@
-/*++
-
-Copyright(c) 1992-2000  Microsoft Corporation
-
-Module Name:
-
-    protocol.c
-
-Abstract:
-
-    Ndis Intermediate Miniport driver sample. This is a passthru driver.
-
-Author:
-
-Environment:
-
-
-Revision History:
-
-
---*/
-
-
-#include "precomp.h"
-#pragma hdrstop
-
-#define MAX_PACKET_POOL_SIZE 0x0000FFFF
-#define MIN_PACKET_POOL_SIZE 0x000000FF
-
-//
-// NDIS version as 0xMMMMmmmm, where M=Major/m=minor (0x00050001 = 5.1); 
-// initially unknown (0)
-// 
-ULONG       NdisDotSysVersion =  0x0;
-
-
-#define NDIS_SYS_VERSION_51       0x00050001
-
-
-VOID
-PtBindAdapter(
-    OUT PNDIS_STATUS            Status,
-    IN  NDIS_HANDLE             BindContext,
-    IN  PNDIS_STRING            DeviceName,
-    IN  PVOID                   SystemSpecific1,
-    IN  PVOID                   SystemSpecific2
-    )
-/*++
-
-Routine Description:
-
-    Called by NDIS to bind to a miniport below.
-
-Arguments:
-
-    Status            - Return status of bind here.
-    BindContext        - Can be passed to NdisCompleteBindAdapter if this call is pended.
-    DeviceName         - Device name to bind to. This is passed to NdisOpenAdapter.
-    SystemSpecific1    - Can be passed to NdisOpenProtocolConfiguration to read per-binding information
-    SystemSpecific2    - Unused
-
-Return Value:
-
-    NDIS_STATUS_PENDING    if this call is pended. In this case call NdisCompleteBindAdapter
-    to complete.
-    Anything else          Completes this call synchronously
-
---*/
-{
-    NDIS_HANDLE                     ConfigHandle = NULL;
-    PNDIS_CONFIGURATION_PARAMETER   Param;
-    NDIS_STRING                     DeviceStr = NDIS_STRING_CONST("UpperBindings");
-    NDIS_STRING                     NdisVersionStr = NDIS_STRING_CONST("NdisVersion");
-    PADAPT                          pAdapt = NULL;
-    NDIS_STATUS                     Sts;
-    UINT                            MediumIndex;
-    ULONG                           TotalSize;
-    BOOLEAN                         NoCleanUpNeeded = FALSE;
-
-
-    UNREFERENCED_PARAMETER(BindContext);
-    UNREFERENCED_PARAMETER(SystemSpecific2);
-    
-    DBGPRINT(("==> Protocol BindAdapter\n"));
-
-    do
-    {
-        //
-        // Access the configuration section for our binding-specific
-        // parameters.
-        //
-        NdisOpenProtocolConfiguration(Status,
-                                       &ConfigHandle,
-                                       SystemSpecific1);
-
-        if (*Status != NDIS_STATUS_SUCCESS)
-        {
-            break;
-        }
-        if (NdisDotSysVersion == 0)
-        {
-            NdisReadConfiguration(Status,
-                                  &Param,
-                                  ConfigHandle,
-                                  &NdisVersionStr,        // "NdisVersion"
-                                  NdisParameterInteger);
-            if (*Status != NDIS_STATUS_SUCCESS)
-            {
-                break;
-            }
-            
-            NdisDotSysVersion = Param->ParameterData.IntegerData;
-        }
-                        
-
-        //
-        // Read the "UpperBindings" reserved key that contains a list
-        // of device names representing our miniport instances corresponding
-        // to this lower binding. Since this is a 1:1 IM driver, this key
-        // contains exactly one name.
-        //
-        // If we want to implement a N:1 mux driver (N adapter instances
-        // over a single lower binding), then UpperBindings will be a
-        // MULTI_SZ containing a list of device names - we would loop through
-        // this list, calling NdisIMInitializeDeviceInstanceEx once for
-        // each name in it.
-        //
-        NdisReadConfiguration(Status,
-                              &Param,
-                              ConfigHandle,
-                              &DeviceStr,
-                              NdisParameterString);
-        if (*Status != NDIS_STATUS_SUCCESS)
-        {
-            break;
-        }
-
-        //
-        // Allocate memory for the Adapter structure. This represents both the
-        // protocol context as well as the adapter structure when the miniport
-        // is initialized.
-        //
-        // In addition to the base structure, allocate space for the device
-        // instance string.
-        //
-        TotalSize = sizeof(ADAPT) + Param->ParameterData.StringData.MaximumLength;
-
-        NdisAllocateMemoryWithTag(&pAdapt, TotalSize, TAG);
-
-        if (pAdapt == NULL)
-        {
-            *Status = NDIS_STATUS_RESOURCES;
-            break;
-        }
-
-        //
-        // Initialize the adapter structure. We copy in the IM device
-        // name as well, because we may need to use it in a call to
-        // NdisIMCancelInitializeDeviceInstance. The string returned
-        // by NdisReadConfiguration is active (i.e. available) only
-        // for the duration of this call to our BindAdapter handler.
-        //
-        NdisZeroMemory(pAdapt, TotalSize);
-        pAdapt->DeviceName.MaximumLength = Param->ParameterData.StringData.MaximumLength;
-        pAdapt->DeviceName.Length = Param->ParameterData.StringData.Length;
-        pAdapt->DeviceName.Buffer = (PWCHAR)((ULONG_PTR)pAdapt + sizeof(ADAPT));
-        NdisMoveMemory(pAdapt->DeviceName.Buffer,
-                       Param->ParameterData.StringData.Buffer,
-                       Param->ParameterData.StringData.MaximumLength);
-
-
-
-        NdisInitializeEvent(&pAdapt->Event);
-        NdisAllocateSpinLock(&pAdapt->Lock);
-
-        //
-        // Allocate a packet pool for sends. We need this to pass sends down.
-        // We cannot use the same packet descriptor that came down to our send
-        // handler (see also NDIS 5.1 packet stacking).
-        //
-        NdisAllocatePacketPoolEx(Status,
-                                   &pAdapt->SendPacketPoolHandle,
-                                   MIN_PACKET_POOL_SIZE,
-                                   MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
-                                   sizeof(SEND_RSVD));
-
-        if (*Status != NDIS_STATUS_SUCCESS)
-        {
-            break;
-        }
-
-        //
-        // Allocate a packet pool for receives. We need this to indicate receives.
-        // Same consideration as sends (see also NDIS 5.1 packet stacking).
-        //
-        NdisAllocatePacketPoolEx(Status,
-                                   &pAdapt->RecvPacketPoolHandle,
-                                   MIN_PACKET_POOL_SIZE,
-                                   MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
-                                   PROTOCOL_RESERVED_SIZE_IN_PACKET);
-
-        if (*Status != NDIS_STATUS_SUCCESS)
-        {
-            break;
-        }
-
-        //
-        // Now open the adapter below and complete the initialization
-        //
-        NdisOpenAdapter(Status,
-                          &Sts,
-                          &pAdapt->BindingHandle,
-                          &MediumIndex,
-                          MediumArray,
-                          sizeof(MediumArray)/sizeof(NDIS_MEDIUM),
-                          ProtHandle,
-                          pAdapt,
-                          DeviceName,
-                          0,
-                          NULL);
-
-        if (*Status == NDIS_STATUS_PENDING)
-        {
-            NdisWaitEvent(&pAdapt->Event, 0);
-            *Status = pAdapt->Status;
-        }
-
-        if (*Status != NDIS_STATUS_SUCCESS)
-        {
-            break;
-        }
-        PtReferenceAdapt(pAdapt);
-
-#pragma prefast(suppress: __WARNING_POTENTIAL_BUFFER_OVERFLOW, "Ndis guarantees MediumIndex to be within bounds");
-        pAdapt->Medium = MediumArray[MediumIndex];
-
-        //
-        // Now ask NDIS to initialize our miniport (upper) edge.
-        // Set the flag below to synchronize with a possible call
-        // to our protocol Unbind handler that may come in before
-        // our miniport initialization happens.
-        //
-        pAdapt->MiniportInitPending = TRUE;
-        NdisInitializeEvent(&pAdapt->MiniportInitEvent);
-
-        PtReferenceAdapt(pAdapt);
-
-        *Status = NdisIMInitializeDeviceInstanceEx(DriverHandle,
-                                           &pAdapt->DeviceName,
-                                           pAdapt);
-
-        if (*Status != NDIS_STATUS_SUCCESS)
-        {
-            if (pAdapt->MiniportIsHalted == TRUE)
-            {
-                NoCleanUpNeeded = TRUE;
-            }
-            
-            DBGPRINT(("BindAdapter: Adapt %p, IMInitializeDeviceInstance error %x\n",
-                pAdapt, *Status));
-            
-            if (PtDereferenceAdapt(pAdapt))
-            {
-                pAdapt = NULL;
-            }
-            
-            break;
-        }
-        
-        PtDereferenceAdapt(pAdapt);
-
-    } while(FALSE);
-
-    //
-    // Close the configuration handle now - see comments above with
-    // the call to NdisIMInitializeDeviceInstanceEx.
-    //
-    if (ConfigHandle != NULL)
-    {
-        NdisCloseConfiguration(ConfigHandle);
-    }
-
-    if ((*Status != NDIS_STATUS_SUCCESS) && (NoCleanUpNeeded == FALSE))
-    {
-        if (pAdapt != NULL)
-        {
-            if (pAdapt->BindingHandle != NULL)
-            {
-                NDIS_STATUS    LocalStatus;
-
-                //
-                // Close the binding we opened above.
-                //
-
-                NdisResetEvent(&pAdapt->Event);
-                
-                NdisCloseAdapter(&LocalStatus, pAdapt->BindingHandle);
-                pAdapt->BindingHandle = NULL;
-
-                if (LocalStatus == NDIS_STATUS_PENDING)
-                {
-                     NdisWaitEvent(&pAdapt->Event, 0);
-                     LocalStatus = pAdapt->Status;
-
-                     
-                }
-                if (PtDereferenceAdapt(pAdapt))
-                {
-                     pAdapt = NULL;
-                }
-            }
-        }
-    }
-
-
-    DBGPRINT(("<== Protocol BindAdapter: pAdapt %p, Status %x\n", pAdapt, *Status));
-}
-
-
-VOID
-PtOpenAdapterComplete(
-    IN  NDIS_HANDLE             ProtocolBindingContext,
-    IN  NDIS_STATUS             Status,
-    IN  NDIS_STATUS             OpenErrorStatus
-    )
-/*++
-
-Routine Description:
-
-    Completion routine for NdisOpenAdapter issued from within the PtBindAdapter. Simply
-    unblock the caller.
-
-Arguments:
-
-    ProtocolBindingContext    Pointer to the adapter
-    Status                    Status of the NdisOpenAdapter call
-    OpenErrorStatus            Secondary status(ignored by us).
-
-Return Value:
-
-    None
-
---*/
-{
-    PADAPT      pAdapt =(PADAPT)ProtocolBindingContext;
-    
-    UNREFERENCED_PARAMETER(OpenErrorStatus);
-    
-    DBGPRINT(("==> PtOpenAdapterComplete: Adapt %p, Status %x\n", pAdapt, Status));
-    pAdapt->Status = Status;
-    NdisSetEvent(&pAdapt->Event);
-}
-
-
-VOID
-PtUnbindAdapter(
-    OUT PNDIS_STATUS           Status,
-    IN  NDIS_HANDLE            ProtocolBindingContext,
-    IN  NDIS_HANDLE            UnbindContext
-    )
-/*++
-
-Routine Description:
-
-    Called by NDIS when we are required to unbind to the adapter below.
-    This functions shares functionality with the miniport's HaltHandler.
-    The code should ensure that NdisCloseAdapter and NdisFreeMemory is called
-    only once between the two functions
-
-Arguments:
-
-    Status                    Placeholder for return status
-    ProtocolBindingContext    Pointer to the adapter structure
-    UnbindContext            Context for NdisUnbindComplete() if this pends
-
-Return Value:
-
-    Status for NdisIMDeinitializeDeviceContext
-
---*/
-{
-    PADAPT         pAdapt =(PADAPT)ProtocolBindingContext;
-    NDIS_STATUS    LocalStatus;
-
-    UNREFERENCED_PARAMETER(UnbindContext);
-    
-    DBGPRINT(("==> PtUnbindAdapter: Adapt %p\n", pAdapt));
-
-    //
-    // Set the flag that the miniport below is unbinding, so the request handlers will
-    // fail any request comming later
-    // 
-    NdisAcquireSpinLock(&pAdapt->Lock);
-    pAdapt->UnbindingInProcess = TRUE;
-    if (pAdapt->QueuedRequest == TRUE)
-    {
-        pAdapt->QueuedRequest = FALSE;
-        NdisReleaseSpinLock(&pAdapt->Lock);
-
-        PtRequestComplete(pAdapt,
-                         &pAdapt->Request,
-                         NDIS_STATUS_FAILURE );
-
-    }
-    else
-    {
-        NdisReleaseSpinLock(&pAdapt->Lock);
-    }
-#ifndef WIN9X
-    //
-    // Check if we had called NdisIMInitializeDeviceInstanceEx and
-    // we are awaiting a call to MiniportInitialize.
-    //
-    if (pAdapt->MiniportInitPending == TRUE)
-    {
-        //
-        // Try to cancel the pending IMInit process.
-        //
-        LocalStatus = NdisIMCancelInitializeDeviceInstance(
-                        DriverHandle,
-                        &pAdapt->DeviceName);
-
-        if (LocalStatus == NDIS_STATUS_SUCCESS)
-        {
-            //
-            // Successfully cancelled IM Initialization; our
-            // Miniport Initialize routine will not be called
-            // for this device.
-            //
-            pAdapt->MiniportInitPending = FALSE;
-            ASSERT(pAdapt->MiniportHandle == NULL);
-        }
-        else
-        {
-            //
-            // Our Miniport Initialize routine will be called
-            // (may be running on another thread at this time).
-            // Wait for it to finish.
-            //
-            NdisWaitEvent(&pAdapt->MiniportInitEvent, 0);
-            ASSERT(pAdapt->MiniportInitPending == FALSE);
-        }
-
-    }
-#endif // !WIN9X
-
-    //
-    // Call NDIS to remove our device-instance. We do most of the work
-    // inside the HaltHandler.
-    //
-    // The Handle will be NULL if our miniport Halt Handler has been called or
-    // if the IM device was never initialized
-    //
-    
-    if (pAdapt->MiniportHandle != NULL)
-    {
-        *Status = NdisIMDeInitializeDeviceInstance(pAdapt->MiniportHandle);
-
-        if (*Status != NDIS_STATUS_SUCCESS)
-        {
-            *Status = NDIS_STATUS_FAILURE;
-        }
-    }
-    else
-    {
-        //
-        // We need to do some work here. 
-        // Close the binding below us 
-        // and release the memory allocated.
-        //
-        
-        if(pAdapt->BindingHandle != NULL)
-        {
-            NdisResetEvent(&pAdapt->Event);
-
-            NdisCloseAdapter(Status, pAdapt->BindingHandle);
-
-            //
-            // Wait for it to complete
-            //
-            if(*Status == NDIS_STATUS_PENDING)
-            {
-                 NdisWaitEvent(&pAdapt->Event, 0);
-                 *Status = pAdapt->Status;
-            }
-            pAdapt->BindingHandle = NULL;
-        }
-        else
-        {
-            //
-            // Both Our MiniportHandle and Binding Handle  should not be NULL.
-            //
-            *Status = NDIS_STATUS_FAILURE;
-            ASSERT(0);
-        }
-
-        //
-        //    Free the memory here, if was not released earlier(by calling the HaltHandler)
-        //
-        MPFreeAllPacketPools(pAdapt);
-        NdisFreeSpinLock(&pAdapt->Lock);
-        NdisFreeMemory(pAdapt, 0, 0);
-    }
-
-    DBGPRINT(("<== PtUnbindAdapter: Adapt %p\n", pAdapt));
-}
-
-VOID
-PtUnloadProtocol(
-    VOID
-)
-{
-    NDIS_STATUS Status;
-
-    if (ProtHandle != NULL)
-    {
-        NdisDeregisterProtocol(&Status, ProtHandle);
-        ProtHandle = NULL;
-    }
-
-    DBGPRINT(("PtUnloadProtocol: done!\n"));
-}
-
-
-
-VOID
-PtCloseAdapterComplete(
-    IN    NDIS_HANDLE            ProtocolBindingContext,
-    IN    NDIS_STATUS            Status
-    )
-/*++
-
-Routine Description:
-
-    Completion for the CloseAdapter call.
-
-Arguments:
-
-    ProtocolBindingContext    Pointer to the adapter structure
-    Status                    Completion status
-
-Return Value:
-
-    None.
-
---*/
-{
-    PADAPT      pAdapt =(PADAPT)ProtocolBindingContext;
-
-    DBGPRINT(("CloseAdapterComplete: Adapt %p, Status %x\n", pAdapt, Status));
-    pAdapt->Status = Status;
-    NdisSetEvent(&pAdapt->Event);
-}
-
-
-VOID
-PtResetComplete(
-    IN  NDIS_HANDLE            ProtocolBindingContext,
-    IN  NDIS_STATUS            Status
-    )
-/*++
-
-Routine Description:
-
-    Completion for the reset.
-
-Arguments:
-
-    ProtocolBindingContext    Pointer to the adapter structure
-    Status                    Completion status
-
-Return Value:
-
-    None.
-
---*/
-{
-
-    UNREFERENCED_PARAMETER(ProtocolBindingContext);
-    UNREFERENCED_PARAMETER(Status);
-    //
-    // We never issue a reset, so we should not be here.
-    //
-    ASSERT(0);
-}
-
-
-VOID
-PtRequestComplete(
-    IN  NDIS_HANDLE            ProtocolBindingContext,
-    IN  PNDIS_REQUEST          NdisRequest,
-    IN  NDIS_STATUS            Status
-    )
-/*++
-
-Routine Description:
-
-    Completion handler for the previously posted request. All OIDS
-    are completed by and sent to the same miniport that they were requested for.
-    If Oid == OID_PNP_QUERY_POWER then the data structure needs to returned with all entries =
-    NdisDeviceStateUnspecified
-
-Arguments:
-
-    ProtocolBindingContext    Pointer to the adapter structure
-    NdisRequest                The posted request
-    Status                    Completion status
-
-Return Value:
-
-    None
-
---*/
-{
-    PADAPT        pAdapt = (PADAPT)ProtocolBindingContext;
-    NDIS_OID      Oid = pAdapt->Request.DATA.SET_INFORMATION.Oid ;
-
-    //
-    // Since our request is not outstanding anymore
-    //
-    ASSERT(pAdapt->OutstandingRequests == TRUE);
-
-    pAdapt->OutstandingRequests = FALSE;
-
-    //
-    // Complete the Set or Query, and fill in the buffer for OID_PNP_CAPABILITIES, if need be.
-    //
-    switch (NdisRequest->RequestType)
-    {
-      case NdisRequestQueryInformation:
-
-        //
-        // We never pass OID_PNP_QUERY_POWER down.
-        //
-        ASSERT(Oid != OID_PNP_QUERY_POWER);
-
-        if ((Oid == OID_PNP_CAPABILITIES) && (Status == NDIS_STATUS_SUCCESS))
-        {
-            MPQueryPNPCapabilities(pAdapt, &Status);
-        }
-        *pAdapt->BytesReadOrWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten;
-        *pAdapt->BytesNeeded = NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded;
-
-        if (((Oid == OID_GEN_MAC_OPTIONS) 
-              && (Status == NDIS_STATUS_SUCCESS))
-              && (NdisDotSysVersion >= NDIS_SYS_VERSION_51))
-        {
-            //
-            // Only do this on Windows XP or greater (NDIS.SYS v 5.1); 
-            // do not do in Windows 2000 (NDIS.SYS v 5.0))
-            //
-                
-            //
-            // Remove the no-loopback bit from mac-options. In essence we are
-            // telling NDIS that we can handle loopback. We don't, but the
-            // interface below us does. If we do not do this, then loopback
-            // processing happens both below us and above us. This is wasteful
-            // at best and if Netmon is running, it will see multiple copies
-            // of loopback packets when sniffing above us.
-            //
-            // Only the lowest miniport is a stack of layered miniports should
-            // ever report this bit set to NDIS.
-            //
-            *(PULONG)NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer &= ~NDIS_MAC_OPTION_NO_LOOPBACK;
-        }
-
-        NdisMQueryInformationComplete(pAdapt->MiniportHandle,
-                                      Status);
-        break;
-
-      case NdisRequestSetInformation:
-
-        ASSERT( Oid != OID_PNP_SET_POWER);
-
-        *pAdapt->BytesReadOrWritten = NdisRequest->DATA.SET_INFORMATION.BytesRead;
-        *pAdapt->BytesNeeded = NdisRequest->DATA.SET_INFORMATION.BytesNeeded;
-        NdisMSetInformationComplete(pAdapt->MiniportHandle,
-                                    Status);
-        break;
-
-      default:
-        ASSERT(0);
-        break;
-    }
-    
-}
-
-
-VOID
-PtStatus(
-    IN  NDIS_HANDLE         ProtocolBindingContext,
-    IN  NDIS_STATUS         GeneralStatus,
-    IN  PVOID               StatusBuffer,
-    IN  UINT                StatusBufferSize
-    )
-/*++
-
-Routine Description:
-
-    Status handler for the lower-edge(protocol).
-
-Arguments:
-
-    ProtocolBindingContext    Pointer to the adapter structure
-    GeneralStatus             Status code
-    StatusBuffer              Status buffer
-    StatusBufferSize          Size of the status buffer
-
-Return Value:
-
-    None
-
---*/
-{
-    PADAPT      pAdapt = (PADAPT)ProtocolBindingContext;
-
-    //
-    // Pass up this indication only if the upper edge miniport is initialized
-    // and powered on. Also ignore indications that might be sent by the lower
-    // miniport when it isn't at D0.
-    //
-    if ((pAdapt->MiniportHandle != NULL)  &&
-        (pAdapt->MPDeviceState == NdisDeviceStateD0) &&
-        (pAdapt->PTDeviceState == NdisDeviceStateD0))    
-    {
-        if ((GeneralStatus == NDIS_STATUS_MEDIA_CONNECT) || 
-            (GeneralStatus == NDIS_STATUS_MEDIA_DISCONNECT))
-        {
-            
-            pAdapt->LastIndicatedStatus = GeneralStatus;
-        }
-        NdisMIndicateStatus(pAdapt->MiniportHandle,
-                            GeneralStatus,
-                            StatusBuffer,
-                            StatusBufferSize);
-    }
-    //
-    // Save the last indicated media status 
-    //
-    else
-    {
-        if ((pAdapt->MiniportHandle != NULL) && 
-        ((GeneralStatus == NDIS_STATUS_MEDIA_CONNECT) || 
-            (GeneralStatus == NDIS_STATUS_MEDIA_DISCONNECT)))
-        {
-            pAdapt->LatestUnIndicateStatus = GeneralStatus;
-        }
-    }
-    
-}
-
-
-VOID
-PtStatusComplete(
-    IN NDIS_HANDLE            ProtocolBindingContext
-    )
-/*++
-
-Routine Description:
-
-
-Arguments:
-
-
-Return Value:
-
-
---*/
-{
-    PADAPT      pAdapt = (PADAPT)ProtocolBindingContext;
-
-    //
-    // Pass up this indication only if the upper edge miniport is initialized
-    // and powered on. Also ignore indications that might be sent by the lower
-    // miniport when it isn't at D0.
-    //
-    if ((pAdapt->MiniportHandle != NULL)  &&
-        (pAdapt->MPDeviceState == NdisDeviceStateD0) &&
-        (pAdapt->PTDeviceState == NdisDeviceStateD0))    
-    {
-        NdisMIndicateStatusComplete(pAdapt->MiniportHandle);
-    }
-}
-
-
-VOID
-PtSendComplete(
-    IN  NDIS_HANDLE            ProtocolBindingContext,
-    IN  PNDIS_PACKET           Packet,
-    IN  NDIS_STATUS            Status
-    )
-/*++
-
-Routine Description:
-
-    Called by NDIS when the miniport below had completed a send. We should
-    complete the corresponding upper-edge send this represents.
-
-Arguments:
-
-    ProtocolBindingContext - Points to ADAPT structure
-    Packet - Low level packet being completed
-    Status - status of send
-
-Return Value:
-
-    None
-
---*/
-{
-    PADAPT            pAdapt = (PADAPT)ProtocolBindingContext;
-    PNDIS_PACKET      Pkt; 
-    NDIS_HANDLE       PoolHandle;
-
-#ifdef NDIS51
-    //
-    // Packet stacking:
-    //
-    // Determine if the packet we are completing is the one we allocated. If so, then
-    // get the original packet from the reserved area and completed it and free the
-    // allocated packet. If this is the packet that was sent down to us, then just
-    // complete it
-    //
-    PoolHandle = NdisGetPoolFromPacket(Packet);
-    if (PoolHandle != pAdapt->SendPacketPoolHandle)
-    {
-        //
-        // We had passed down a packet belonging to the protocol above us.
-        //
-        // DBGPRINT(("PtSendComp: Adapt %p, Stacked Packet %p\n", pAdapt, Packet));
-
-        NdisMSendComplete(pAdapt->MiniportHandle,
-                          Packet,
-                          Status);
-    }
-    else
-#endif // NDIS51
-    {
-        PSEND_RSVD        SendRsvd;
-
-        SendRsvd = (PSEND_RSVD)(Packet->ProtocolReserved);
-        Pkt = SendRsvd->OriginalPkt;
-
-#if 1  // IPFW - new code
-       //DbgPrint("SendComplete: packet %p pkt %p\n", Packet, Pkt);
-       if (Pkt == NULL) { //this is a reinjected packet, with no 'father'
-               CleanupReinjected(Packet, SendRsvd->pMbuf, pAdapt);
-               return;
-       }
-#endif /* IPFW */
-    
-#ifndef WIN9X
-        NdisIMCopySendCompletePerPacketInfo (Pkt, Packet);
-#endif
-    
-        NdisDprFreePacket(Packet);
-
-        NdisMSendComplete(pAdapt->MiniportHandle,
-                                 Pkt,
-                                 Status);
-    }
-    //
-    // Decrease the outstanding send count
-    //
-    ADAPT_DECR_PENDING_SENDS(pAdapt);
-}       
-
-
-VOID
-PtTransferDataComplete(
-    IN  NDIS_HANDLE         ProtocolBindingContext,
-    IN  PNDIS_PACKET        Packet,
-    IN  NDIS_STATUS         Status,
-    IN  UINT                BytesTransferred
-    )
-/*++
-
-Routine Description:
-
-    Entry point called by NDIS to indicate completion of a call by us
-    to NdisTransferData.
-
-    See notes under SendComplete.
-
-Arguments:
-
-Return Value:
-
---*/
-{
-    PADAPT      pAdapt =(PADAPT)ProtocolBindingContext;
-
-    if(pAdapt->MiniportHandle)
-    {
-        NdisMTransferDataComplete(pAdapt->MiniportHandle,
-                                  Packet,
-                                  Status,
-                                  BytesTransferred);
-    }
-}
-
-
-NDIS_STATUS
-PtReceive(
-    IN  NDIS_HANDLE         ProtocolBindingContext,
-    IN  NDIS_HANDLE         MacReceiveContext,
-    IN  PVOID               HeaderBuffer,
-    IN  UINT                HeaderBufferSize,
-    IN  PVOID               LookAheadBuffer,
-    IN  UINT                LookAheadBufferSize,
-    IN  UINT                PacketSize
-    )
-/*++
-
-Routine Description:
-
-    Handle receive data indicated up by the miniport below. We pass
-    it along to the protocol above us.
-
-    If the miniport below indicates packets, NDIS would more
-    likely call us at our ReceivePacket handler. However we
-    might be called here in certain situations even though
-    the miniport below has indicated a receive packet, e.g.
-    if the miniport had set packet status to NDIS_STATUS_RESOURCES.
-        
-Arguments:
-
-    <see DDK ref page for ProtocolReceive>
-
-Return Value:
-
-    NDIS_STATUS_SUCCESS if we processed the receive successfully,
-    NDIS_STATUS_XXX error code if we discarded it.
-
---*/
-{
-    PADAPT            pAdapt = (PADAPT)ProtocolBindingContext;
-    PNDIS_PACKET      MyPacket, Packet = NULL;
-    NDIS_STATUS       Status = NDIS_STATUS_SUCCESS;
-    ULONG             Proc = KeGetCurrentProcessorNumber();      
-    
-    if ((!pAdapt->MiniportHandle) || (pAdapt->MPDeviceState > NdisDeviceStateD0))
-    {
-        Status = NDIS_STATUS_FAILURE;
-    }
-    else do
-    {
-        //
-        // Get at the packet, if any, indicated up by the miniport below.
-        //
-        Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext);
-        if (Packet != NULL)
-        {              
-            //
-            // The miniport below did indicate up a packet. Use information
-            // from that packet to construct a new packet to indicate up.
-            //
-
-#ifdef NDIS51
-            //
-            // NDIS 5.1 NOTE: Do not reuse the original packet in indicating
-            // up a receive, even if there is sufficient packet stack space.
-            // If we had to do so, we would have had to overwrite the
-            // status field in the original packet to NDIS_STATUS_RESOURCES,
-            // and it is not allowed for protocols to overwrite this field
-            // in received packets.
-            //
-#endif // NDIS51
-
-            //
-            // Get a packet off the pool and indicate that up
-            //
-            NdisDprAllocatePacket(&Status,
-                                &MyPacket,
-                                pAdapt->RecvPacketPoolHandle);
-
-            if (Status == NDIS_STATUS_SUCCESS)
-            {
-                //
-                // Make our packet point to data from the original
-                // packet. NOTE: this works only because we are
-                // indicating a receive directly from the context of
-                // our receive indication. If we need to queue this
-                // packet and indicate it from another thread context,
-                // we will also have to allocate a new buffer and copy
-                // over the packet contents, OOB data and per-packet
-                // information. This is because the packet data
-                // is available only for the duration of this
-                // receive indication call.
-                //
-                NDIS_PACKET_FIRST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_FIRST_NDIS_BUFFER(Packet);
-                NDIS_PACKET_LAST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_LAST_NDIS_BUFFER(Packet);
-
-                //
-                // Get the original packet (it could be the same packet as the
-                // one received or a different one based on the number of layered
-                // miniports below) and set it on the indicated packet so the OOB
-                // data is visible correctly at protocols above.  If the IM driver 
-                // modifies the packet in any way it should not set the new packet's
-                // original packet equal to the original packet of the packet that 
-                // was indicated to it from the underlying driver, in this case, the 
-                // IM driver should also ensure that the related per packet info should
-                // be copied to the new packet.
-                // we can set the original packet to the original packet of the packet
-                // indicated from the underlying driver because the driver doesn't modify
-                // the data content in the packet.
-                //
-                NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet));
-                NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize);
-
-                //
-                // Copy packet flags.
-                //
-                NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);
-
-                //
-                // Force protocols above to make a copy if they want to hang
-                // on to data in this packet. This is because we are in our
-                // Receive handler (not ReceivePacket) and we can't return a
-                // ref count from here.
-                //
-                NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);
-
-                //
-                // By setting NDIS_STATUS_RESOURCES, we also know that we can reclaim
-                // this packet as soon as the call to NdisMIndicateReceivePacket
-                // returns.
-                //
-
-                if (pAdapt->MiniportHandle != NULL)
-                {
-#if 1  /* IPFW: query the firewall */
-                                       int     ret;
-                                       ret = ipfw2_qhandler_w32(MyPacket, INCOMING,
-                                               ProtocolBindingContext);
-                                       if (ret != PASS)
-                                       return 0; //otherwise simply continue
-#endif /* end of IPFW code */
-                    NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
-                }
-
-                //
-                // Reclaim the indicated packet. Since we had set its status
-                // to NDIS_STATUS_RESOURCES, we are guaranteed that protocols
-                // above are done with it.
-                //
-                NdisDprFreePacket(MyPacket);
-
-                break;
-            }
-        }
-        else
-        {
-            //
-            // The miniport below us uses the old-style (not packet)
-            // receive indication. Fall through.
-            //
-        }
-
-        //
-        // Fall through if the miniport below us has either not
-        // indicated a packet or we could not allocate one
-        //
-        pAdapt->ReceivedIndicationFlags[Proc] = TRUE;
-        if (pAdapt->MiniportHandle == NULL)
-        {
-            break;
-        }
-        switch (pAdapt->Medium)
-        {
-            case NdisMedium802_3:
-            case NdisMediumWan:
-                               //DbgPrint("EthIndicateReceive context %p, header at %p len %u, lookahead at %p len %u, packetsize %u\n",ProtocolBindingContext,HeaderBuffer,HeaderBufferSize,LookAheadBuffer,LookAheadBufferSize,PacketSize);
-                               //hexdump(HeaderBuffer,HeaderBufferSize+LookAheadBufferSize,"EthIndicateReceive");
-                       {
-                               int ret = ipfw2_qhandler_w32_oldstyle(INCOMING, ProtocolBindingContext, HeaderBuffer, HeaderBufferSize, LookAheadBuffer, LookAheadBufferSize, PacketSize);
-                               if (ret != PASS)
-                                       return NDIS_STATUS_SUCCESS;
-                       }
-                NdisMEthIndicateReceive(pAdapt->MiniportHandle,
-                                             MacReceiveContext,
-                                             HeaderBuffer,
-                                             HeaderBufferSize,
-                                             LookAheadBuffer,
-                                             LookAheadBufferSize,
-                                             PacketSize);
-                break;
-
-            case NdisMedium802_5:
-                NdisMTrIndicateReceive(pAdapt->MiniportHandle,
-                                            MacReceiveContext,
-                                            HeaderBuffer,
-                                            HeaderBufferSize,
-                                            LookAheadBuffer,
-                                            LookAheadBufferSize,
-                                            PacketSize);
-                break;
-
-#if FDDI
-                 case NdisMediumFddi:
-                        NdisMFddiIndicateReceive(pAdapt->MiniportHandle,
-                                                                                         MacReceiveContext,
-                                                                                         HeaderBuffer,
-                                                                                         HeaderBufferSize,
-                                                                                         LookAheadBuffer,
-                                                                                         LookAheadBufferSize,
-                                                                                         PacketSize);
-                        break;
-#endif
-                 default:
-                        ASSERT(FALSE);
-                        break;
-               }
-
-    } while(FALSE);
-
-    return Status;
-}
-
-
-VOID
-PtReceiveComplete(
-    IN NDIS_HANDLE        ProtocolBindingContext
-    )
-/*++
-
-Routine Description:
-
-    Called by the adapter below us when it is done indicating a batch of
-    received packets.
-
-Arguments:
-
-    ProtocolBindingContext    Pointer to our adapter structure.
-
-Return Value:
-
-    None
-
---*/
-{
-    PADAPT        pAdapt =(PADAPT)ProtocolBindingContext;
-    ULONG         Proc = KeGetCurrentProcessorNumber();      
-       
-       /* Warning: this is a poor implementation of the PtReceiveComplete
-        * made by MS, and it's a well known (but never fixed) issue.
-        * Since the ProcessorNumber here can be different from the one
-        * that processed the PtReceive, sometimes NdisMEthIndicateReceiveComplete
-        * will not be called, causing poor performance in the incoming traffic.
-        * In our driver, PtReceive is called for IP packets ONLY by particulary 
-        * old NIC drivers, and the poor performance can be seen even 
-        * in traffic not handled by ipfw or dummynet.
-        * Fortunately, this is quite rare, all the incoming IP packets
-        * will arrive through PtReceivePacket, and this callback will never
-        * be called. For reinjected traffic, a workaround is done
-        * commuting the ReceivedIndicationFlag and calling
-        * NdisMEthIndicateReceiveComplete manually for each packet.
-        */
-
-    if (((pAdapt->MiniportHandle != NULL)
-                && (pAdapt->MPDeviceState == NdisDeviceStateD0))
-                && (pAdapt->ReceivedIndicationFlags[Proc]))
-    {
-        switch (pAdapt->Medium)
-        {
-            case NdisMedium802_3:
-            case NdisMediumWan:
-                NdisMEthIndicateReceiveComplete(pAdapt->MiniportHandle);
-                break;
-
-                 case NdisMedium802_5:
-                       NdisMTrIndicateReceiveComplete(pAdapt->MiniportHandle);
-                       break;
-#if FDDI
-                 case NdisMediumFddi:
-                       NdisMFddiIndicateReceiveComplete(pAdapt->MiniportHandle);
-                       break;
-#endif
-                 default:
-                       ASSERT(FALSE);
-                       break;
-               }
-       }
-
-    pAdapt->ReceivedIndicationFlags[Proc] = FALSE;
-}
-
-
-INT
-PtReceivePacket(
-    IN NDIS_HANDLE            ProtocolBindingContext,
-    IN PNDIS_PACKET           Packet
-    )
-/*++
-
-Routine Description:
-
-    ReceivePacket handler. Called by NDIS if the miniport below supports
-    NDIS 4.0 style receives. Re-package the buffer chain in a new packet
-    and indicate the new packet to protocols above us. Any context for
-    packets indicated up must be kept in the MiniportReserved field.
-
-    NDIS 5.1 - packet stacking - if there is sufficient "stack space" in
-    the packet passed to us, we can use the same packet in a receive
-    indication.
-
-Arguments:
-
-    ProtocolBindingContext - Pointer to our adapter structure.
-    Packet - Pointer to the packet
-
-Return Value:
-
-    == 0 -> We are done with the packet
-    != 0 -> We will keep the packet and call NdisReturnPackets() this
-            many times when done.
---*/
-{
-    PADAPT              pAdapt =(PADAPT)ProtocolBindingContext;
-    NDIS_STATUS         Status;
-    PNDIS_PACKET        MyPacket;
-    BOOLEAN             Remaining;
-
-    //
-    // Drop the packet silently if the upper miniport edge isn't initialized or
-    // the miniport edge is in low power state
-    //
-    if ((!pAdapt->MiniportHandle) || (pAdapt->MPDeviceState > NdisDeviceStateD0))
-    {
-          return 0;
-    }
-
-#ifdef NDIS51
-    //
-    // Check if we can reuse the same packet for indicating up.
-    // See also: PtReceive(). 
-    //
-    (VOID)NdisIMGetCurrentPacketStack(Packet, &Remaining);
-    if (0 && Remaining)
-    {
-        //
-        // We can reuse "Packet". Indicate it up and be done with it.
-        //
-        Status = NDIS_GET_PACKET_STATUS(Packet);
-        NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &Packet, 1);
-        return((Status != NDIS_STATUS_RESOURCES) ? 1 : 0);
-    }
-#endif // NDIS51
-
-    //
-    // Get a packet off the pool and indicate that up
-    //
-    NdisDprAllocatePacket(&Status,
-                           &MyPacket,
-                           pAdapt->RecvPacketPoolHandle);
-
-    if (Status == NDIS_STATUS_SUCCESS)
-    {
-        PRECV_RSVD            RecvRsvd;
-
-        RecvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
-        RecvRsvd->OriginalPkt = Packet;
-
-        NDIS_PACKET_FIRST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_FIRST_NDIS_BUFFER(Packet);
-        NDIS_PACKET_LAST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_LAST_NDIS_BUFFER(Packet);
-
-        //
-        // Get the original packet (it could be the same packet as the one
-        // received or a different one based on the number of layered miniports
-        // below) and set it on the indicated packet so the OOB data is visible
-        // correctly to protocols above us.
-        //
-        NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet));
-
-        //
-        // Set Packet Flags
-        //
-        NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);
-
-        Status = NDIS_GET_PACKET_STATUS(Packet);
-
-        NDIS_SET_PACKET_STATUS(MyPacket, Status);
-        NDIS_SET_PACKET_HEADER_SIZE(MyPacket, NDIS_GET_PACKET_HEADER_SIZE(Packet));
-
-        if (pAdapt->MiniportHandle != NULL)
-        {
-#if 1  /* IPFW: query the firewall */
-           int ret;
-           ret = ipfw2_qhandler_w32(MyPacket, INCOMING,
-                       ProtocolBindingContext);
-           if (ret != PASS)
-                       return 0; //otherwise simply continue
-#endif /* end of IPFW code */
-            NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
-        }
-
-        //
-        // Check if we had indicated up the packet with NDIS_STATUS_RESOURCES
-        // NOTE -- do not use NDIS_GET_PACKET_STATUS(MyPacket) for this since
-        // it might have changed! Use the value saved in the local variable.
-        //
-        if (Status == NDIS_STATUS_RESOURCES)
-        {
-            //
-            // Our ReturnPackets handler will not be called for this packet.
-            // We should reclaim it right here.
-            //
-            NdisDprFreePacket(MyPacket);
-        }
-
-        return((Status != NDIS_STATUS_RESOURCES) ? 1 : 0);
-    }
-    else
-    {
-        //
-        // We are out of packets. Silently drop it.
-        //
-        return(0);
-    }
-}
-
-
-NDIS_STATUS
-PtPNPHandler(
-    IN NDIS_HANDLE        ProtocolBindingContext,
-    IN PNET_PNP_EVENT     pNetPnPEvent
-    )
-
-/*++
-Routine Description:
-
-    This is called by NDIS to notify us of a PNP event related to a lower
-    binding. Based on the event, this dispatches to other helper routines.
-
-    NDIS 5.1: forward this event to the upper protocol(s) by calling
-    NdisIMNotifyPnPEvent.
-
-Arguments:
-
-    ProtocolBindingContext - Pointer to our adapter structure. Can be NULL
-                for "global" notifications
-
-    pNetPnPEvent - Pointer to the PNP event to be processed.
-
-Return Value:
-
-    NDIS_STATUS code indicating status of event processing.
-
---*/
-{
-    PADAPT            pAdapt  =(PADAPT)ProtocolBindingContext;
-    NDIS_STATUS       Status  = NDIS_STATUS_SUCCESS;
-
-    DBGPRINT(("PtPnPHandler: Adapt %p, Event %d\n", pAdapt, pNetPnPEvent->NetEvent));
-
-    switch (pNetPnPEvent->NetEvent)
-    {
-        case NetEventSetPower:
-            Status = PtPnPNetEventSetPower(pAdapt, pNetPnPEvent);
-            break;
-
-         case NetEventReconfigure:
-            Status = PtPnPNetEventReconfigure(pAdapt, pNetPnPEvent);
-            break;
-
-         default:
-#ifdef NDIS51
-            //
-            // Pass on this notification to protocol(s) above, before
-            // doing anything else with it.
-            //
-            if (pAdapt && pAdapt->MiniportHandle)
-            {
-                Status = NdisIMNotifyPnPEvent(pAdapt->MiniportHandle, pNetPnPEvent);
-            }
-#else
-            Status = NDIS_STATUS_SUCCESS;
-
-#endif // NDIS51
-
-            break;
-    }
-
-    return Status;
-}
-
-
-NDIS_STATUS
-PtPnPNetEventReconfigure(
-    IN PADAPT            pAdapt,
-    IN PNET_PNP_EVENT    pNetPnPEvent
-    )
-/*++
-Routine Description:
-
-    This routine is called from NDIS to notify our protocol edge of a
-    reconfiguration of parameters for either a specific binding (pAdapt
-    is not NULL), or global parameters if any (pAdapt is NULL).
-
-Arguments:
-
-    pAdapt - Pointer to our adapter structure.
-    pNetPnPEvent - the reconfigure event
-
-Return Value:
-
-    NDIS_STATUS_SUCCESS
-
---*/
-{
-    NDIS_STATUS    ReconfigStatus = NDIS_STATUS_SUCCESS;
-    NDIS_STATUS    ReturnStatus = NDIS_STATUS_SUCCESS;
-
-    do
-    {
-        //
-        // Is this is a global reconfiguration notification ?
-        //
-        if (pAdapt == NULL)
-        {
-            //
-            // An important event that causes this notification to us is if
-            // one of our upper-edge miniport instances was enabled after being
-            // disabled earlier, e.g. from Device Manager in Win2000. Note that
-            // NDIS calls this because we had set up an association between our
-            // miniport and protocol entities by calling NdisIMAssociateMiniport.
-            //
-            // Since we would have torn down the lower binding for that miniport,
-            // we need NDIS' assistance to re-bind to the lower miniport. The
-            // call to NdisReEnumerateProtocolBindings does exactly that.
-            //
-            NdisReEnumerateProtocolBindings (ProtHandle);        
-            
-            break;
-        }
-
-#ifdef NDIS51
-        //
-        // Pass on this notification to protocol(s) above before doing anything
-        // with it.
-        //
-        if (pAdapt->MiniportHandle)
-        {
-            ReturnStatus = NdisIMNotifyPnPEvent(pAdapt->MiniportHandle, pNetPnPEvent);
-        }
-#endif // NDIS51
-
-        ReconfigStatus = NDIS_STATUS_SUCCESS;
-
-    } while(FALSE);
-
-    DBGPRINT(("<==PtPNPNetEventReconfigure: pAdapt %p\n", pAdapt));
-
-#ifdef NDIS51
-    //
-    // Overwrite status with what upper-layer protocol(s) returned.
-    //
-    ReconfigStatus = ReturnStatus;
-#endif
-
-    return ReconfigStatus;
-}
-
-
-NDIS_STATUS
-PtPnPNetEventSetPower(
-    IN PADAPT            pAdapt,
-    IN PNET_PNP_EVENT    pNetPnPEvent
-    )
-/*++
-Routine Description:
-
-    This is a notification to our protocol edge of the power state
-    of the lower miniport. If it is going to a low-power state, we must
-    wait here for all outstanding sends and requests to complete.
-
-    NDIS 5.1:  Since we use packet stacking, it is not sufficient to
-    check usage of our local send packet pool to detect whether or not
-    all outstanding sends have completed. For this, use the new API
-    NdisQueryPendingIOCount.
-
-    NDIS 5.1: Use the 5.1 API NdisIMNotifyPnPEvent to pass on PnP
-    notifications to upper protocol(s).
-
-Arguments:
-
-    pAdapt            -    Pointer to the adpater structure
-    pNetPnPEvent    -    The Net Pnp Event. this contains the new device state
-
-Return Value:
-
-    NDIS_STATUS_SUCCESS or the status returned by upper-layer protocols.
-
---*/
-{
-    PNDIS_DEVICE_POWER_STATE       pDeviceState  =(PNDIS_DEVICE_POWER_STATE)(pNetPnPEvent->Buffer);
-    NDIS_DEVICE_POWER_STATE        PrevDeviceState = pAdapt->PTDeviceState;  
-    NDIS_STATUS                    Status;
-    NDIS_STATUS                    ReturnStatus;
-
-    ReturnStatus = NDIS_STATUS_SUCCESS;
-
-    //
-    // Set the Internal Device State, this blocks all new sends or receives
-    //
-    NdisAcquireSpinLock(&pAdapt->Lock);
-    pAdapt->PTDeviceState = *pDeviceState;
-
-    //
-    // Check if the miniport below is going to a low power state.
-    //
-    if (pAdapt->PTDeviceState > NdisDeviceStateD0)
-    {
-        //
-        // If the miniport below is going to standby, fail all incoming requests
-        //
-        if (PrevDeviceState == NdisDeviceStateD0)
-        {
-            pAdapt->StandingBy = TRUE;
-        }
-
-        NdisReleaseSpinLock(&pAdapt->Lock);
-
-#ifdef NDIS51
-        //
-        // Notify upper layer protocol(s) first.
-        //
-        if (pAdapt->MiniportHandle != NULL)
-        {
-            ReturnStatus = NdisIMNotifyPnPEvent(pAdapt->MiniportHandle, pNetPnPEvent);
-        }
-#endif // NDIS51
-
-        //
-        // Wait for outstanding sends and requests to complete.
-        //
-        while (pAdapt->OutstandingSends != 0)
-        {
-            NdisMSleep(2);
-        }
-
-        while (pAdapt->OutstandingRequests == TRUE)
-        {
-            //
-            // sleep till outstanding requests complete
-            //
-            NdisMSleep(2);
-        }
-
-        //
-        // If the below miniport is going to low power state, complete the queued request
-        //
-        NdisAcquireSpinLock(&pAdapt->Lock);
-        if (pAdapt->QueuedRequest)
-        {
-            pAdapt->QueuedRequest = FALSE;
-            NdisReleaseSpinLock(&pAdapt->Lock);
-            PtRequestComplete(pAdapt, &pAdapt->Request, NDIS_STATUS_FAILURE);
-        }
-        else
-        {
-            NdisReleaseSpinLock(&pAdapt->Lock);
-        }
-            
-
-        ASSERT(NdisPacketPoolUsage(pAdapt->SendPacketPoolHandle) == 0);
-        ASSERT(pAdapt->OutstandingRequests == FALSE);
-    }
-    else
-    {
-        //
-        // If the physical miniport is powering up (from Low power state to D0), 
-        // clear the flag
-        //
-        if (PrevDeviceState > NdisDeviceStateD0)
-        {
-            pAdapt->StandingBy = FALSE;
-        }
-        //
-        // The device below is being turned on. If we had a request
-        // pending, send it down now.
-        //
-        if (pAdapt->QueuedRequest == TRUE)
-        {
-            pAdapt->QueuedRequest = FALSE;
-        
-            pAdapt->OutstandingRequests = TRUE;
-            NdisReleaseSpinLock(&pAdapt->Lock);
-
-            NdisRequest(&Status,
-                        pAdapt->BindingHandle,
-                        &pAdapt->Request);
-
-            if (Status != NDIS_STATUS_PENDING)
-            {
-                PtRequestComplete(pAdapt,
-                                  &pAdapt->Request,
-                                  Status);
-                
-            }
-        }
-        else
-        {
-            NdisReleaseSpinLock(&pAdapt->Lock);
-        }
-
-
-#ifdef NDIS51
-        //
-        // Pass on this notification to protocol(s) above
-        //
-        if (pAdapt->MiniportHandle)
-        {
-            ReturnStatus = NdisIMNotifyPnPEvent(pAdapt->MiniportHandle, pNetPnPEvent);
-        }
-#endif // NDIS51
-
-    }
-
-    return ReturnStatus;
-}
-
-VOID
-PtReferenceAdapt(
-    IN PADAPT     pAdapt
-    )
-{
-    NdisAcquireSpinLock(&pAdapt->Lock);
-    
-    ASSERT(pAdapt->RefCount >= 0);
-
-    pAdapt->RefCount ++;
-    NdisReleaseSpinLock(&pAdapt->Lock);
-}
-
-
-BOOLEAN
-PtDereferenceAdapt(
-    IN PADAPT     pAdapt
-    )
-{
-    NdisAcquireSpinLock(&pAdapt->Lock);
-
-    ASSERT(pAdapt->RefCount > 0);
-
-    pAdapt->RefCount--;
-
-    if (pAdapt->RefCount == 0)
-    {
-        NdisReleaseSpinLock(&pAdapt->Lock);
-        
-        //
-        // Free all resources on this adapter structure.
-        //
-        MPFreeAllPacketPools (pAdapt);;
-        NdisFreeSpinLock(&pAdapt->Lock);
-        NdisFreeMemory(pAdapt, 0 , 0);
-        
-        return TRUE;
-        
-    }
-    else
-    {
-        NdisReleaseSpinLock(&pAdapt->Lock);
-
-        return FALSE;
-    }
-}
-
-
diff --git a/original_passthru/makefile b/original_passthru/makefile
deleted file mode 100644 (file)
index c6c9e94..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#\r
-# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source\r
-# file to this component.  This file merely indirects to the real make file\r
-# that is shared by all the components of NT\r
-#\r
-\r
-#!INCLUDE $(NTMAKEENV)\makefile.def\r
-\r
-\r
-!IF DEFINED(_NT_TARGET_VERSION)\r
-!      IF $(_NT_TARGET_VERSION)>=0x501\r
-!              INCLUDE $(NTMAKEENV)\makefile.def\r
-!      ELSE\r
-#               Only warn once per directory\r
-!               INCLUDE $(NTMAKEENV)\makefile.plt\r
-!               IF "$(BUILD_PASS)"=="PASS1"\r
-!                  message BUILDMSG: Warning : The sample "$(MAKEDIR)" is not valid for the current OS target.\r
-!               ENDIF\r
-!      ENDIF\r
-!ELSE\r
-!      INCLUDE $(NTMAKEENV)\makefile.def\r
-!ENDIF\r
diff --git a/original_passthru/miniport.c b/original_passthru/miniport.c
deleted file mode 100644 (file)
index a7f3bbc..0000000
+++ /dev/null
@@ -1,1461 +0,0 @@
-/*++\r
-\r
-Copyright (c) 1992-2000  Microsoft Corporation\r
-\r
-Module Name:\r
-\r
-    miniport.c\r
-\r
-Abstract:\r
-\r
-    Ndis Intermediate Miniport driver sample. This is a passthru driver.\r
-\r
-Author:\r
-\r
-Environment:\r
-\r
-\r
-Revision History:\r
-\r
-\r
---*/\r
-\r
-#include "precomp.h"\r
-#pragma hdrstop\r
-\r
-\r
-\r
-NDIS_STATUS\r
-MPInitialize(\r
-    OUT PNDIS_STATUS             OpenErrorStatus,\r
-    OUT PUINT                    SelectedMediumIndex,\r
-    IN  PNDIS_MEDIUM             MediumArray,\r
-    IN  UINT                     MediumArraySize,\r
-    IN  NDIS_HANDLE              MiniportAdapterHandle,\r
-    IN  NDIS_HANDLE              WrapperConfigurationContext\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    This is the initialize handler which gets called as a result of\r
-    the BindAdapter handler calling NdisIMInitializeDeviceInstanceEx.\r
-    The context parameter which we pass there is the adapter structure\r
-    which we retrieve here.\r
-\r
-    Arguments:\r
-\r
-    OpenErrorStatus            Not used by us.\r
-    SelectedMediumIndex        Place-holder for what media we are using\r
-    MediumArray                Array of ndis media passed down to us to pick from\r
-    MediumArraySize            Size of the array\r
-    MiniportAdapterHandle    The handle NDIS uses to refer to us\r
-    WrapperConfigurationContext    For use by NdisOpenConfiguration\r
-\r
-Return Value:\r
-\r
-    NDIS_STATUS_SUCCESS unless something goes wrong\r
-\r
---*/\r
-{\r
-    UINT            i;\r
-    PADAPT          pAdapt;\r
-    NDIS_STATUS     Status = NDIS_STATUS_FAILURE;\r
-    NDIS_MEDIUM     Medium;\r
-\r
-    UNREFERENCED_PARAMETER(WrapperConfigurationContext);\r
-    \r
-    do\r
-    {\r
-        //\r
-        // Start off by retrieving our adapter context and storing\r
-        // the Miniport handle in it.\r
-        //\r
-        pAdapt = NdisIMGetDeviceContext(MiniportAdapterHandle);\r
-        pAdapt->MiniportIsHalted = FALSE;\r
-\r
-        DBGPRINT(("==> Miniport Initialize: Adapt %p\n", pAdapt));\r
-\r
-        //\r
-        // Usually we export the medium type of the adapter below as our\r
-        // virtual miniport's medium type. However if the adapter below us\r
-        // is a WAN device, then we claim to be of medium type 802.3.\r
-        //\r
-        Medium = pAdapt->Medium;\r
-\r
-        if (Medium == NdisMediumWan)\r
-        {\r
-            Medium = NdisMedium802_3;\r
-        }\r
-\r
-        for (i = 0; i < MediumArraySize; i++)\r
-        {\r
-            if (MediumArray[i] == Medium)\r
-            {\r
-                *SelectedMediumIndex = i;\r
-                break;\r
-            }\r
-        }\r
-\r
-        if (i == MediumArraySize)\r
-        {\r
-            Status = NDIS_STATUS_UNSUPPORTED_MEDIA;\r
-            break;\r
-        }\r
-\r
-\r
-        //\r
-        // Set the attributes now. NDIS_ATTRIBUTE_DESERIALIZE enables us\r
-        // to make up-calls to NDIS without having to call NdisIMSwitchToMiniport\r
-        // or NdisIMQueueCallBack. This also forces us to protect our data using\r
-        // spinlocks where appropriate. Also in this case NDIS does not queue\r
-        // packets on our behalf. Since this is a very simple pass-thru\r
-        // miniport, we do not have a need to protect anything. However in\r
-        // a general case there will be a need to use per-adapter spin-locks\r
-        // for the packet queues at the very least.\r
-        //\r
-        NdisMSetAttributesEx(MiniportAdapterHandle,\r
-                             pAdapt,\r
-                             0,                                        // CheckForHangTimeInSeconds\r
-                             NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT    |\r
-                                NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT|\r
-                                NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER |\r
-                                NDIS_ATTRIBUTE_DESERIALIZE |\r
-                                NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND,\r
-                             0);\r
-\r
-        pAdapt->MiniportHandle = MiniportAdapterHandle;\r
-        //\r
-        // Initialize LastIndicatedStatus to be NDIS_STATUS_MEDIA_CONNECT\r
-        //\r
-        pAdapt->LastIndicatedStatus = NDIS_STATUS_MEDIA_CONNECT;\r
-        \r
-        //\r
-        // Initialize the power states for both the lower binding (PTDeviceState)\r
-        // and our miniport edge to Powered On.\r
-        //\r
-        pAdapt->MPDeviceState = NdisDeviceStateD0;\r
-        pAdapt->PTDeviceState = NdisDeviceStateD0;\r
-\r
-        //\r
-        // Add this adapter to the global pAdapt List\r
-        //\r
-        NdisAcquireSpinLock(&GlobalLock);\r
-\r
-        pAdapt->Next = pAdaptList;\r
-        pAdaptList = pAdapt;\r
-\r
-        NdisReleaseSpinLock(&GlobalLock);\r
-        \r
-        //\r
-        // Create an ioctl interface\r
-        //\r
-        (VOID)PtRegisterDevice();\r
-\r
-        Status = NDIS_STATUS_SUCCESS;\r
-    }\r
-    while (FALSE);\r
-\r
-    //\r
-    // If we had received an UnbindAdapter notification on the underlying\r
-    // adapter, we would have blocked that thread waiting for the IM Init\r
-    // process to complete. Wake up any such thread.\r
-    //\r
-    ASSERT(pAdapt->MiniportInitPending == TRUE);\r
-    pAdapt->MiniportInitPending = FALSE;\r
-    NdisSetEvent(&pAdapt->MiniportInitEvent);\r
-\r
-    if (Status == NDIS_STATUS_SUCCESS)\r
-    {\r
-        PtReferenceAdapt(pAdapt);\r
-    }\r
-\r
-    DBGPRINT(("<== Miniport Initialize: Adapt %p, Status %x\n", pAdapt, Status));\r
-\r
-    *OpenErrorStatus = Status;\r
-\r
-    \r
-    return Status;\r
-}\r
-\r
-\r
-NDIS_STATUS\r
-MPSend(\r
-    IN NDIS_HANDLE             MiniportAdapterContext,\r
-    IN PNDIS_PACKET            Packet,\r
-    IN UINT                    Flags\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Send Packet handler. Either this or our SendPackets (array) handler is called\r
-    based on which one is enabled in our Miniport Characteristics.\r
-\r
-Arguments:\r
-\r
-    MiniportAdapterContext    Pointer to the adapter\r
-    Packet                    Packet to send\r
-    Flags                     Unused, passed down below\r
-\r
-Return Value:\r
-\r
-    Return code from NdisSend\r
-\r
---*/\r
-{\r
-    PADAPT              pAdapt = (PADAPT)MiniportAdapterContext;\r
-    NDIS_STATUS         Status;\r
-    PNDIS_PACKET        MyPacket;\r
-    PVOID               MediaSpecificInfo = NULL;\r
-    ULONG               MediaSpecificInfoSize = 0;\r
-\r
-    //\r
-    // The driver should fail the send if the virtual miniport is in low \r
-    // power state\r
-    //\r
-    if (pAdapt->MPDeviceState > NdisDeviceStateD0)\r
-    {\r
-         return NDIS_STATUS_FAILURE;\r
-    }\r
-\r
-#ifdef NDIS51\r
-    //\r
-    // Use NDIS 5.1 packet stacking:\r
-    //\r
-    {\r
-        PNDIS_PACKET_STACK        pStack;\r
-        BOOLEAN                   Remaining;\r
-\r
-        //\r
-        // Packet stacks: Check if we can use the same packet for sending down.\r
-        //\r
-\r
-        pStack = NdisIMGetCurrentPacketStack(Packet, &Remaining);\r
-        if (Remaining)\r
-        {\r
-            //\r
-            // We can reuse "Packet".\r
-            //\r
-            // NOTE: if we needed to keep per-packet information in packets\r
-            // sent down, we can use pStack->IMReserved[].\r
-            //\r
-            ASSERT(pStack);\r
-            //\r
-            // If the below miniport is going to low power state, stop sending down any packet.\r
-            //\r
-            NdisAcquireSpinLock(&pAdapt->Lock);\r
-            if (pAdapt->PTDeviceState > NdisDeviceStateD0)\r
-            {\r
-                NdisReleaseSpinLock(&pAdapt->Lock);\r
-                return NDIS_STATUS_FAILURE;\r
-            }\r
-            pAdapt->OutstandingSends++;\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            NdisSend(&Status,\r
-                     pAdapt->BindingHandle,\r
-                     Packet);\r
-\r
-            if (Status != NDIS_STATUS_PENDING)\r
-            {\r
-                ADAPT_DECR_PENDING_SENDS(pAdapt);\r
-            }\r
-\r
-            return(Status);\r
-        }\r
-    }\r
-#endif // NDIS51\r
-\r
-    //\r
-    // We are either not using packet stacks, or there isn't stack space\r
-    // in the original packet passed down to us. Allocate a new packet\r
-    // to wrap the data with.\r
-    //\r
-    //\r
-    // If the below miniport is going to low power state, stop sending down any packet.\r
-    //\r
-    NdisAcquireSpinLock(&pAdapt->Lock);\r
-    if (pAdapt->PTDeviceState > NdisDeviceStateD0)\r
-    {\r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-        return NDIS_STATUS_FAILURE;\r
-    \r
-    }\r
-    pAdapt->OutstandingSends++;\r
-    NdisReleaseSpinLock(&pAdapt->Lock);\r
-    \r
-    NdisAllocatePacket(&Status,\r
-                       &MyPacket,\r
-                       pAdapt->SendPacketPoolHandle);\r
-\r
-    if (Status == NDIS_STATUS_SUCCESS)\r
-    {\r
-        PSEND_RSVD            SendRsvd;\r
-\r
-        //\r
-        // Save a pointer to the original packet in our reserved\r
-        // area in the new packet. This is needed so that we can\r
-        // get back to the original packet when the new packet's send\r
-        // is completed.\r
-        //\r
-        SendRsvd = (PSEND_RSVD)(MyPacket->ProtocolReserved);\r
-        SendRsvd->OriginalPkt = Packet;\r
-\r
-        NdisGetPacketFlags(MyPacket) = Flags;\r
-\r
-        //\r
-        // Set up the new packet so that it describes the same\r
-        // data as the original packet.\r
-        //\r
-        NDIS_PACKET_FIRST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_FIRST_NDIS_BUFFER(Packet);\r
-        NDIS_PACKET_LAST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_LAST_NDIS_BUFFER(Packet);\r
-#ifdef WIN9X\r
-        //\r
-        // Work around the fact that NDIS does not initialize this\r
-        // to FALSE on Win9x.\r
-        //\r
-        NDIS_PACKET_VALID_COUNTS(MyPacket) = FALSE;\r
-#endif\r
-\r
-        //\r
-        // Copy the OOB Offset from the original packet to the new\r
-        // packet.\r
-        //\r
-        NdisMoveMemory(NDIS_OOB_DATA_FROM_PACKET(MyPacket),\r
-                       NDIS_OOB_DATA_FROM_PACKET(Packet),\r
-                       sizeof(NDIS_PACKET_OOB_DATA));\r
-\r
-#ifndef WIN9X\r
-        //\r
-        // Copy the right parts of per packet info into the new packet.\r
-        // This API is not available on Win9x since task offload is\r
-        // not supported on that platform.\r
-        //\r
-        NdisIMCopySendPerPacketInfo(MyPacket, Packet);\r
-#endif\r
-        \r
-        //\r
-        // Copy the Media specific information\r
-        //\r
-        NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(Packet,\r
-                                            &MediaSpecificInfo,\r
-                                            &MediaSpecificInfoSize);\r
-\r
-        if (MediaSpecificInfo || MediaSpecificInfoSize)\r
-        {\r
-            NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket,\r
-                                                MediaSpecificInfo,\r
-                                                MediaSpecificInfoSize);\r
-        }\r
-\r
-        NdisSend(&Status,\r
-                 pAdapt->BindingHandle,\r
-                 MyPacket);\r
-\r
-\r
-        if (Status != NDIS_STATUS_PENDING)\r
-        {\r
-#ifndef WIN9X\r
-            NdisIMCopySendCompletePerPacketInfo (Packet, MyPacket);\r
-#endif\r
-            NdisFreePacket(MyPacket);\r
-            ADAPT_DECR_PENDING_SENDS(pAdapt);\r
-        }\r
-    }\r
-    else\r
-    {\r
-        ADAPT_DECR_PENDING_SENDS(pAdapt);\r
-        //\r
-        // We are out of packets. Silently drop it. Alternatively we can deal with it:\r
-        //    - By keeping separate send and receive pools\r
-        //    - Dynamically allocate more pools as needed and free them when not needed\r
-        //\r
-    }\r
-\r
-    return(Status);\r
-}\r
-\r
-\r
-VOID\r
-MPSendPackets(\r
-    IN NDIS_HANDLE             MiniportAdapterContext,\r
-    IN PPNDIS_PACKET           PacketArray,\r
-    IN UINT                    NumberOfPackets\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Send Packet Array handler. Either this or our SendPacket handler is called\r
-    based on which one is enabled in our Miniport Characteristics.\r
-\r
-Arguments:\r
-\r
-    MiniportAdapterContext     Pointer to our adapter\r
-    PacketArray                Set of packets to send\r
-    NumberOfPackets            Self-explanatory\r
-\r
-Return Value:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-    PADAPT              pAdapt = (PADAPT)MiniportAdapterContext;\r
-    NDIS_STATUS         Status;\r
-    UINT                i;\r
-    PVOID               MediaSpecificInfo = NULL;\r
-    UINT                MediaSpecificInfoSize = 0;\r
-    \r
-\r
-    for (i = 0; i < NumberOfPackets; i++)\r
-    {\r
-        PNDIS_PACKET    Packet, MyPacket;\r
-\r
-        Packet = PacketArray[i];\r
-        //\r
-        // The driver should fail the send if the virtual miniport is in low \r
-        // power state\r
-        //\r
-        if (pAdapt->MPDeviceState > NdisDeviceStateD0)\r
-        {\r
-            NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),\r
-                            Packet,\r
-                            NDIS_STATUS_FAILURE);\r
-            continue;\r
-        }\r
-\r
-#ifdef NDIS51\r
-\r
-        //\r
-        // Use NDIS 5.1 packet stacking:\r
-        //\r
-        {\r
-            PNDIS_PACKET_STACK        pStack;\r
-            BOOLEAN                   Remaining;\r
-\r
-            //\r
-            // Packet stacks: Check if we can use the same packet for sending down.\r
-            //\r
-            pStack = NdisIMGetCurrentPacketStack(Packet, &Remaining);\r
-            if (Remaining)\r
-            {\r
-                //\r
-                // We can reuse "Packet".\r
-                //\r
-                // NOTE: if we needed to keep per-packet information in packets\r
-                // sent down, we can use pStack->IMReserved[].\r
-                //\r
-                ASSERT(pStack);\r
-                //\r
-                // If the below miniport is going to low power state, stop sending down any packet.\r
-                //\r
-                NdisAcquireSpinLock(&pAdapt->Lock);\r
-                if (pAdapt->PTDeviceState > NdisDeviceStateD0)\r
-                {\r
-                    NdisReleaseSpinLock(&pAdapt->Lock);\r
-                    NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),\r
-                                        Packet,\r
-                                        NDIS_STATUS_FAILURE);\r
-                }\r
-                else\r
-                {\r
-                    pAdapt->OutstandingSends++;\r
-                    NdisReleaseSpinLock(&pAdapt->Lock);\r
-                \r
-                    NdisSend(&Status,\r
-                              pAdapt->BindingHandle,\r
-                              Packet);\r
-        \r
-                    if (Status != NDIS_STATUS_PENDING)\r
-                    {\r
-                        NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),\r
-                                            Packet,\r
-                                            Status);\r
-                   \r
-                        ADAPT_DECR_PENDING_SENDS(pAdapt);\r
-                    }\r
-                }\r
-                continue;\r
-            }\r
-        }\r
-#endif\r
-        do \r
-        {\r
-            NdisAcquireSpinLock(&pAdapt->Lock);\r
-            //\r
-            // If the below miniport is going to low power state, stop sending down any packet.\r
-            //\r
-            if (pAdapt->PTDeviceState > NdisDeviceStateD0)\r
-            {\r
-                NdisReleaseSpinLock(&pAdapt->Lock);\r
-                Status = NDIS_STATUS_FAILURE;\r
-                break;\r
-            }\r
-            pAdapt->OutstandingSends++;\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            \r
-            NdisAllocatePacket(&Status,\r
-                               &MyPacket,\r
-                               pAdapt->SendPacketPoolHandle);\r
-\r
-            if (Status == NDIS_STATUS_SUCCESS)\r
-            {\r
-                PSEND_RSVD        SendRsvd;\r
-\r
-                SendRsvd = (PSEND_RSVD)(MyPacket->ProtocolReserved);\r
-                SendRsvd->OriginalPkt = Packet;\r
-\r
-                NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);\r
-\r
-                NDIS_PACKET_FIRST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_FIRST_NDIS_BUFFER(Packet);\r
-                NDIS_PACKET_LAST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_LAST_NDIS_BUFFER(Packet);\r
-#ifdef WIN9X\r
-                //\r
-                // Work around the fact that NDIS does not initialize this\r
-                // to FALSE on Win9x.\r
-                //\r
-                NDIS_PACKET_VALID_COUNTS(MyPacket) = FALSE;\r
-#endif // WIN9X\r
-\r
-                //\r
-                // Copy the OOB data from the original packet to the new\r
-                // packet.\r
-                //\r
-                NdisMoveMemory(NDIS_OOB_DATA_FROM_PACKET(MyPacket),\r
-                            NDIS_OOB_DATA_FROM_PACKET(Packet),\r
-                            sizeof(NDIS_PACKET_OOB_DATA));\r
-                //\r
-                // Copy relevant parts of the per packet info into the new packet\r
-                //\r
-#ifndef WIN9X\r
-                NdisIMCopySendPerPacketInfo(MyPacket, Packet);\r
-#endif\r
-\r
-                //\r
-                // Copy the Media specific information\r
-                //\r
-                NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(Packet,\r
-                                                    &MediaSpecificInfo,\r
-                                                    &MediaSpecificInfoSize);\r
-\r
-                if (MediaSpecificInfo || MediaSpecificInfoSize)\r
-                {\r
-                    NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket,\r
-                                                        MediaSpecificInfo,\r
-                                                        MediaSpecificInfoSize);\r
-                }\r
-\r
-                NdisSend(&Status,\r
-                         pAdapt->BindingHandle,\r
-                         MyPacket);\r
-\r
-                if (Status != NDIS_STATUS_PENDING)\r
-                {\r
-#ifndef WIN9X\r
-                    NdisIMCopySendCompletePerPacketInfo (Packet, MyPacket);\r
-#endif\r
-                    NdisFreePacket(MyPacket);\r
-                    ADAPT_DECR_PENDING_SENDS(pAdapt);\r
-                }\r
-            }\r
-            else\r
-            {\r
-                //\r
-                // The driver cannot allocate a packet.\r
-                // \r
-                ADAPT_DECR_PENDING_SENDS(pAdapt);\r
-            }\r
-        }\r
-        while (FALSE);\r
-\r
-        if (Status != NDIS_STATUS_PENDING)\r
-        {\r
-            NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),\r
-                              Packet,\r
-                              Status);\r
-        }\r
-    }\r
-}\r
-\r
-\r
-NDIS_STATUS\r
-MPQueryInformation(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN NDIS_OID                   Oid,\r
-    IN PVOID                      InformationBuffer,\r
-    IN ULONG                      InformationBufferLength,\r
-    OUT PULONG                    BytesWritten,\r
-    OUT PULONG                    BytesNeeded\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Entry point called by NDIS to query for the value of the specified OID.\r
-    Typical processing is to forward the query down to the underlying miniport.\r
-\r
-    The following OIDs are filtered here:\r
-\r
-    OID_PNP_QUERY_POWER - return success right here\r
-\r
-    OID_GEN_SUPPORTED_GUIDS - do not forward, otherwise we will show up\r
-    multiple instances of private GUIDs supported by the underlying miniport.\r
-\r
-    OID_PNP_CAPABILITIES - we do send this down to the lower miniport, but\r
-    the values returned are postprocessed before we complete this request;\r
-    see PtRequestComplete.\r
-\r
-    NOTE on OID_TCP_TASK_OFFLOAD - if this IM driver modifies the contents\r
-    of data it passes through such that a lower miniport may not be able\r
-    to perform TCP task offload, then it should not forward this OID down,\r
-    but fail it here with the status NDIS_STATUS_NOT_SUPPORTED. This is to\r
-    avoid performing incorrect transformations on data.\r
-\r
-    If our miniport edge (upper edge) is at a low-power state, fail the request.\r
-\r
-    If our protocol edge (lower edge) has been notified of a low-power state,\r
-    we pend this request until the miniport below has been set to D0. Since\r
-    requests to miniports are serialized always, at most a single request will\r
-    be pended.\r
-\r
-Arguments:\r
-\r
-    MiniportAdapterContext    Pointer to the adapter structure\r
-    Oid                       Oid for this query\r
-    InformationBuffer         Buffer for information\r
-    InformationBufferLength   Size of this buffer\r
-    BytesWritten              Specifies how much info is written\r
-    BytesNeeded               In case the buffer is smaller than what we need, tell them how much is needed\r
-\r
-\r
-Return Value:\r
-\r
-    Return code from the NdisRequest below.\r
-\r
---*/\r
-{\r
-    PADAPT        pAdapt = (PADAPT)MiniportAdapterContext;\r
-    NDIS_STATUS   Status = NDIS_STATUS_FAILURE;\r
-\r
-    do\r
-    {\r
-        if (Oid == OID_PNP_QUERY_POWER)\r
-        {\r
-            //\r
-            //  Do not forward this.\r
-            //\r
-            Status = NDIS_STATUS_SUCCESS;\r
-            break;\r
-        }\r
-\r
-        if (Oid == OID_GEN_SUPPORTED_GUIDS)\r
-        {\r
-            //\r
-            //  Do not forward this, otherwise we will end up with multiple\r
-            //  instances of private GUIDs that the underlying miniport\r
-            //  supports.\r
-            //\r
-            Status = NDIS_STATUS_NOT_SUPPORTED;\r
-            break;\r
-        }\r
-\r
-        if (Oid == OID_TCP_TASK_OFFLOAD)\r
-        {\r
-            //\r
-            // Fail this -if- this driver performs data transformations\r
-            // that can interfere with a lower driver's ability to offload\r
-            // TCP tasks.\r
-            //\r
-            // Status = NDIS_STATUS_NOT_SUPPORTED;\r
-            // break;\r
-            //\r
-        }\r
-        //\r
-        // If the miniport below is unbinding, just fail any request\r
-        //\r
-        NdisAcquireSpinLock(&pAdapt->Lock);\r
-        if (pAdapt->UnbindingInProcess == TRUE)\r
-        {\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            Status = NDIS_STATUS_FAILURE;\r
-            break;\r
-        }\r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-        //\r
-        // All other queries are failed, if the miniport is not at D0,\r
-        //\r
-        if (pAdapt->MPDeviceState > NdisDeviceStateD0) \r
-        {\r
-            Status = NDIS_STATUS_FAILURE;\r
-            break;\r
-        }\r
-\r
-        pAdapt->Request.RequestType = NdisRequestQueryInformation;\r
-        pAdapt->Request.DATA.QUERY_INFORMATION.Oid = Oid;\r
-        pAdapt->Request.DATA.QUERY_INFORMATION.InformationBuffer = InformationBuffer;\r
-        pAdapt->Request.DATA.QUERY_INFORMATION.InformationBufferLength = InformationBufferLength;\r
-        pAdapt->BytesNeeded = BytesNeeded;\r
-        pAdapt->BytesReadOrWritten = BytesWritten;\r
-\r
-        //\r
-        // If the miniport below is binding, fail the request\r
-        //\r
-        NdisAcquireSpinLock(&pAdapt->Lock);\r
-            \r
-        if (pAdapt->UnbindingInProcess == TRUE)\r
-        {\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            Status = NDIS_STATUS_FAILURE;\r
-            break;\r
-        }\r
-        //\r
-        // If the Protocol device state is OFF, mark this request as being \r
-        // pended. We queue this until the device state is back to D0. \r
-        //\r
-        if ((pAdapt->PTDeviceState > NdisDeviceStateD0) \r
-                && (pAdapt->StandingBy == FALSE))\r
-        {\r
-            pAdapt->QueuedRequest = TRUE;\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            Status = NDIS_STATUS_PENDING;\r
-            break;\r
-        }\r
-        //\r
-        // This is in the process of powering down the system, always fail the request\r
-        // \r
-        if (pAdapt->StandingBy == TRUE)\r
-        {\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            Status = NDIS_STATUS_FAILURE;\r
-            break;\r
-        }\r
-        pAdapt->OutstandingRequests = TRUE;\r
-        \r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-\r
-        //\r
-        // default case, most requests will be passed to the miniport below\r
-        //\r
-        NdisRequest(&Status,\r
-                    pAdapt->BindingHandle,\r
-                    &pAdapt->Request);\r
-\r
-\r
-        if (Status != NDIS_STATUS_PENDING)\r
-        {\r
-            PtRequestComplete(pAdapt, &pAdapt->Request, Status);\r
-            Status = NDIS_STATUS_PENDING;\r
-        }\r
-\r
-    } while (FALSE);\r
-\r
-    return(Status);\r
-\r
-}\r
-\r
-\r
-VOID\r
-MPQueryPNPCapabilities(\r
-    IN OUT PADAPT            pAdapt,\r
-    OUT PNDIS_STATUS         pStatus\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Postprocess a request for OID_PNP_CAPABILITIES that was forwarded\r
-    down to the underlying miniport, and has been completed by it.\r
-\r
-Arguments:\r
-\r
-    pAdapt - Pointer to the adapter structure\r
-    pStatus - Place to return final status\r
-\r
-Return Value:\r
-\r
-    None.\r
-\r
---*/\r
-\r
-{\r
-    PNDIS_PNP_CAPABILITIES           pPNPCapabilities;\r
-    PNDIS_PM_WAKE_UP_CAPABILITIES    pPMstruct;\r
-\r
-    if (pAdapt->Request.DATA.QUERY_INFORMATION.InformationBufferLength >= sizeof(NDIS_PNP_CAPABILITIES))\r
-    {\r
-        pPNPCapabilities = (PNDIS_PNP_CAPABILITIES)(pAdapt->Request.DATA.QUERY_INFORMATION.InformationBuffer);\r
-\r
-        //\r
-        // The following fields must be overwritten by an IM driver.\r
-        //\r
-        pPMstruct= & pPNPCapabilities->WakeUpCapabilities;\r
-        pPMstruct->MinMagicPacketWakeUp = NdisDeviceStateUnspecified;\r
-        pPMstruct->MinPatternWakeUp = NdisDeviceStateUnspecified;\r
-        pPMstruct->MinLinkChangeWakeUp = NdisDeviceStateUnspecified;\r
-        *pAdapt->BytesReadOrWritten = sizeof(NDIS_PNP_CAPABILITIES);\r
-        *pAdapt->BytesNeeded = 0;\r
-\r
-\r
-        //\r
-        // Setting our internal flags\r
-        // Default, device is ON\r
-        //\r
-        pAdapt->MPDeviceState = NdisDeviceStateD0;\r
-        pAdapt->PTDeviceState = NdisDeviceStateD0;\r
-\r
-        *pStatus = NDIS_STATUS_SUCCESS;\r
-    }\r
-    else\r
-    {\r
-        *pAdapt->BytesNeeded= sizeof(NDIS_PNP_CAPABILITIES);\r
-        *pStatus = NDIS_STATUS_RESOURCES;\r
-    }\r
-}\r
-\r
-\r
-NDIS_STATUS\r
-MPSetInformation(\r
-    IN NDIS_HANDLE                                  MiniportAdapterContext,\r
-    IN NDIS_OID                                     Oid,\r
-    __in_bcount(InformationBufferLength) IN PVOID   InformationBuffer,\r
-    IN ULONG                                        InformationBufferLength,\r
-    OUT PULONG                                      BytesRead,\r
-    OUT PULONG                                      BytesNeeded\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Miniport SetInfo handler.\r
-\r
-    In the case of OID_PNP_SET_POWER, record the power state and return the OID.    \r
-    Do not pass below\r
-    If the device is suspended, do not block the SET_POWER_OID \r
-    as it is used to reactivate the Passthru miniport\r
-\r
-    \r
-    PM- If the MP is not ON (DeviceState > D0) return immediately  (except for 'query power' and 'set power')\r
-         If MP is ON, but the PT is not at D0, then queue the queue the request for later processing\r
-\r
-    Requests to miniports are always serialized\r
-\r
-\r
-Arguments:\r
-\r
-    MiniportAdapterContext    Pointer to the adapter structure\r
-    Oid                       Oid for this query\r
-    InformationBuffer         Buffer for information\r
-    InformationBufferLength   Size of this buffer\r
-    BytesRead                 Specifies how much info is read\r
-    BytesNeeded               In case the buffer is smaller than what we need, tell them how much is needed\r
-\r
-Return Value:\r
-\r
-    Return code from the NdisRequest below.\r
-\r
---*/\r
-{\r
-    PADAPT        pAdapt = (PADAPT)MiniportAdapterContext;\r
-    NDIS_STATUS   Status;\r
-\r
-    Status = NDIS_STATUS_FAILURE;\r
-\r
-    do\r
-    {\r
-        //\r
-        // The Set Power should not be sent to the miniport below the Passthru, but is handled internally\r
-        //\r
-        if (Oid == OID_PNP_SET_POWER)\r
-        {\r
-            MPProcessSetPowerOid(&Status, \r
-                                 pAdapt, \r
-                                 InformationBuffer, \r
-                                 InformationBufferLength, \r
-                                 BytesRead, \r
-                                 BytesNeeded);\r
-            break;\r
-\r
-        }\r
-\r
-        //\r
-        // If the miniport below is unbinding, fail the request\r
-        //\r
-        NdisAcquireSpinLock(&pAdapt->Lock);     \r
-        if (pAdapt->UnbindingInProcess == TRUE)\r
-        {\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            Status = NDIS_STATUS_FAILURE;\r
-            break;\r
-        }\r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-        //\r
-        // All other Set Information requests are failed, if the miniport is\r
-        // not at D0 or is transitioning to a device state greater than D0.\r
-        //\r
-        if (pAdapt->MPDeviceState > NdisDeviceStateD0)\r
-        {\r
-            Status = NDIS_STATUS_FAILURE;\r
-            break;\r
-        }\r
-\r
-        // Set up the Request and return the result\r
-        pAdapt->Request.RequestType = NdisRequestSetInformation;\r
-        pAdapt->Request.DATA.SET_INFORMATION.Oid = Oid;\r
-        pAdapt->Request.DATA.SET_INFORMATION.InformationBuffer = InformationBuffer;\r
-        pAdapt->Request.DATA.SET_INFORMATION.InformationBufferLength = InformationBufferLength;\r
-        pAdapt->BytesNeeded = BytesNeeded;\r
-        pAdapt->BytesReadOrWritten = BytesRead;\r
-\r
-        //\r
-        // If the miniport below is unbinding, fail the request\r
-        //\r
-        NdisAcquireSpinLock(&pAdapt->Lock);     \r
-        if (pAdapt->UnbindingInProcess == TRUE)\r
-        {\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            Status = NDIS_STATUS_FAILURE;\r
-            break;\r
-        }\r
-            \r
-        //\r
-        // If the device below is at a low power state, we cannot send it the\r
-        // request now, and must pend it.\r
-        //\r
-        if ((pAdapt->PTDeviceState > NdisDeviceStateD0) \r
-                && (pAdapt->StandingBy == FALSE))\r
-        {\r
-            pAdapt->QueuedRequest = TRUE;\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            Status = NDIS_STATUS_PENDING;\r
-            break;\r
-        }\r
-        //\r
-        // This is in the process of powering down the system, always fail the request\r
-        // \r
-        if (pAdapt->StandingBy == TRUE)\r
-        {\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            Status = NDIS_STATUS_FAILURE;\r
-            break;\r
-        }\r
-        pAdapt->OutstandingRequests = TRUE;\r
-        \r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-        //\r
-        // Forward the request to the device below.\r
-        //\r
-        NdisRequest(&Status,\r
-                    pAdapt->BindingHandle,\r
-                    &pAdapt->Request);\r
-\r
-        if (Status != NDIS_STATUS_PENDING)\r
-        {\r
-            *BytesRead = pAdapt->Request.DATA.SET_INFORMATION.BytesRead;\r
-            *BytesNeeded = pAdapt->Request.DATA.SET_INFORMATION.BytesNeeded;\r
-            pAdapt->OutstandingRequests = FALSE;\r
-        }\r
-\r
-    } while (FALSE);\r
-\r
-    return(Status);\r
-}\r
-\r
-\r
-VOID\r
-MPProcessSetPowerOid(\r
-    IN OUT PNDIS_STATUS                             pNdisStatus,\r
-    IN PADAPT                                       pAdapt,\r
-    __in_bcount(InformationBufferLength) IN PVOID   InformationBuffer,\r
-    IN ULONG                                        InformationBufferLength,\r
-    OUT PULONG                                      BytesRead,\r
-    OUT PULONG                                      BytesNeeded\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-    This routine does all the procssing for a request with a SetPower Oid\r
-    The miniport shoud accept  the Set Power and transition to the new state\r
-\r
-    The Set Power should not be passed to the miniport below\r
-\r
-    If the IM miniport is going into a low power state, then there is no guarantee if it will ever\r
-    be asked go back to D0, before getting halted. No requests should be pended or queued.\r
-\r
-    \r
-Arguments:\r
-    pNdisStatus           - Status of the operation\r
-    pAdapt                - The Adapter structure\r
-    InformationBuffer     - The New DeviceState\r
-    InformationBufferLength\r
-    BytesRead             - No of bytes read\r
-    BytesNeeded           -  No of bytes needed\r
-\r
-\r
-Return Value:\r
-    Status  - NDIS_STATUS_SUCCESS if all the wait events succeed.\r
-\r
---*/\r
-{\r
-\r
-    \r
-    NDIS_DEVICE_POWER_STATE NewDeviceState;\r
-\r
-    DBGPRINT(("==>MPProcessSetPowerOid: Adapt %p\n", pAdapt)); \r
-\r
-    ASSERT (InformationBuffer != NULL);\r
-\r
-    *pNdisStatus = NDIS_STATUS_FAILURE;\r
-\r
-    do \r
-    {\r
-        //\r
-        // Check for invalid length\r
-        //\r
-        if (InformationBufferLength < sizeof(NDIS_DEVICE_POWER_STATE))\r
-        {\r
-            *pNdisStatus = NDIS_STATUS_INVALID_LENGTH;\r
-            break;\r
-        }\r
-\r
-        NewDeviceState = (*(PNDIS_DEVICE_POWER_STATE)InformationBuffer);\r
-\r
-        //\r
-        // Check for invalid device state\r
-        //\r
-        if ((pAdapt->MPDeviceState > NdisDeviceStateD0) && (NewDeviceState != NdisDeviceStateD0))\r
-        {\r
-            //\r
-            // If the miniport is in a non-D0 state, the miniport can only receive a Set Power to D0\r
-            //\r
-            ASSERT (!(pAdapt->MPDeviceState > NdisDeviceStateD0) && (NewDeviceState != NdisDeviceStateD0));\r
-\r
-            *pNdisStatus = NDIS_STATUS_FAILURE;\r
-            break;\r
-        }    \r
-\r
-        //\r
-        // Is the miniport transitioning from an On (D0) state to an Low Power State (>D0)\r
-        // If so, then set the StandingBy Flag - (Block all incoming requests)\r
-        //\r
-        if (pAdapt->MPDeviceState == NdisDeviceStateD0 && NewDeviceState > NdisDeviceStateD0)\r
-        {\r
-            pAdapt->StandingBy = TRUE;\r
-        }\r
-\r
-        //\r
-        // If the miniport is transitioning from a low power state to ON (D0), then clear the StandingBy flag\r
-        // All incoming requests will be pended until the physical miniport turns ON.\r
-        //\r
-        if (pAdapt->MPDeviceState > NdisDeviceStateD0 &&  NewDeviceState == NdisDeviceStateD0)\r
-        {\r
-            pAdapt->StandingBy = FALSE;\r
-        }\r
-        \r
-        //\r
-        // Now update the state in the pAdapt structure;\r
-        //\r
-        pAdapt->MPDeviceState = NewDeviceState;\r
-        \r
-        *pNdisStatus = NDIS_STATUS_SUCCESS;\r
-    \r
-\r
-    } while (FALSE);    \r
-        \r
-    if (*pNdisStatus == NDIS_STATUS_SUCCESS)\r
-    {\r
-        //\r
-        // The miniport resume from low power state\r
-        // \r
-        if (pAdapt->StandingBy == FALSE)\r
-        {\r
-            //\r
-            // If we need to indicate the media connect state\r
-            // \r
-            if (pAdapt->LastIndicatedStatus != pAdapt->LatestUnIndicateStatus)\r
-            {\r
-               if (pAdapt->MiniportHandle != NULL)\r
-               {\r
-                   NdisMIndicateStatus(pAdapt->MiniportHandle,\r
-                                            pAdapt->LatestUnIndicateStatus,\r
-                                            (PVOID)NULL,\r
-                                            0);\r
-                   NdisMIndicateStatusComplete(pAdapt->MiniportHandle);\r
-                   pAdapt->LastIndicatedStatus = pAdapt->LatestUnIndicateStatus;\r
-               }\r
-            }\r
-        }\r
-        else\r
-        {\r
-            //\r
-            // Initialize LatestUnIndicatedStatus\r
-            //\r
-            pAdapt->LatestUnIndicateStatus = pAdapt->LastIndicatedStatus;\r
-        }\r
-        *BytesRead = sizeof(NDIS_DEVICE_POWER_STATE);\r
-        *BytesNeeded = 0;\r
-    }\r
-    else\r
-    {\r
-        *BytesRead = 0;\r
-        *BytesNeeded = sizeof (NDIS_DEVICE_POWER_STATE);\r
-    }\r
-\r
-    DBGPRINT(("<==MPProcessSetPowerOid: Adapt %p\n", pAdapt)); \r
-}\r
-\r
-\r
-VOID\r
-MPReturnPacket(\r
-    IN NDIS_HANDLE             MiniportAdapterContext,\r
-    IN PNDIS_PACKET            Packet\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    NDIS Miniport entry point called whenever protocols are done with\r
-    a packet that we had indicated up and they had queued up for returning\r
-    later.\r
-\r
-Arguments:\r
-\r
-    MiniportAdapterContext    - pointer to ADAPT structure\r
-    Packet    - packet being returned.\r
-\r
-Return Value:\r
-\r
-    None.\r
-\r
---*/\r
-{\r
-    PADAPT            pAdapt = (PADAPT)MiniportAdapterContext;\r
-\r
-#ifdef NDIS51\r
-    //\r
-    // Packet stacking: Check if this packet belongs to us.\r
-    //\r
-    if (NdisGetPoolFromPacket(Packet) != pAdapt->RecvPacketPoolHandle)\r
-    {\r
-        //\r
-        // We reused the original packet in a receive indication.\r
-        // Simply return it to the miniport below us.\r
-        //\r
-        NdisReturnPackets(&Packet, 1);\r
-    }\r
-    else\r
-#endif // NDIS51\r
-    {\r
-        //\r
-        // This is a packet allocated from this IM's receive packet pool.\r
-        // Reclaim our packet, and return the original to the driver below.\r
-        //\r
-\r
-        PNDIS_PACKET    MyPacket;\r
-        PRECV_RSVD      RecvRsvd;\r
-    \r
-        RecvRsvd = (PRECV_RSVD)(Packet->MiniportReserved);\r
-        MyPacket = RecvRsvd->OriginalPkt;\r
-    \r
-        NdisFreePacket(Packet);\r
-        NdisReturnPackets(&MyPacket, 1);\r
-    }\r
-}\r
-\r
-\r
-NDIS_STATUS\r
-MPTransferData(\r
-    OUT PNDIS_PACKET            Packet,\r
-    OUT PUINT                   BytesTransferred,\r
-    IN NDIS_HANDLE              MiniportAdapterContext,\r
-    IN NDIS_HANDLE              MiniportReceiveContext,\r
-    IN UINT                     ByteOffset,\r
-    IN UINT                     BytesToTransfer\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Miniport's transfer data handler.\r
-\r
-Arguments:\r
-\r
-    Packet                    Destination packet\r
-    BytesTransferred          Place-holder for how much data was copied\r
-    MiniportAdapterContext    Pointer to the adapter structure\r
-    MiniportReceiveContext    Context\r
-    ByteOffset                Offset into the packet for copying data\r
-    BytesToTransfer           How much to copy.\r
-\r
-Return Value:\r
-\r
-    Status of transfer\r
-\r
---*/\r
-{\r
-    PADAPT        pAdapt = (PADAPT)MiniportAdapterContext;\r
-    NDIS_STATUS   Status;\r
-\r
-    //\r
-    // Return, if the device is OFF\r
-    //\r
-\r
-    if (IsIMDeviceStateOn(pAdapt) == FALSE)\r
-    {\r
-        return NDIS_STATUS_FAILURE;\r
-    }\r
-\r
-    NdisTransferData(&Status,\r
-                     pAdapt->BindingHandle,\r
-                     MiniportReceiveContext,\r
-                     ByteOffset,\r
-                     BytesToTransfer,\r
-                     Packet,\r
-                     BytesTransferred);\r
-\r
-    return(Status);\r
-}\r
-\r
-VOID\r
-MPHalt(\r
-    IN NDIS_HANDLE                MiniportAdapterContext\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Halt handler. All the hard-work for clean-up is done here.\r
-\r
-Arguments:\r
-\r
-    MiniportAdapterContext    Pointer to the Adapter\r
-\r
-Return Value:\r
-\r
-    None.\r
-\r
---*/\r
-{\r
-    PADAPT             pAdapt = (PADAPT)MiniportAdapterContext;\r
-    NDIS_STATUS        Status;\r
-    PADAPT            *ppCursor;\r
-\r
-    DBGPRINT(("==>MiniportHalt: Adapt %p\n", pAdapt));\r
-\r
-    pAdapt->MiniportHandle = NULL;\r
-    pAdapt->MiniportIsHalted = TRUE;\r
-\r
-    //\r
-    // Remove this adapter from the global list\r
-    //\r
-    NdisAcquireSpinLock(&GlobalLock);\r
-\r
-    for (ppCursor = &pAdaptList; *ppCursor != NULL; ppCursor = &(*ppCursor)->Next)\r
-    {\r
-        if (*ppCursor == pAdapt)\r
-        {\r
-            *ppCursor = pAdapt->Next;\r
-            break;\r
-        }\r
-    }\r
-\r
-    NdisReleaseSpinLock(&GlobalLock);\r
-\r
-    //\r
-    // Delete the ioctl interface that was created when the miniport\r
-    // was created.\r
-    //\r
-    (VOID)PtDeregisterDevice();\r
-\r
-    //\r
-    // If we have a valid bind, close the miniport below the protocol\r
-    //\r
-#pragma prefast(suppress: __WARNING_DEREF_NULL_PTR, "pAdapt cannot be NULL")\r
-    if (pAdapt->BindingHandle != NULL)\r
-    {\r
-        //\r
-        // Close the binding below. and wait for it to complete\r
-        //\r
-        NdisResetEvent(&pAdapt->Event);\r
-\r
-        NdisCloseAdapter(&Status, pAdapt->BindingHandle);\r
-\r
-        if (Status == NDIS_STATUS_PENDING)\r
-        {\r
-            NdisWaitEvent(&pAdapt->Event, 0);\r
-            Status = pAdapt->Status;\r
-        }\r
-\r
-        ASSERT (Status == NDIS_STATUS_SUCCESS);\r
-\r
-        pAdapt->BindingHandle = NULL;\r
-        \r
-        PtDereferenceAdapt(pAdapt);\r
-    }\r
-\r
-    if (PtDereferenceAdapt(pAdapt))\r
-    {\r
-        pAdapt = NULL;\r
-    }\r
-        \r
-    \r
-    DBGPRINT(("<== MiniportHalt: pAdapt %p\n", pAdapt));\r
-}\r
-\r
-\r
-#ifdef NDIS51_MINIPORT\r
-\r
-VOID\r
-MPCancelSendPackets(\r
-    IN NDIS_HANDLE            MiniportAdapterContext,\r
-    IN PVOID                  CancelId\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    The miniport entry point to handle cancellation of all send packets\r
-    that match the given CancelId. If we have queued any packets that match\r
-    this, then we should dequeue them and call NdisMSendComplete for all\r
-    such packets, with a status of NDIS_STATUS_REQUEST_ABORTED.\r
-\r
-    We should also call NdisCancelSendPackets in turn, on each lower binding\r
-    that this adapter corresponds to. This is to let miniports below cancel\r
-    any matching packets.\r
-\r
-Arguments:\r
-\r
-    MiniportAdapterContext    - pointer to ADAPT structure\r
-    CancelId    - ID of packets to be cancelled.\r
-\r
-Return Value:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-    PADAPT    pAdapt = (PADAPT)MiniportAdapterContext;\r
-\r
-    //\r
-    // If we queue packets on our adapter structure, this would be \r
-    // the place to acquire a spinlock to it, unlink any packets whose\r
-    // Id matches CancelId, release the spinlock and call NdisMSendComplete\r
-    // with NDIS_STATUS_REQUEST_ABORTED for all unlinked packets.\r
-    //\r
-\r
-    //\r
-    // Next, pass this down so that we let the miniport(s) below cancel\r
-    // any packets that they might have queued.\r
-    //\r
-    NdisCancelSendPackets(pAdapt->BindingHandle, CancelId);\r
-\r
-    return;\r
-}\r
-\r
-VOID\r
-MPDevicePnPEvent(\r
-    IN NDIS_HANDLE              MiniportAdapterContext,\r
-    IN NDIS_DEVICE_PNP_EVENT    DevicePnPEvent,\r
-    IN PVOID                    InformationBuffer,\r
-    IN ULONG                    InformationBufferLength\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    This handler is called to notify us of PnP events directed to\r
-    our miniport device object.\r
-\r
-Arguments:\r
-\r
-    MiniportAdapterContext    - pointer to ADAPT structure\r
-    DevicePnPEvent - the event\r
-    InformationBuffer - Points to additional event-specific information\r
-    InformationBufferLength - length of above\r
-\r
-Return Value:\r
-\r
-    None\r
---*/\r
-{\r
-    // TBD - add code/comments about processing this.\r
-\r
-    UNREFERENCED_PARAMETER(MiniportAdapterContext);\r
-    UNREFERENCED_PARAMETER(DevicePnPEvent);\r
-    UNREFERENCED_PARAMETER(InformationBuffer);\r
-    UNREFERENCED_PARAMETER(InformationBufferLength);\r
-    \r
-    return;\r
-}\r
-\r
-VOID\r
-MPAdapterShutdown(\r
-    IN NDIS_HANDLE                MiniportAdapterContext\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    This handler is called to notify us of an impending system shutdown.\r
-\r
-Arguments:\r
-\r
-    MiniportAdapterContext    - pointer to ADAPT structure\r
-\r
-Return Value:\r
-\r
-    None\r
---*/\r
-{\r
-    UNREFERENCED_PARAMETER(MiniportAdapterContext);\r
-    \r
-    return;\r
-}\r
-\r
-#endif\r
-\r
-\r
-VOID\r
-MPFreeAllPacketPools(\r
-    IN PADAPT                    pAdapt\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Free all packet pools on the specified adapter.\r
-    \r
-Arguments:\r
-\r
-    pAdapt    - pointer to ADAPT structure\r
-\r
-Return Value:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-    if (pAdapt->RecvPacketPoolHandle != NULL)\r
-    {\r
-        //\r
-        // Free the packet pool that is used to indicate receives\r
-        //\r
-        NdisFreePacketPool(pAdapt->RecvPacketPoolHandle);\r
-\r
-        pAdapt->RecvPacketPoolHandle = NULL;\r
-    }\r
-\r
-    if (pAdapt->SendPacketPoolHandle != NULL)\r
-    {\r
-\r
-        //\r
-        //  Free the packet pool that is used to send packets below\r
-        //\r
-\r
-        NdisFreePacketPool(pAdapt->SendPacketPoolHandle);\r
-\r
-        pAdapt->SendPacketPoolHandle = NULL;\r
-\r
-    }\r
-}\r
-\r
diff --git a/original_passthru/netsf.inf b/original_passthru/netsf.inf
deleted file mode 100644 (file)
index 5e03a01..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-; -- NETSF.INF --\r
-;\r
-; Passthru driver INF file - this is the INF for the service (protocol)\r
-; part.\r
-;\r
-; Copyright (c) 1993-2001, Microsoft Corporation\r
-;\r
-; ----------------------------------------------------------------------\r
-; Notes:\r
-; 0. The term "filter" is used in this INF to refer to an NDIS IM driver that\r
-;    implements a 1:1 relationship between upper and lower bindings.\r
-;\r
-; 1. Items specifically required for a filter have been marked with\r
-;    "!!--Filter Specific--!!" keyword\r
-; 2. In general a filter DOES NOT require a notify object for proper installation.\r
-;    A notify object is only required if one wants to have better control\r
-;    over binding operations or if one wants to receive notifications\r
-;    when other components get installed/removed/bound/unbound.\r
-;    Since Windows 2000 systems do not have support for CopyINF directive,\r
-;    a notify object is required to programmatically copy the miniport INF  \r
-;    file to the system INF directory. Previous versions of this INF file\r
-;    erroneously used to copy the INF files directly by using the CopyFiles \r
-;    directive.\r
-;    On Windows XP, you can install a filter IM without a notify object.\r
-;    by following the instructions in (4).\r
-;\r
-; 3. If you want to use this INF file with your own IM driver, please\r
-;    make the following modifications:\r
-;    File netsf.inf\r
-;    --------------\r
-;    a. In section [SourceDiskFiles] and [Passthru.Files.Sys]\r
-;       change passthru.sys to the name of your own driver binary.\r
-;    b. In section [Passthru.ndi.AddReg], change values of\r
-;       BindForm and MiniportId to appropriate values.\r
-;    File netsf_m.inf\r
-;    ----------------\r
-;    a. Replace MS_PassthruMP with InfId of your miniport.\r
-;    b. In section [PassthruMP.AddService],\r
-;       change ServiceBinary appropriately.\r
-;    c. In section [PassthruMP.ndi.AddReg],\r
-;       change "Passthru" in the line having "Service"\r
-;       to reflect the appropriate name\r
-;\r
-;\r
-; ----------------------------------------------------------------------\r
-\r
-[Version]\r
-Signature  = "$Windows NT$"\r
-Class      = NetService\r
-ClassGUID  = {4D36E974-E325-11CE-BFC1-08002BE10318}\r
-Provider   = %Msft%\r
-DriverVer  =10/01/2002,6.0.5019.0\r
-\r
-[Manufacturer]\r
-%Msft% = MSFT,NTx86,NTia64,NTamd64\r
-\r
-[ControlFlags]\r
-\r
-;=========================================================================\r
-;\r
-;=========================================================================\r
-;For Win2K\r
-\r
-[MSFT]\r
-%Passthru_Desc% = Passthru.ndi, ms_passthru\r
\r
-;For WinXP and later\r
-\r
-[MSFT.NTx86]\r
-%Passthru_Desc% = Passthru.ndi, ms_passthru\r
-\r
-[MSFT.NTia64]\r
-%Passthru_Desc% = Passthru.ndi, ms_passthru\r
-\r
-[MSFT.NTamd64]\r
-%Passthru_Desc% = Passthru.ndi, ms_passthru\r
-\r
-\r
-[Passthru.ndi]\r
-AddReg          = Passthru.ndi.AddReg, Passthru.AddReg\r
-Characteristics = 0x4410 ;  NCF_FILTER | NCF_NDIS_PROTOCOL !--Filter Specific--!!\r
-CopyFiles       = Passthru.Files.Sys\r
-CopyInf         = netsf_m.inf\r
-\r
-[Passthru.ndi.Remove]\r
-DelFiles = Passthru.Files.Sys\r
-\r
-[Passthru.ndi.Services]\r
-AddService = Passthru,, Passthru.AddService\r
-\r
-[Passthru.AddService]\r
-DisplayName    = %PassthruService_Desc%\r
-ServiceType    = 1 ;SERVICE_KERNEL_DRIVER\r
-StartType      = 3 ;SERVICE_DEMAND_START\r
-ErrorControl   = 1 ;SERVICE_ERROR_NORMAL\r
-ServiceBinary  = %12%\passthru.sys\r
-AddReg         = Passthru.AddService.AddReg\r
-\r
-\r
-[Passthru.AddService.AddReg]\r
-; ----------------------------------------------------------------------\r
-; Add any miniport-specific parameters here.  These are params that your\r
-; filter device is going to use.\r
-;\r
-;HKR, Parameters, ParameterName,  0x10000, "MultiSz", "Parameter", "Value"\r
-;HKR, Parameters, ParameterName2, 0x10001, 4\r
-\r
-\r
-; ----------------------------------------------------------------------\r
-; File copy\r
-;\r
-[SourceDisksNames]\r
-1=%DiskDescription%,"",,\r
-\r
-[SourceDisksFiles]\r
-passthru.sys=1\r
-\r
-[DestinationDirs]\r
-DefaultDestDir = 12\r
-Passthru.Files.Sys   = 12   ; %windir%\System32\drivers\r
-\r
-[Passthru.Files.Sys]\r
-passthru.sys,,,2\r
-\r
-; ----------------------------------------------------------------------\r
-; Filter Install\r
-;\r
-\r
-[Passthru.ndi.AddReg]\r
-HKR, Ndi, HelpText, , %Passthru_HELP%\r
-\r
-; ----------------------------------------------------------------------\r
-; !!--Filter Specific--!!\r
-;\r
-; Note:\r
-; 1. Other components may also have UpperRange/LowerRange but for filters\r
-;    the value of both of them must be noupper/nolower\r
-; 2. The value FilterClass is required.\r
-; 3. The value Service is required\r
-; 4. FilterDeviceInfId is the InfId of the filter device (miniport) that will\r
-;    be installed for each filtered adapter.\r
-;    In this case this is ms_passthrump (refer to netsf_m.inf)\r
-;\r
-HKR, Ndi,            FilterClass,         , failover\r
-HKR, Ndi,            FilterDeviceInfId,   , ms_passthrump\r
-HKR, Ndi,            Service,             , Passthru\r
-HKR, Ndi\Interfaces, UpperRange,          , noupper\r
-HKR, Ndi\Interfaces, LowerRange,          , nolower\r
-HKR, Ndi\Interfaces, FilterMediaTypes,    , "ethernet, tokenring, fddi, wan"\r
-\r
-[Passthru.AddReg]\r
-; The following key is Required\r
-; The following key is Passthru specific\r
-HKR, Parameters, Param1, 0, 4\r
-\r
-; ----------------------------------------------------------------------\r
-[Strings]\r
-Msft = "Microsoft"\r
-DiskDescription = "Microsoft Passthru Driver Disk"\r
-\r
-Passthru_Desc = "Passthru Driver"\r
-Passthru_HELP = "Passthru Driver"\r
-PassthruService_Desc = "Passthru Service"\r
-\r
-\r
diff --git a/original_passthru/netsf_m.inf b/original_passthru/netsf_m.inf
deleted file mode 100644 (file)
index 6605a02..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-; -- NETSF_M.INF --\r
-;\r
-; Passsthru Miniport INF file\r
-;\r
-; Copyright (c) 1993-1999, Microsoft Corporation\r
-\r
-; ----------------------------------------------------------------------\r
-; Notes:\r
-; 0. The term "filter" is used here to refer to an NDIS IM driver that\r
-;    implements a 1:1 relationship between upper and lower bindings.\r
-; 1. Items specifically required for a filter have been marked with\r
-;    "!!--Filter Specific--!!" keyword\r
-; 2. A filter DOES NOT require a notify object for proper installation.\r
-;    A notify object is only required if one wants to have better control\r
-;    over binding operations or if one wants to receive notifications\r
-;    when other components get installed/removed/bound/unbound.\r
-;    This sample uses a notify object as an example only. If you do not\r
-;    want to use a notify object, please comment out the lines that add\r
-;    ClsId and ComponentDll registry keys.\r
-; ----------------------------------------------------------------------\r
-\r
-[Version]\r
-signature  = "$Windows NT$"\r
-Class      = Net\r
-ClassGUID  = {4d36e972-e325-11ce-bfc1-08002be10318}\r
-Provider   = %Msft%\r
-DriverVer  =10/01/2002,6.0.5019.0\r
-\r
-[ControlFlags]\r
-ExcludeFromSelect = ms_passthrump\r
-\r
-[DestinationDirs]\r
-DefaultDestDir=12\r
-; No files to copy \r
-\r
-[Manufacturer]\r
-%Msft% = MSFT,NTx86,NTia64,NTamd64\r
-\r
-;For Win2K\r
-\r
-[MSFT]\r
-%PassthruMP_Desc% = PassthruMP.ndi, ms_passthrump\r
-\r
-;For WinXP and later\r
-\r
-[MSFT.NTx86]\r
-%PassthruMP_Desc% = PassthruMP.ndi, ms_passthrump\r
-\r
-[MSFT.NTia64]\r
-%PassthruMP_Desc% = PassthruMP.ndi, ms_passthrump\r
-\r
-[MSFT.NTamd64]\r
-%PassthruMP_Desc% = PassthruMP.ndi, ms_passthrump\r
-\r
-\r
-[PassthruMP.ndi]\r
-AddReg  = PassthruMP.ndi.AddReg\r
-Characteristics = 0x29 ;NCF_NOT_USER_REMOVABLE | NCF_VIRTUAL | NCF_HIDDEN\r
-\r
-[PassthruMP.ndi.AddReg]\r
-HKR, Ndi, Service,  0,  PassthruMP\r
-\r
-[PassthruMP.ndi.Services]\r
-AddService = PassthruMP,0x2, PassthruMP.AddService\r
-\r
-\r
-[PassthruMP.AddService]\r
-ServiceType    = 1 ;SERVICE_KERNEL_DRIVER\r
-StartType      = 3 ;SERVICE_DEMAND_START\r
-ErrorControl   = 1 ;SERVICE_ERROR_NORMAL\r
-ServiceBinary  = %12%\passthru.sys\r
-AddReg         = PassthruMP.AddService.AddReg\r
-\r
-\r
-[PassthruMP.AddService.AddReg]\r
-; ----------------------------------------------------------------------\r
-; Add any miniport-specific parameters here.  These are params that your\r
-; filter device is going to use.\r
-;\r
-;HKR, Parameters, ParameterName,  0x10000, "MultiSz", "Parameter", "Value"\r
-;HKR, Parameters, ParameterName2, 0x10001, 4\r
-\r
-[Strings]\r
-Msft = "Microsoft"\r
-PassthruMP_Desc = "Passthru Miniport"\r
-\r
-[SourceDisksNames]\r
-;None \r
-\r
-[SourceDisksFiles]\r
-;None\r
-\r
-\r
diff --git a/original_passthru/passthru.c b/original_passthru/passthru.c
deleted file mode 100644 (file)
index f614f2a..0000000
+++ /dev/null
@@ -1,458 +0,0 @@
-/*++\r
-\r
-Copyright (c) 1992-2000  Microsoft Corporation\r
\r
-Module Name:\r
\r
-    passthru.c\r
-\r
-Abstract:\r
-\r
-    Ndis Intermediate Miniport driver sample. This is a passthru driver.\r
-\r
-Author:\r
-\r
-Environment:\r
-\r
-\r
-Revision History:\r
-\r
-\r
---*/\r
-\r
-\r
-#include "precomp.h"\r
-#pragma hdrstop\r
-\r
-#pragma NDIS_INIT_FUNCTION(DriverEntry)\r
-\r
-NDIS_HANDLE         ProtHandle = NULL;\r
-NDIS_HANDLE         DriverHandle = NULL;\r
-NDIS_MEDIUM         MediumArray[4] =\r
-                    {\r
-                        NdisMedium802_3,    // Ethernet\r
-                        NdisMedium802_5,    // Token-ring\r
-                        NdisMediumFddi,     // Fddi\r
-                        NdisMediumWan       // NDISWAN\r
-                    };\r
-\r
-NDIS_SPIN_LOCK     GlobalLock;\r
-\r
-PADAPT             pAdaptList = NULL;\r
-LONG               MiniportCount = 0;\r
-\r
-NDIS_HANDLE        NdisWrapperHandle;\r
-\r
-//\r
-// To support ioctls from user-mode:\r
-//\r
-\r
-#define LINKNAME_STRING     L"\\DosDevices\\Passthru"\r
-#define NTDEVICE_STRING     L"\\Device\\Passthru"\r
-\r
-NDIS_HANDLE     NdisDeviceHandle = NULL;\r
-PDEVICE_OBJECT  ControlDeviceObject = NULL;\r
-\r
-enum _DEVICE_STATE\r
-{\r
-    PS_DEVICE_STATE_READY = 0,    // ready for create/delete\r
-    PS_DEVICE_STATE_CREATING,    // create operation in progress\r
-    PS_DEVICE_STATE_DELETING    // delete operation in progress\r
-} ControlDeviceState = PS_DEVICE_STATE_READY;\r
-\r
-\r
-\r
-NTSTATUS\r
-DriverEntry(\r
-    IN PDRIVER_OBJECT        DriverObject,\r
-    IN PUNICODE_STRING       RegistryPath\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    First entry point to be called, when this driver is loaded.\r
-    Register with NDIS as an intermediate driver.\r
-\r
-Arguments:\r
-\r
-    DriverObject - pointer to the system's driver object structure\r
-        for this driver\r
-    \r
-    RegistryPath - system's registry path for this driver\r
-    \r
-Return Value:\r
-\r
-    STATUS_SUCCESS if all initialization is successful, STATUS_XXX\r
-    error code if not.\r
-\r
---*/\r
-{\r
-    NDIS_STATUS                        Status;\r
-    NDIS_PROTOCOL_CHARACTERISTICS      PChars;\r
-    NDIS_MINIPORT_CHARACTERISTICS      MChars;\r
-    NDIS_STRING                        Name;\r
-\r
-    Status = NDIS_STATUS_SUCCESS;\r
-    NdisAllocateSpinLock(&GlobalLock);\r
-\r
-    NdisMInitializeWrapper(&NdisWrapperHandle, DriverObject, RegistryPath, NULL);\r
-\r
-    do\r
-    {\r
-        //\r
-        // Register the miniport with NDIS. Note that it is the miniport\r
-        // which was started as a driver and not the protocol. Also the miniport\r
-        // must be registered prior to the protocol since the protocol's BindAdapter\r
-        // handler can be initiated anytime and when it is, it must be ready to\r
-        // start driver instances.\r
-        //\r
-\r
-        NdisZeroMemory(&MChars, sizeof(NDIS_MINIPORT_CHARACTERISTICS));\r
-\r
-        MChars.MajorNdisVersion = PASSTHRU_MAJOR_NDIS_VERSION;\r
-        MChars.MinorNdisVersion = PASSTHRU_MINOR_NDIS_VERSION;\r
-\r
-        MChars.InitializeHandler = MPInitialize;\r
-        MChars.QueryInformationHandler = MPQueryInformation;\r
-        MChars.SetInformationHandler = MPSetInformation;\r
-        MChars.ResetHandler = NULL;\r
-        MChars.TransferDataHandler = MPTransferData;\r
-        MChars.HaltHandler = MPHalt;\r
-#ifdef NDIS51_MINIPORT\r
-        MChars.CancelSendPacketsHandler = MPCancelSendPackets;\r
-        MChars.PnPEventNotifyHandler = MPDevicePnPEvent;\r
-        MChars.AdapterShutdownHandler = MPAdapterShutdown;\r
-#endif // NDIS51_MINIPORT\r
-\r
-        //\r
-        // We will disable the check for hang timeout so we do not\r
-        // need a check for hang handler!\r
-        //\r
-        MChars.CheckForHangHandler = NULL;\r
-        MChars.ReturnPacketHandler = MPReturnPacket;\r
-\r
-        //\r
-        // Either the Send or the SendPackets handler should be specified.\r
-        // If SendPackets handler is specified, SendHandler is ignored\r
-        //\r
-        MChars.SendHandler = NULL;    // MPSend;\r
-        MChars.SendPacketsHandler = MPSendPackets;\r
-\r
-        Status = NdisIMRegisterLayeredMiniport(NdisWrapperHandle,\r
-                                                  &MChars,\r
-                                                  sizeof(MChars),\r
-                                                  &DriverHandle);\r
-        if (Status != NDIS_STATUS_SUCCESS)\r
-        {\r
-            break;\r
-        }\r
-\r
-#ifndef WIN9X\r
-        NdisMRegisterUnloadHandler(NdisWrapperHandle, PtUnload);\r
-#endif\r
-\r
-        //\r
-        // Now register the protocol.\r
-        //\r
-        NdisZeroMemory(&PChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));\r
-        PChars.MajorNdisVersion = PASSTHRU_PROT_MAJOR_NDIS_VERSION;\r
-        PChars.MinorNdisVersion = PASSTHRU_PROT_MINOR_NDIS_VERSION;\r
-\r
-        //\r
-        // Make sure the protocol-name matches the service-name\r
-        // (from the INF) under which this protocol is installed.\r
-        // This is needed to ensure that NDIS can correctly determine\r
-        // the binding and call us to bind to miniports below.\r
-        //\r
-        NdisInitUnicodeString(&Name, L"Passthru");    // Protocol name\r
-        PChars.Name = Name;\r
-        PChars.OpenAdapterCompleteHandler = PtOpenAdapterComplete;\r
-        PChars.CloseAdapterCompleteHandler = PtCloseAdapterComplete;\r
-        PChars.SendCompleteHandler = PtSendComplete;\r
-        PChars.TransferDataCompleteHandler = PtTransferDataComplete;\r
-    \r
-        PChars.ResetCompleteHandler = PtResetComplete;\r
-        PChars.RequestCompleteHandler = PtRequestComplete;\r
-        PChars.ReceiveHandler = PtReceive;\r
-        PChars.ReceiveCompleteHandler = PtReceiveComplete;\r
-        PChars.StatusHandler = PtStatus;\r
-        PChars.StatusCompleteHandler = PtStatusComplete;\r
-        PChars.BindAdapterHandler = PtBindAdapter;\r
-        PChars.UnbindAdapterHandler = PtUnbindAdapter;\r
-        PChars.UnloadHandler = PtUnloadProtocol;\r
-\r
-        PChars.ReceivePacketHandler = PtReceivePacket;\r
-        PChars.PnPEventHandler= PtPNPHandler;\r
-\r
-        NdisRegisterProtocol(&Status,\r
-                             &ProtHandle,\r
-                             &PChars,\r
-                             sizeof(NDIS_PROTOCOL_CHARACTERISTICS));\r
-\r
-        if (Status != NDIS_STATUS_SUCCESS)\r
-        {\r
-            NdisIMDeregisterLayeredMiniport(DriverHandle);\r
-            break;\r
-        }\r
-\r
-        NdisIMAssociateMiniport(DriverHandle, ProtHandle);\r
-    }\r
-    while (FALSE);\r
-\r
-    if (Status != NDIS_STATUS_SUCCESS)\r
-    {\r
-        NdisTerminateWrapper(NdisWrapperHandle, NULL);\r
-    }\r
-\r
-    return(Status);\r
-}\r
-\r
-\r
-NDIS_STATUS\r
-PtRegisterDevice(\r
-    VOID\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Register an ioctl interface - a device object to be used for this\r
-    purpose is created by NDIS when we call NdisMRegisterDevice.\r
-\r
-    This routine is called whenever a new miniport instance is\r
-    initialized. However, we only create one global device object,\r
-    when the first miniport instance is initialized. This routine\r
-    handles potential race conditions with PtDeregisterDevice via\r
-    the ControlDeviceState and MiniportCount variables.\r
-\r
-    NOTE: do not call this from DriverEntry; it will prevent the driver\r
-    from being unloaded (e.g. on uninstall).\r
-\r
-Arguments:\r
-\r
-    None\r
-\r
-Return Value:\r
-\r
-    NDIS_STATUS_SUCCESS if we successfully register a device object.\r
-\r
---*/\r
-{\r
-    NDIS_STATUS            Status = NDIS_STATUS_SUCCESS;\r
-    UNICODE_STRING         DeviceName;\r
-    UNICODE_STRING         DeviceLinkUnicodeString;\r
-    PDRIVER_DISPATCH       DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1];\r
-\r
-    DBGPRINT(("==>PtRegisterDevice\n"));\r
-\r
-    NdisAcquireSpinLock(&GlobalLock);\r
-\r
-    ++MiniportCount;\r
-    \r
-    if (1 == MiniportCount)\r
-    {\r
-        ASSERT(ControlDeviceState != PS_DEVICE_STATE_CREATING);\r
-\r
-        //\r
-        // Another thread could be running PtDeregisterDevice on\r
-        // behalf of another miniport instance. If so, wait for\r
-        // it to exit.\r
-        //\r
-        while (ControlDeviceState != PS_DEVICE_STATE_READY)\r
-        {\r
-            NdisReleaseSpinLock(&GlobalLock);\r
-            NdisMSleep(1);\r
-            NdisAcquireSpinLock(&GlobalLock);\r
-        }\r
-\r
-        ControlDeviceState = PS_DEVICE_STATE_CREATING;\r
-\r
-        NdisReleaseSpinLock(&GlobalLock);\r
-\r
-    \r
-        NdisZeroMemory(DispatchTable, (IRP_MJ_MAXIMUM_FUNCTION+1) * sizeof(PDRIVER_DISPATCH));\r
-\r
-        DispatchTable[IRP_MJ_CREATE] = PtDispatch;\r
-        DispatchTable[IRP_MJ_CLEANUP] = PtDispatch;\r
-        DispatchTable[IRP_MJ_CLOSE] = PtDispatch;\r
-        DispatchTable[IRP_MJ_DEVICE_CONTROL] = PtDispatch;\r
-        \r
-\r
-        NdisInitUnicodeString(&DeviceName, NTDEVICE_STRING);\r
-        NdisInitUnicodeString(&DeviceLinkUnicodeString, LINKNAME_STRING);\r
-\r
-        //\r
-        // Create a device object and register our dispatch handlers\r
-        //\r
-        \r
-        Status = NdisMRegisterDevice(\r
-                    NdisWrapperHandle, \r
-                    &DeviceName,\r
-                    &DeviceLinkUnicodeString,\r
-                    &DispatchTable[0],\r
-                    &ControlDeviceObject,\r
-                    &NdisDeviceHandle\r
-                    );\r
-\r
-        NdisAcquireSpinLock(&GlobalLock);\r
-\r
-        ControlDeviceState = PS_DEVICE_STATE_READY;\r
-    }\r
-\r
-    NdisReleaseSpinLock(&GlobalLock);\r
-\r
-    DBGPRINT(("<==PtRegisterDevice: %x\n", Status));\r
-\r
-    return (Status);\r
-}\r
-\r
-\r
-NTSTATUS\r
-PtDispatch(\r
-    IN PDEVICE_OBJECT    DeviceObject,\r
-    IN PIRP              Irp\r
-    )\r
-/*++\r
-Routine Description:\r
-\r
-    Process IRPs sent to this device.\r
-\r
-Arguments:\r
-\r
-    DeviceObject - pointer to a device object\r
-    Irp      - pointer to an I/O Request Packet\r
-\r
-Return Value:\r
-\r
-    NTSTATUS - STATUS_SUCCESS always - change this when adding\r
-    real code to handle ioctls.\r
-\r
---*/\r
-{\r
-    PIO_STACK_LOCATION  irpStack;\r
-    NTSTATUS            status = STATUS_SUCCESS;\r
-\r
-    UNREFERENCED_PARAMETER(DeviceObject);\r
-    \r
-    DBGPRINT(("==>Pt Dispatch\n"));\r
-    irpStack = IoGetCurrentIrpStackLocation(Irp);\r
-      \r
-\r
-    switch (irpStack->MajorFunction)\r
-    {\r
-        case IRP_MJ_CREATE:\r
-            break;\r
-            \r
-        case IRP_MJ_CLEANUP:\r
-            break;\r
-            \r
-        case IRP_MJ_CLOSE:\r
-            break;        \r
-            \r
-        case IRP_MJ_DEVICE_CONTROL:\r
-            //\r
-            // Add code here to handle ioctl commands sent to passthru.\r
-            //\r
-            break;        \r
-        default:\r
-            break;\r
-    }\r
-\r
-    Irp->IoStatus.Status = status;\r
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);\r
-\r
-    DBGPRINT(("<== Pt Dispatch\n"));\r
-\r
-    return status;\r
-\r
-} \r
-\r
-\r
-NDIS_STATUS\r
-PtDeregisterDevice(\r
-    VOID\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Deregister the ioctl interface. This is called whenever a miniport\r
-    instance is halted. When the last miniport instance is halted, we\r
-    request NDIS to delete the device object\r
-\r
-Arguments:\r
-\r
-    NdisDeviceHandle - Handle returned by NdisMRegisterDevice\r
-\r
-Return Value:\r
-\r
-    NDIS_STATUS_SUCCESS if everything worked ok\r
-\r
---*/\r
-{\r
-    NDIS_STATUS Status = NDIS_STATUS_SUCCESS;\r
-\r
-    DBGPRINT(("==>PassthruDeregisterDevice\n"));\r
-\r
-    NdisAcquireSpinLock(&GlobalLock);\r
-\r
-    ASSERT(MiniportCount > 0);\r
-\r
-    --MiniportCount;\r
-    \r
-    if (0 == MiniportCount)\r
-    {\r
-        //\r
-        // All miniport instances have been halted. Deregister\r
-        // the control device.\r
-        //\r
-\r
-        ASSERT(ControlDeviceState == PS_DEVICE_STATE_READY);\r
-\r
-        //\r
-        // Block PtRegisterDevice() while we release the control\r
-        // device lock and deregister the device.\r
-        // \r
-        ControlDeviceState = PS_DEVICE_STATE_DELETING;\r
-\r
-        NdisReleaseSpinLock(&GlobalLock);\r
-\r
-        if (NdisDeviceHandle != NULL)\r
-        {\r
-            Status = NdisMDeregisterDevice(NdisDeviceHandle);\r
-            NdisDeviceHandle = NULL;\r
-        }\r
-\r
-        NdisAcquireSpinLock(&GlobalLock);\r
-        ControlDeviceState = PS_DEVICE_STATE_READY;\r
-    }\r
-\r
-    NdisReleaseSpinLock(&GlobalLock);\r
-\r
-    DBGPRINT(("<== PassthruDeregisterDevice: %x\n", Status));\r
-    return Status;\r
-    \r
-}\r
-\r
-VOID\r
-PtUnload(\r
-    IN PDRIVER_OBJECT        DriverObject\r
-    )\r
-//\r
-// PassThru driver unload function\r
-//\r
-{\r
-    UNREFERENCED_PARAMETER(DriverObject);\r
-    \r
-    DBGPRINT(("PtUnload: entered\n"));\r
-    \r
-    PtUnloadProtocol();\r
-    \r
-    NdisIMDeregisterLayeredMiniport(DriverHandle);\r
-    \r
-    NdisFreeSpinLock(&GlobalLock);\r
-\r
-    DBGPRINT(("PtUnload: done!\n"));\r
-}\r
-\r
diff --git a/original_passthru/passthru.h b/original_passthru/passthru.h
deleted file mode 100644 (file)
index badde8a..0000000
+++ /dev/null
@@ -1,477 +0,0 @@
-/*++\r
-\r
-Copyright (c) 1992-2000  Microsoft Corporation\r
-\r
-Module Name:\r
-\r
-    passthru.h\r
-\r
-Abstract:\r
-\r
-    Ndis Intermediate Miniport driver sample. This is a passthru driver.\r
-\r
-Author:\r
-\r
-Environment:\r
-\r
-\r
-Revision History:\r
-\r
\r
---*/\r
-\r
-#ifdef NDIS51_MINIPORT\r
-#define PASSTHRU_MAJOR_NDIS_VERSION            5\r
-#define PASSTHRU_MINOR_NDIS_VERSION            1\r
-#else\r
-#define PASSTHRU_MAJOR_NDIS_VERSION            4\r
-#define PASSTHRU_MINOR_NDIS_VERSION            0\r
-#endif\r
-\r
-#ifdef NDIS51\r
-#define PASSTHRU_PROT_MAJOR_NDIS_VERSION    5\r
-#define PASSTHRU_PROT_MINOR_NDIS_VERSION    0\r
-#else\r
-#define PASSTHRU_PROT_MAJOR_NDIS_VERSION    4\r
-#define PASSTHRU_PROT_MINOR_NDIS_VERSION    0\r
-#endif\r
-\r
-#define MAX_BUNDLEID_LENGTH 50\r
-\r
-#define TAG 'ImPa'\r
-#define WAIT_INFINITE 0\r
-\r
-\r
-\r
-//advance declaration\r
-typedef struct _ADAPT ADAPT, *PADAPT;\r
-\r
-DRIVER_INITIALIZE DriverEntry;\r
-extern\r
-NTSTATUS\r
-DriverEntry(\r
-    IN PDRIVER_OBJECT            DriverObject,\r
-    IN PUNICODE_STRING           RegistryPath\r
-    );\r
-\r
-DRIVER_DISPATCH PtDispatch;\r
-NTSTATUS\r
-PtDispatch(\r
-    IN PDEVICE_OBJECT            DeviceObject,\r
-    IN PIRP                      Irp\r
-    );\r
-\r
-NDIS_STATUS\r
-PtRegisterDevice(\r
-    VOID\r
-    );\r
-\r
-NDIS_STATUS\r
-PtDeregisterDevice(\r
-    VOID\r
-   );\r
-\r
-DRIVER_UNLOAD PtUnload;\r
-VOID\r
-PtUnloadProtocol(\r
-    VOID\r
-    );\r
-\r
-//\r
-// Protocol proto-types\r
-//\r
-extern\r
-VOID\r
-PtOpenAdapterComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_STATUS                Status,\r
-    IN NDIS_STATUS                OpenErrorStatus\r
-    );\r
-\r
-extern\r
-VOID\r
-PtCloseAdapterComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_STATUS                Status\r
-    );\r
-\r
-extern\r
-VOID\r
-PtResetComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_STATUS                Status\r
-    );\r
-\r
-extern\r
-VOID\r
-PtRequestComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNDIS_REQUEST              NdisRequest,\r
-    IN NDIS_STATUS                Status\r
-    );\r
-\r
-extern\r
-VOID\r
-PtStatus(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_STATUS                GeneralStatus,\r
-    IN PVOID                      StatusBuffer,\r
-    IN UINT                       StatusBufferSize\r
-    );\r
-\r
-extern\r
-VOID\r
-PtStatusComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext\r
-    );\r
-\r
-extern\r
-VOID\r
-PtSendComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNDIS_PACKET               Packet,\r
-    IN NDIS_STATUS                Status\r
-    );\r
-\r
-extern\r
-VOID\r
-PtTransferDataComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNDIS_PACKET               Packet,\r
-    IN NDIS_STATUS                Status,\r
-    IN UINT                       BytesTransferred\r
-    );\r
-\r
-extern\r
-NDIS_STATUS\r
-PtReceive(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN NDIS_HANDLE                MacReceiveContext,\r
-    IN PVOID                      HeaderBuffer,\r
-    IN UINT                       HeaderBufferSize,\r
-    IN PVOID                      LookAheadBuffer,\r
-    IN UINT                       LookaheadBufferSize,\r
-    IN UINT                       PacketSize\r
-    );\r
-\r
-extern\r
-VOID\r
-PtReceiveComplete(\r
-    IN NDIS_HANDLE                ProtocolBindingContext\r
-    );\r
-\r
-extern\r
-INT\r
-PtReceivePacket(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNDIS_PACKET               Packet\r
-    );\r
-\r
-extern\r
-VOID\r
-PtBindAdapter(\r
-    OUT PNDIS_STATUS              Status,\r
-    IN  NDIS_HANDLE               BindContext,\r
-    IN  PNDIS_STRING              DeviceName,\r
-    IN  PVOID                     SystemSpecific1,\r
-    IN  PVOID                     SystemSpecific2\r
-    );\r
-\r
-extern\r
-VOID\r
-PtUnbindAdapter(\r
-    OUT PNDIS_STATUS              Status,\r
-    IN  NDIS_HANDLE               ProtocolBindingContext,\r
-    IN  NDIS_HANDLE               UnbindContext\r
-    );\r
-    \r
-VOID\r
-PtUnload(\r
-    IN PDRIVER_OBJECT             DriverObject\r
-    );\r
-\r
-\r
-\r
-extern \r
-NDIS_STATUS\r
-PtPNPHandler(\r
-    IN NDIS_HANDLE                ProtocolBindingContext,\r
-    IN PNET_PNP_EVENT             pNetPnPEvent\r
-    );\r
-\r
-\r
-\r
-\r
-NDIS_STATUS\r
-PtPnPNetEventReconfigure(\r
-    IN PADAPT            pAdapt,\r
-    IN PNET_PNP_EVENT    pNetPnPEvent\r
-    );    \r
-\r
-NDIS_STATUS \r
-PtPnPNetEventSetPower (\r
-    IN PADAPT                    pAdapt,\r
-    IN PNET_PNP_EVENT            pNetPnPEvent\r
-    );\r
-    \r
-\r
-//\r
-// Miniport proto-types\r
-//\r
-NDIS_STATUS\r
-MPInitialize(\r
-    OUT PNDIS_STATUS             OpenErrorStatus,\r
-    OUT PUINT                    SelectedMediumIndex,\r
-    IN PNDIS_MEDIUM              MediumArray,\r
-    IN UINT                      MediumArraySize,\r
-    IN NDIS_HANDLE               MiniportAdapterHandle,\r
-    IN NDIS_HANDLE               WrapperConfigurationContext\r
-    );\r
-\r
-VOID\r
-MPSendPackets(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN PPNDIS_PACKET              PacketArray,\r
-    IN UINT                       NumberOfPackets\r
-    );\r
-\r
-NDIS_STATUS\r
-MPSend(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN PNDIS_PACKET               Packet,\r
-    IN UINT                       Flags\r
-    );\r
-\r
-NDIS_STATUS\r
-MPQueryInformation(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN NDIS_OID                   Oid,\r
-    IN PVOID                      InformationBuffer,\r
-    IN ULONG                      InformationBufferLength,\r
-    OUT PULONG                    BytesWritten,\r
-    OUT PULONG                    BytesNeeded\r
-    );\r
-\r
-NDIS_STATUS\r
-MPSetInformation(\r
-    IN NDIS_HANDLE                                      MiniportAdapterContext,\r
-    IN NDIS_OID                                         Oid,\r
-    __in_bcount(InformationBufferLength) IN PVOID       InformationBuffer,\r
-    IN ULONG                                            InformationBufferLength,\r
-    OUT PULONG                                          BytesRead,\r
-    OUT PULONG                                          BytesNeeded\r
-    );\r
-\r
-VOID\r
-MPReturnPacket(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN PNDIS_PACKET               Packet\r
-    );\r
-\r
-NDIS_STATUS\r
-MPTransferData(\r
-    OUT PNDIS_PACKET              Packet,\r
-    OUT PUINT                     BytesTransferred,\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN NDIS_HANDLE                MiniportReceiveContext,\r
-    IN UINT                       ByteOffset,\r
-    IN UINT                       BytesToTransfer\r
-    );\r
-\r
-VOID\r
-MPHalt(\r
-    IN NDIS_HANDLE                MiniportAdapterContext\r
-    );\r
-\r
-\r
-VOID\r
-MPQueryPNPCapabilities(  \r
-    OUT PADAPT                    MiniportProtocolContext, \r
-    OUT PNDIS_STATUS              Status\r
-    );\r
-\r
-\r
-#ifdef NDIS51_MINIPORT\r
-\r
-VOID\r
-MPCancelSendPackets(\r
-    IN NDIS_HANDLE            MiniportAdapterContext,\r
-    IN PVOID                  CancelId\r
-    );\r
-\r
-VOID\r
-MPAdapterShutdown(\r
-    IN NDIS_HANDLE                MiniportAdapterContext\r
-    );\r
-\r
-VOID\r
-MPDevicePnPEvent(\r
-    IN NDIS_HANDLE                MiniportAdapterContext,\r
-    IN NDIS_DEVICE_PNP_EVENT      DevicePnPEvent,\r
-    IN PVOID                      InformationBuffer,\r
-    IN ULONG                      InformationBufferLength\r
-    );\r
-\r
-#endif // NDIS51_MINIPORT\r
-\r
-VOID\r
-MPFreeAllPacketPools(\r
-    IN PADAPT                    pAdapt\r
-    );\r
-\r
-\r
-VOID\r
-MPProcessSetPowerOid(\r
-    IN OUT PNDIS_STATUS                             pNdisStatus,\r
-    IN PADAPT                                       pAdapt,\r
-    __in_bcount(InformationBufferLength) IN PVOID   InformationBuffer,\r
-    IN ULONG                                        InformationBufferLength,\r
-    OUT PULONG                                      BytesRead,\r
-    OUT PULONG                                      BytesNeeded\r
-    );\r
-\r
-VOID\r
-PtReferenceAdapt(\r
-    IN PADAPT     pAdapt\r
-    );\r
-\r
-BOOLEAN\r
-PtDereferenceAdapt(\r
-    IN PADAPT     pAdapt\r
-    );\r
-\r
-//\r
-// There should be no DbgPrint's in the Free version of the driver\r
-//\r
-#if DBG\r
-\r
-#define DBGPRINT(Fmt)                                        \\r
-    {                                                        \\r
-        DbgPrint("Passthru: ");                                \\r
-        DbgPrint Fmt;                                        \\r
-    }\r
-\r
-#else // if DBG\r
-\r
-#define DBGPRINT(Fmt)                                            \r
-\r
-#endif // if DBG \r
-\r
-#define    NUM_PKTS_IN_POOL    256\r
-\r
-\r
-//\r
-// Protocol reserved part of a sent packet that is allocated by us.\r
-//\r
-typedef struct _SEND_RSVD\r
-{\r
-    PNDIS_PACKET    OriginalPkt;\r
-} SEND_RSVD, *PSEND_RSVD;\r
-\r
-//\r
-// Miniport reserved part of a received packet that is allocated by\r
-// us. Note that this should fit into the MiniportReserved space\r
-// in an NDIS_PACKET.\r
-//\r
-typedef struct _RECV_RSVD\r
-{\r
-    PNDIS_PACKET    OriginalPkt;\r
-} RECV_RSVD, *PRECV_RSVD;\r
-\r
-C_ASSERT(sizeof(RECV_RSVD) <= sizeof(((PNDIS_PACKET)0)->MiniportReserved));\r
-\r
-//\r
-// Event Codes related to the PassthruEvent Structure\r
-//\r
-\r
-typedef enum \r
-{\r
-    Passthru_Invalid,\r
-    Passthru_SetPower,\r
-    Passthru_Unbind\r
-\r
-} PASSSTHRU_EVENT_CODE, *PPASTHRU_EVENT_CODE; \r
-\r
-//\r
-// Passthru Event with  a code to state why they have been state\r
-//\r
-\r
-typedef struct _PASSTHRU_EVENT\r
-{\r
-    NDIS_EVENT Event;\r
-    PASSSTHRU_EVENT_CODE Code;\r
-\r
-} PASSTHRU_EVENT, *PPASSTHRU_EVENT;\r
-\r
-\r
-//\r
-// Structure used by both the miniport as well as the protocol part of the intermediate driver\r
-// to represent an adapter and its corres. lower bindings\r
-//\r
-typedef struct _ADAPT\r
-{\r
-    struct _ADAPT *                Next;\r
-    \r
-    NDIS_HANDLE                    BindingHandle;    // To the lower miniport\r
-    NDIS_HANDLE                    MiniportHandle;    // NDIS Handle to for miniport up-calls\r
-    NDIS_HANDLE                    SendPacketPoolHandle;\r
-    NDIS_HANDLE                    RecvPacketPoolHandle;\r
-    NDIS_STATUS                    Status;            // Open Status\r
-    NDIS_EVENT                     Event;            // Used by bind/halt for Open/Close Adapter synch.\r
-    NDIS_MEDIUM                    Medium;\r
-    NDIS_REQUEST                   Request;        // This is used to wrap a request coming down\r
-                                                // to us. This exploits the fact that requests\r
-                                                // are serialized down to us.\r
-    PULONG                         BytesNeeded;\r
-    PULONG                         BytesReadOrWritten;\r
-    BOOLEAN                        ReceivedIndicationFlags[32];\r
-    \r
-    BOOLEAN                        OutstandingRequests;      // TRUE iff a request is pending\r
-                                                        // at the miniport below\r
-    BOOLEAN                        QueuedRequest;            // TRUE iff a request is queued at\r
-                                                        // this IM miniport\r
-\r
-    BOOLEAN                        StandingBy;                // True - When the miniport or protocol is transitioning from a D0 to Standby (>D0) State\r
-    BOOLEAN                        UnbindingInProcess;\r
-    NDIS_SPIN_LOCK                 Lock;\r
-                                                        // False - At all other times, - Flag is cleared after a transition to D0\r
-\r
-    NDIS_DEVICE_POWER_STATE        MPDeviceState;            // Miniport's Device State \r
-    NDIS_DEVICE_POWER_STATE        PTDeviceState;            // Protocol's Device State \r
-    NDIS_STRING                    DeviceName;                // For initializing the miniport edge\r
-    NDIS_EVENT                     MiniportInitEvent;        // For blocking UnbindAdapter while\r
-                                                        // an IM Init is in progress.\r
-    BOOLEAN                        MiniportInitPending;    // TRUE iff IMInit in progress\r
-    NDIS_STATUS                    LastIndicatedStatus;    // The last indicated media status\r
-    NDIS_STATUS                    LatestUnIndicateStatus; // The latest suppressed media status\r
-    ULONG                          OutstandingSends;\r
-    LONG                           RefCount;\r
-    BOOLEAN                        MiniportIsHalted;\r
-} ADAPT, *PADAPT;\r
-\r
-extern    NDIS_HANDLE                        ProtHandle, DriverHandle;\r
-extern    NDIS_MEDIUM                        MediumArray[4];\r
-extern    PADAPT                             pAdaptList;\r
-extern    NDIS_SPIN_LOCK                     GlobalLock;\r
-\r
-\r
-#define ADAPT_MINIPORT_HANDLE(_pAdapt)    ((_pAdapt)->MiniportHandle)\r
-#define ADAPT_DECR_PENDING_SENDS(_pAdapt)     \\r
-    {                                         \\r
-        NdisAcquireSpinLock(&(_pAdapt)->Lock);   \\r
-        (_pAdapt)->OutstandingSends--;           \\r
-        NdisReleaseSpinLock(&(_pAdapt)->Lock);   \\r
-    }\r
-\r
-//\r
-// Custom Macros to be used by the passthru driver \r
-//\r
-/*\r
-BOOLEAN\r
-IsIMDeviceStateOn(\r
-   PADAPT \r
-   )\r
-\r
-*/\r
-#define IsIMDeviceStateOn(_pP)        ((_pP)->MPDeviceState == NdisDeviceStateD0 && (_pP)->PTDeviceState == NdisDeviceStateD0 ) \r
-\r
diff --git a/original_passthru/passthru.htm b/original_passthru/passthru.htm
deleted file mode 100644 (file)
index ee23278..0000000
+++ /dev/null
@@ -1,486 +0,0 @@
-<html xmlns:v="urn:schemas-microsoft-com:vml"\r
-xmlns:o="urn:schemas-microsoft-com:office:office"\r
-xmlns:w="urn:schemas-microsoft-com:office:word"\r
-xmlns:st1="urn:schemas-microsoft-com:office:smarttags"\r
-xmlns="http://www.w3.org/TR/REC-html40">\r
-\r
-<head>\r
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">\r
-<meta name=ProgId content=Word.Document>\r
-<meta name=Generator content="Microsoft Word 10">\r
-<meta name=Originator content="Microsoft Word 10">\r
-<link rel=File-List href="passthru_files/filelist.xml">\r
-<title>passthru</title>\r
-<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"\r
- name="place"/>\r
-<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"\r
- name="PlaceType"/>\r
-<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"\r
- name="PlaceName"/>\r
-<!--[if gte mso 9]><xml>\r
- <w:WordDocument>\r
-  <w:SpellingState>Clean</w:SpellingState>\r
-  <w:GrammarState>Clean</w:GrammarState>\r
-  <w:Compatibility>\r
-   <w:UseFELayout/>\r
-  </w:Compatibility>\r
-  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>\r
- </w:WordDocument>\r
-</xml><![endif]--><!--[if !mso]><object\r
- classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>\r
-<style>\r
-st1\:*{behavior:url(#ieooui) }\r
-</style>\r
-<![endif]-->\r
-<style>\r
-<!--\r
- /* Font Definitions */\r
- @font-face\r
-       {font-family:"MS Mincho";\r
-       panose-1:2 2 6 9 4 2 5 8 3 4;\r
-       mso-font-alt:"\FF2D\FF33 \660E\671D";\r
-       mso-font-charset:128;\r
-       mso-generic-font-family:modern;\r
-       mso-font-pitch:fixed;\r
-       mso-font-signature:-1610612033 1757936891 16 0 131231 0;}\r
-@font-face\r
-       {font-family:Verdana;\r
-       panose-1:2 11 6 4 3 5 4 4 2 4;\r
-       mso-font-charset:0;\r
-       mso-generic-font-family:swiss;\r
-       mso-font-pitch:variable;\r
-       mso-font-signature:536871559 0 0 0 415 0;}\r
-@font-face\r
-       {font-family:"\@MS Mincho";\r
-       panose-1:2 2 6 9 4 2 5 8 3 4;\r
-       mso-font-charset:128;\r
-       mso-generic-font-family:modern;\r
-       mso-font-pitch:fixed;\r
-       mso-font-signature:-1610612033 1757936891 16 0 131231 0;}\r
-@font-face\r
-       {font-family:"MS Sans Serif";\r
-       panose-1:0 0 0 0 0 0 0 0 0 0;\r
-       mso-font-charset:0;\r
-       mso-generic-font-family:swiss;\r
-       mso-font-format:other;\r
-       mso-font-pitch:variable;\r
-       mso-font-signature:3 0 0 0 1 0;}\r
- /* Style Definitions */\r
- p.MsoNormal, li.MsoNormal, div.MsoNormal\r
-       {mso-style-parent:"";\r
-       margin:0in;\r
-       margin-bottom:.0001pt;\r
-       mso-pagination:widow-orphan;\r
-       font-size:12.0pt;\r
-       font-family:"Times New Roman";\r
-       mso-fareast-font-family:"Times New Roman";\r
-       color:black;}\r
-h2\r
-       {mso-margin-top-alt:auto;\r
-       margin-right:0in;\r
-       mso-margin-bottom-alt:auto;\r
-       margin-left:0in;\r
-       mso-pagination:widow-orphan;\r
-       mso-outline-level:2;\r
-       font-size:18.0pt;\r
-       font-family:"Times New Roman";\r
-       mso-fareast-font-family:"MS Mincho";\r
-       color:black;\r
-       font-weight:bold;}\r
-h3\r
-       {mso-margin-top-alt:auto;\r
-       margin-right:0in;\r
-       mso-margin-bottom-alt:auto;\r
-       margin-left:0in;\r
-       mso-pagination:widow-orphan;\r
-       mso-outline-level:3;\r
-       font-size:13.5pt;\r
-       font-family:"Times New Roman";\r
-       mso-fareast-font-family:"MS Mincho";\r
-       color:black;\r
-       font-weight:bold;}\r
-h4\r
-       {mso-margin-top-alt:auto;\r
-       margin-right:0in;\r
-       mso-margin-bottom-alt:auto;\r
-       margin-left:0in;\r
-       mso-pagination:widow-orphan;\r
-       mso-outline-level:4;\r
-       font-size:12.0pt;\r
-       font-family:"Times New Roman";\r
-       mso-fareast-font-family:"MS Mincho";\r
-       color:black;\r
-       font-weight:bold;}\r
-a:link, span.MsoHyperlink\r
-       {color:blue;\r
-       text-decoration:underline;\r
-       text-underline:single;}\r
-a:visited, span.MsoHyperlinkFollowed\r
-       {color:purple;\r
-       text-decoration:underline;\r
-       text-underline:single;}\r
-p\r
-       {mso-margin-top-alt:auto;\r
-       margin-right:0in;\r
-       mso-margin-bottom-alt:auto;\r
-       margin-left:0in;\r
-       mso-pagination:widow-orphan;\r
-       font-size:12.0pt;\r
-       font-family:"Times New Roman";\r
-       mso-fareast-font-family:"Times New Roman";\r
-       color:black;}\r
-pre\r
-       {margin:0in;\r
-       margin-bottom:.0001pt;\r
-       mso-pagination:widow-orphan;\r
-       tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\r
-       font-size:10.0pt;\r
-       font-family:"Courier New";\r
-       mso-fareast-font-family:"Courier New";\r
-       color:black;}\r
-span.SpellE\r
-       {mso-style-name:"";\r
-       mso-spl-e:yes;}\r
-span.GramE\r
-       {mso-style-name:"";\r
-       mso-gram-e:yes;}\r
-@page Section1\r
-       {size:8.5in 11.0in;\r
-       margin:1.0in 1.25in 1.0in 1.25in;\r
-       mso-header-margin:.5in;\r
-       mso-footer-margin:.5in;\r
-       mso-paper-source:0;}\r
-div.Section1\r
-       {page:Section1;}\r
--->\r
-</style>\r
-<!--[if gte mso 10]>\r
-<style>\r
- /* Style Definitions */\r
- table.MsoNormalTable\r
-       {mso-style-name:"Table Normal";\r
-       mso-tstyle-rowband-size:0;\r
-       mso-tstyle-colband-size:0;\r
-       mso-style-noshow:yes;\r
-       mso-style-parent:"";\r
-       mso-padding-alt:0in 5.4pt 0in 5.4pt;\r
-       mso-para-margin:0in;\r
-       mso-para-margin-bottom:.0001pt;\r
-       mso-pagination:widow-orphan;\r
-       font-size:10.0pt;\r
-       font-family:"Times New Roman";}\r
-</style>\r
-<![endif]-->\r
-<meta name=Template content="C:\Program Files\Microsoft Office\Office\html.dot">\r
-<!--[if gte mso 9]><xml>\r
- <o:shapedefaults v:ext="edit" spidmax="3074"/>\r
-</xml><![endif]--><!--[if gte mso 9]><xml>\r
- <o:shapelayout v:ext="edit">\r
-  <o:idmap v:ext="edit" data="1"/>\r
- </o:shapelayout></xml><![endif]-->\r
-</head>\r
-\r
-<body bgcolor=white lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>\r
-\r
-<div class=Section1>\r
-\r
-<h2><a name=MYSAMPLE></a><a name=top></a><span style='mso-bookmark:MYSAMPLE'>\r
-\r
-<!doctype HTML>\r
-\r
-<span style='font-family:Verdana'><! ---------------- Snip Snip ---------------- >PASSTHRU.SYS\r
-- Sample NDIS Intermediate Driver</span></span><span style='font-family:Verdana'><o:p></o:p></span></h2>\r
-\r
-<h3><span style='font-family:Verdana'>SUMMARY<o:p></o:p></span></h3>\r
-\r
-<p><st1:place><st1:PlaceName><span class=SpellE><b><span style='font-family:\r
-  Verdana'>Passthru</span></b></span></st1:PlaceName><b><span style='font-family:\r
- Verdana'> </span></b><st1:PlaceName><b><span style='font-family:Verdana'>Intermediate</span></b></st1:PlaceName><b><span\r
- style='font-family:Verdana'> </span></b><st1:PlaceType><b><span\r
-  style='font-family:Verdana'>Miniport</span></b></st1:PlaceType></st1:place><b><span\r
-style='font-family:Verdana'> Driver<o:p></o:p></span></b></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>The <span class=SpellE>Passthru</span>\r
-sample is a do-nothing pass-through NDIS 5 driver that demonstrates the basic\r
-principles underlying an NDIS Intermediate Miniport (IM) driver. This driver\r
-exposes a virtual adapter for each binding to a real or virtual NDIS adapter.\r
-Protocols bind to these virtual adapters as if they are real adapters. <o:p></o:p></span></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>The <span class=SpellE>Passthru</span>\r
-driver re-packages and sends down all requests and sends submitted to this\r
-virtual adapter. The <span class=SpellE>Passthru</span> driver can be modified\r
-to change the data before passing it along. For example, it could\r
-encrypt/compress outgoing and decrypt/decompress incoming data.<o:p></o:p></span></p>\r
-\r
-<p><span class=SpellE><span style='font-size:10.0pt;font-family:Verdana'>Passthru</span></span><span\r
-style='font-size:10.0pt;font-family:Verdana'> also re-packages and indicates up\r
-all received data and status indications that it receives at its lower\r
-(protocol) edge.<o:p></o:p></span></p>\r
-\r
-<h3><span style='font-family:Verdana'>BUILDING THE SAMPLE<o:p></o:p></span></h3>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>Run the <b>build</b>\r
-command from this directory to build the sample\97it creates the binary <span\r
-class=SpellE>Passthru.sys</span>. <o:p></o:p></span></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>To install this driver on\r
-Windows® 2000, use the PASSTHRU sample notification object and <span\r
-class=SpellE>INFs</span>, also found in this DDK.<o:p></o:p></span></p>\r
-\r
-<h3><span style='font-family:Verdana'>INSTALLING THE SAMPLE<o:p></o:p></span></h3>\r
-\r
-<p><span class=SpellE><span style='font-size:10.0pt;font-family:Verdana'>Passthru</span></span><span\r
-style='font-size:10.0pt;font-family:Verdana'> is installed as a service (called\r
-\93<span class=SpellE>Passthru</span> Driver\94 in the supplied <span class=SpellE>INFs</span>/notification\r
-object). To install, follow the steps below.<o:p></o:p></span></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>Prepare a floppy disk (or\r
-installation directory) that contains these files: <span class=SpellE>netsf.inf</span>,\r
-<span class=SpellE>netsf_m.inf</span> and <span class=SpellE>passthru.sys</span>.<o:p></o:p></span></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>On the desktop,\r
-right-click the <b>My Network Places</b> icon and choose <b>Properties</b>. <o:p></o:p></span></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>Right-click on the\r
-relevant Local Area Connection icon and choose <b>Properties</b>. <o:p></o:p></span></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>Click <b>Install</b>,\r
-then <b>Service</b>, then <b>Add</b>, <span class=GramE>then</span> <b>Have Disk</b>.\r
-<o:p></o:p></span></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>Browse to the\r
-drive/directory containing the files listed above. Click <b>OK</b>. This should\r
-show \93<span class=SpellE>Passthru</span> Driver\94 in a list of Network Services.\r
-Highlight this and click <b>OK</b>. This should install the <span class=SpellE>Passthru</span>\r
-driver. <o:p></o:p></span></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>Click <b>OK</b> or <span\r
-class=GramE><b>Yes</b></span> each time the system prompts with a warning\r
-regarding installation of unsigned files. This is necessary because binaries\r
-generated via the DDK build environment are not signed.<o:p></o:p></span></p>\r
-\r
-<p><span style='font-size:10.0pt;font-family:Verdana'>Two .INF files are needed\r
-rather than one because <span class=SpellE>Passthru</span> is installed both as\r
-a protocol and a miniport.<o:p></o:p></span></p>\r
-\r
-<h3><span style='font-family:Verdana'>CODE TOUR<o:p></o:p></span></h3>\r
-\r
-<h4><span style='font-family:Verdana'>File Manifest<o:p></o:p></span></h4>\r
-\r
-<pre><u>File<span style='mso-tab-count:2'>           </span>Description<o:p></o:p></u></pre><pre><o:p>&nbsp;</o:p></pre><pre><span\r
-class=SpellE>Makefile</span><span style='mso-tab-count:1'>       </span>Used during compilation to create the object and sys files</pre><pre><span\r
-class=SpellE>Miniport.c</span><span style='mso-tab-count:1'>     </span>Miniport related functions of the <span\r
-class=SpellE>passthru</span> driver</pre><pre><span class=SpellE>Netsf.inf</span><span\r
-style='mso-tab-count:1'>      </span>Installation INF for the service (protocol side installation)</pre><pre><span\r
-class=SpellE>Netsf_m.inf</span><span style='mso-tab-count:1'>    </span>Installation INF for the miniport (virtual device installation)</pre><pre><span\r
-class=SpellE>Passthru.c</span><span style='mso-tab-count:1'>     </span><span\r
-class=SpellE>DriverEntry</span> routine and any routines common to the <span\r
-class=SpellE>passthru</span> miniport and protocol </pre><pre><span\r
-class=SpellE>Passthru.h</span><span style='mso-tab-count:1'>     </span>Prototypes of all functions and data structures used by the <span\r
-class=SpellE>Passthru</span> driver</pre><pre>Passthru.htm<span\r
-style='mso-tab-count:1'>   </span>Documentation for the <span class=SpellE>Passthru</span> driver (this file)</pre><pre><span\r
-class=SpellE>Passthru.rc</span><span style='mso-tab-count:1'>    </span>Resource <span\r
-class=GramE>file</span> for the <span class=SpellE>Passthru</span> driver</pre><pre><span\r
-class=SpellE>Precomp.h</span><span style='mso-tab-count:1'>      </span><span\r
-class=SpellE>Precompile</span> header file</pre><pre><span class=SpellE>Protocol.c</span><span\r
-style='mso-tab-count:1'>     </span>Protocol related functions of the <span\r
-class=SpellE>Passthru</span> driver</pre><pre>Sources<span style='mso-tab-count:\r
-2'>        </span>List of source files that are compiled and linked to create the <span\r
-class=SpellE>passthru</span> driver. This can be modified to create binaries that operate on previous Windows versions (e.g. Windows 2000).</pre>\r
-\r
-<h4 style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-family:Verdana'>Programming Tour<o:p></o:p></span></h4>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>Basic steps in initializing and\r
-halting of <span class=SpellE>Passthru</span> driver:<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>1) During <span class=SpellE>DriverEntry</span>,\r
-the <span class=SpellE>Passthru</span> driver registers as a protocol and an\r
-Intermediate miniport driver.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>2) Later on, NDIS calls <span\r
-class=SpellE>Passthru\92s</span> <span class=SpellE>BindAdapterHandler</span>, <span\r
-class=SpellE>PtBindAdapter</span>, for each underlying NDIS adapter to which it\r
-is configured to bind.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>3) In the context of <span\r
-class=SpellE>BindAdapterHandler</span> and after successfully opening a binding\r
-to the underlying adapter, the <span class=SpellE>Passthru</span> driver\r
-queries the reserved keyword &quot;<span class=SpellE>UpperBindings</span>&quot;\r
-to get a list of device names for the virtual adapters that this particular\r
-binding is to expose. Since this driver implements a 1:1 relationship between\r
-lower bindings and virtual adapters, this list contains a single name. \93<span\r
-class=SpellE>Mux</span>\94 IM drivers that expose multiple virtual adapters over\r
-a single underlying adapter will process multiple entries in <span\r
-class=SpellE>UpperBindings</span>.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>4) For each device name, the <span\r
-class=SpellE>Passthru</span> driver calls <span class=SpellE>NdisIMInitializeDeviceInstanceEx</span>.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>5) In response, NDIS will\r
-eventually call back <span class=SpellE>Passthru</span> miniport\92s <span\r
-class=SpellE>MiniportInitialize</span> entry point, <span class=SpellE>MPInitialize</span>.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>6) After <span class=SpellE>MPInitialize</span>\r
-successfully returns, NDIS takes care of getting upper-layer protocols to bind\r
-to the newly created virtual adapter(s).<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>7) All requests and sends coming\r
-from upper-layer protocols for the <span class=SpellE>Passthru</span> miniport\r
-driver are repackaged and sent down to NDIS, to be passed to the underlying\r
-NDIS adapter.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>8) All indications arriving from\r
-bindings to an underlying NDIS adapter are forwarded up as if they generated\r
-from <span class=SpellE>Passthru\92s</span> virtual adapters.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>9) NDIS calls the <span\r
-class=SpellE>Passthru</span> driver\92s <span class=SpellE>ProtocolUnbind</span>\r
-entry point to request it to close the binding between an underlying adapter\r
-and <span class=SpellE>Passthru</span> protocol. In processing this, the <span\r
-class=SpellE>Passthru</span> driver first calls <span class=SpellE>NdisIMDeInitializeDeviceInstance</span>\r
-for the virtual adapter(s) representing that particular binding.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>10) NDIS in turn will close all\r
-the bindings between upper-layer protocols and virtual <span class=SpellE>Passthru</span>\r
-adapter.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>11) After all the bindings are\r
-closed, NDIS calls the <span class=SpellE>Passthru</span> driver\92s <span\r
-class=SpellE>MiniportHalt</span> entry point (<span class=SpellE>MPHalt</span>)\r
-for the virtual adapter.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>12) The <span class=SpellE>Passthru</span>\r
-protocol then closes the binding to the underlying adapter by calling <span\r
-class=SpellE>NdisCloseAdapter</span>, and completes the unbind request issued\r
-in step 9.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>13) <b>Handling Power Management</b><o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>13.1 During initialization, the <span\r
-class=SpellE>Passthru</span> miniport should set the Attribute '<i>NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND</i>'\r
-in its call to <span class=SpellE>NdisMSetAttributesEx</span>. <o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>13.2 When the <span class=SpellE>Passthru</span>\r
-miniport is requested to report its Plug and Play capabilities\r
-(OID_PNP_CAPABILITIES), the <span class=SpellE>Passthru</span> miniport must\r
-pass the request to the underlying miniport. If this request succeeds, then the\r
-<span class=SpellE>Passthru</span> miniport should overwrite the following\r
-fields before successfully completing the original request: <o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>NDIS_DEVICE_POWER_STATE<span\r
-style='mso-tab-count:1'>          </span><span class=SpellE>MinMagicPacketWakeUp</span>\r
-= <span class=SpellE>NdisDeviceStateUnspecified</span>;<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>NDIS_DEVICE_POWER_STATE<span\r
-style='mso-tab-count:1'>          </span><span class=SpellE>MinPatternWakeUp</span>=\r
-<span class=SpellE>NdisDeviceStateUnspecified</span>;<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>NDIS_DEVICE_POWER_STATE<span\r
-style='mso-tab-count:1'>          </span><span class=SpellE>MinLinkChangeWakeUp</span>=<span\r
-class=SpellE>NdisDeviceStateUnspecified</span><o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>If the miniport below the <span\r
-class=SpellE>Passthru</span> protocol fails this request, then the status that\r
-was returned should be used to respond to the original request that was made to\r
-the <span class=SpellE>Passthru</span> miniport. <o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>13.3 OID_PNP_SET_POWER and OID_PNP_QUERY_POWER\r
-should not be passed to the miniport below the <span class=SpellE>Passthru</span>\r
-protocol, as those <span class=SpellE>miniports</span> will receive independent\r
-requests from NDIS.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>13.4 NDIS calls the <span\r
-class=SpellE>Passthru</span> driver\92s <span class=SpellE>ProtocolPnPEvent</span>\r
-entry point (<span class=SpellE>PtPnPHandler</span>) whenever the underlying adapter\r
-is transitioned to a different power state. If the underlying adapter is\r
-transitioning to a low power state, the IM driver should wait for all\r
-outstanding sends and requests to complete.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>14) <b>NDIS 5.1 Features</b><o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>14.1 All NDIS 5.1 features in <span\r
-class=SpellE>Passthru</span> are identified by #<span class=SpellE>ifdef</span>\r
-NDIS51 compiler directives. The following major features are illustrated (refer\r
-to the DDK documentation for more information on these):<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><b><span\r
-style='font-size:10.0pt;font-family:Verdana'>Packet stacking</span></b><span\r
-style='font-size:10.0pt;font-family:Verdana'>: this allows an IM driver to\r
-reuse a packet submitted to its protocol or miniport edge to forward data down\r
-(or up) to the adjacent layer.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><b><span\r
-style='font-size:10.0pt;font-family:Verdana'>Canceling Sends</span></b><span\r
-style='font-size:10.0pt;font-family:Verdana'>: <span class=SpellE>Passthru</span>\r
-propagates send cancellations from protocols above it to lower <span\r
-class=SpellE>miniports</span>.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><b><span\r
-style='font-size:10.0pt;font-family:Verdana'>PnP Event Propagation</span></b><span\r
-style='font-size:10.0pt;font-family:Verdana'>: <span class=SpellE>Passthru</span>\r
-propagates PnP events arriving at its protocol (lower) edge to higher layer\r
-protocols that are bound to its virtual adapter.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-class=SpellE><b><span style='font-size:10.0pt;font-family:Verdana'>NdisQueryPendingIOCount</span></b></span><span\r
-style='font-size:10.0pt;font-family:Verdana'>: <span class=SpellE>Passthru</span>\r
-uses this new API to determine if any I/O operations are in progress on its\r
-lower binding.<o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'>15) For Win2K SP2 and <span\r
-class=SpellE>WinXP</span>, the <span class=SpellE>Passthru</span> sample no\r
-longer requires a Notify Object. The Notify Object has been removed. <o:p></o:p></span></p>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:10.0pt;font-family:Verdana'><span\r
-style='mso-spacerun:yes'> </span><o:p></o:p></span></p>\r
-\r
-<p align=center style='text-align:center;tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><a\r
-href="#top"><span style='font-size:10.0pt;font-family:Verdana'>Top of page</span></a><span\r
-style='font-size:10.0pt;font-family:Verdana'> <o:p></o:p></span></p>\r
-\r
-<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=624\r
- style='width:6.5in;mso-cellspacing:0in;mso-padding-alt:0in 0in 0in 0in'>\r
- <tr style='mso-yfti-irow:0;mso-yfti-lastrow:yes;height:1.5pt'>\r
-  <td style='background:aqua;padding:.75pt .75pt .75pt .75pt;height:1.5pt'>\r
-  <p class=MsoNormal><o:p>&nbsp;</o:p></p>\r
-  </td>\r
- </tr>\r
-</table>\r
-\r
-<p style='tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt'><span\r
-style='font-size:7.5pt;font-family:"MS Sans Serif"'>© 1999 Microsoft\r
-Corporation</span><span style='font-size:10.0pt;font-family:Verdana'> <o:p></o:p></span></p>\r
-\r
-</div>\r
-\r
-</body>\r
-\r
-</html>\r
-\r
diff --git a/original_passthru/passthru.rc b/original_passthru/passthru.rc
deleted file mode 100644 (file)
index 6ae427c..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <windows.h>\r
-#include <ntverp.h>\r
-\r
-/*-----------------------------------------------*/\r
-/* the following lines are specific to this file */\r
-/*-----------------------------------------------*/\r
-\r
-/* VER_FILETYPE, VER_FILESUBTYPE, VER_FILEDESCRIPTION_STR\r
- * and VER_INTERNALNAME_STR must be defined before including COMMON.VER\r
- * The strings don't need a '\0', since common.ver has them.\r
- */\r
-#define        VER_FILETYPE    VFT_DRV\r
-/* possible values:            VFT_UNKNOWN\r
-                               VFT_APP\r
-                               VFT_DLL\r
-                               VFT_DRV\r
-                               VFT_FONT\r
-                               VFT_VXD\r
-                               VFT_STATIC_LIB\r
-*/\r
-#define        VER_FILESUBTYPE VFT2_DRV_NETWORK\r
-/* possible values             VFT2_UNKNOWN\r
-                               VFT2_DRV_PRINTER\r
-                               VFT2_DRV_KEYBOARD\r
-                               VFT2_DRV_LANGUAGE\r
-                               VFT2_DRV_DISPLAY\r
-                               VFT2_DRV_MOUSE\r
-                               VFT2_DRV_NETWORK\r
-                               VFT2_DRV_SYSTEM\r
-                               VFT2_DRV_INSTALLABLE\r
-                               VFT2_DRV_SOUND\r
-                               VFT2_DRV_COMM\r
-*/\r
-#define VER_FILEDESCRIPTION_STR     "Sample NDIS 4.0 Intermediate Miniport Driver"\r
-#define VER_INTERNALNAME_STR        "PASSTHRU.SYS"\r
-#define VER_ORIGINALFILENAME_STR    "PASSTHRU.SYS"\r
-#define VER_LANGNEUTRAL\r
-\r
-#include "common.ver"\r
-\r
-\1a\r
diff --git a/original_passthru/precomp.h b/original_passthru/precomp.h
deleted file mode 100644 (file)
index b2870d1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma warning(disable:4214)   // bit field types other than int\r
-\r
-#pragma warning(disable:4201)   // nameless struct/union\r
-#pragma warning(disable:4115)   // named type definition in parentheses\r
-#pragma warning(disable:4127)   // conditional expression is constant\r
-#pragma warning(disable:4054)   // cast of function pointer to PVOID\r
-#pragma warning(disable:4244)   // conversion from 'int' to 'BOOLEAN', possible loss of data\r
-\r
-#include <ndis.h>\r
-#include "passthru.h"\r
-\r
diff --git a/original_passthru/protocol.c b/original_passthru/protocol.c
deleted file mode 100644 (file)
index 213924c..0000000
+++ /dev/null
@@ -1,1626 +0,0 @@
-/*++\r
-\r
-Copyright(c) 1992-2000  Microsoft Corporation\r
-\r
-Module Name:\r
-\r
-    protocol.c\r
-\r
-Abstract:\r
-\r
-    Ndis Intermediate Miniport driver sample. This is a passthru driver.\r
-\r
-Author:\r
-\r
-Environment:\r
-\r
-\r
-Revision History:\r
-\r
-\r
---*/\r
-\r
-\r
-#include "precomp.h"\r
-#pragma hdrstop\r
-\r
-#define MAX_PACKET_POOL_SIZE 0x0000FFFF\r
-#define MIN_PACKET_POOL_SIZE 0x000000FF\r
-\r
-//\r
-// NDIS version as 0xMMMMmmmm, where M=Major/m=minor (0x00050001 = 5.1); \r
-// initially unknown (0)\r
-// \r
-ULONG       NdisDotSysVersion =  0x0;\r
-\r
-\r
-#define NDIS_SYS_VERSION_51       0x00050001\r
-\r
-\r
-VOID\r
-PtBindAdapter(\r
-    OUT PNDIS_STATUS            Status,\r
-    IN  NDIS_HANDLE             BindContext,\r
-    IN  PNDIS_STRING            DeviceName,\r
-    IN  PVOID                   SystemSpecific1,\r
-    IN  PVOID                   SystemSpecific2\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Called by NDIS to bind to a miniport below.\r
-\r
-Arguments:\r
-\r
-    Status            - Return status of bind here.\r
-    BindContext        - Can be passed to NdisCompleteBindAdapter if this call is pended.\r
-    DeviceName         - Device name to bind to. This is passed to NdisOpenAdapter.\r
-    SystemSpecific1    - Can be passed to NdisOpenProtocolConfiguration to read per-binding information\r
-    SystemSpecific2    - Unused\r
-\r
-Return Value:\r
-\r
-    NDIS_STATUS_PENDING    if this call is pended. In this case call NdisCompleteBindAdapter\r
-    to complete.\r
-    Anything else          Completes this call synchronously\r
-\r
---*/\r
-{\r
-    NDIS_HANDLE                     ConfigHandle = NULL;\r
-    PNDIS_CONFIGURATION_PARAMETER   Param;\r
-    NDIS_STRING                     DeviceStr = NDIS_STRING_CONST("UpperBindings");\r
-    NDIS_STRING                     NdisVersionStr = NDIS_STRING_CONST("NdisVersion");\r
-    PADAPT                          pAdapt = NULL;\r
-    NDIS_STATUS                     Sts;\r
-    UINT                            MediumIndex;\r
-    ULONG                           TotalSize;\r
-    BOOLEAN                         NoCleanUpNeeded = FALSE;\r
-\r
-\r
-    UNREFERENCED_PARAMETER(BindContext);\r
-    UNREFERENCED_PARAMETER(SystemSpecific2);\r
-    \r
-    DBGPRINT(("==> Protocol BindAdapter\n"));\r
-\r
-    do\r
-    {\r
-        //\r
-        // Access the configuration section for our binding-specific\r
-        // parameters.\r
-        //\r
-        NdisOpenProtocolConfiguration(Status,\r
-                                       &ConfigHandle,\r
-                                       SystemSpecific1);\r
-\r
-        if (*Status != NDIS_STATUS_SUCCESS)\r
-        {\r
-            break;\r
-        }\r
-        if (NdisDotSysVersion == 0)\r
-        {\r
-            NdisReadConfiguration(Status,\r
-                                  &Param,\r
-                                  ConfigHandle,\r
-                                  &NdisVersionStr,        // "NdisVersion"\r
-                                  NdisParameterInteger);\r
-            if (*Status != NDIS_STATUS_SUCCESS)\r
-            {\r
-                break;\r
-            }\r
-            \r
-            NdisDotSysVersion = Param->ParameterData.IntegerData;\r
-        }\r
-                        \r
-\r
-        //\r
-        // Read the "UpperBindings" reserved key that contains a list\r
-        // of device names representing our miniport instances corresponding\r
-        // to this lower binding. Since this is a 1:1 IM driver, this key\r
-        // contains exactly one name.\r
-        //\r
-        // If we want to implement a N:1 mux driver (N adapter instances\r
-        // over a single lower binding), then UpperBindings will be a\r
-        // MULTI_SZ containing a list of device names - we would loop through\r
-        // this list, calling NdisIMInitializeDeviceInstanceEx once for\r
-        // each name in it.\r
-        //\r
-        NdisReadConfiguration(Status,\r
-                              &Param,\r
-                              ConfigHandle,\r
-                              &DeviceStr,\r
-                              NdisParameterString);\r
-        if (*Status != NDIS_STATUS_SUCCESS)\r
-        {\r
-            break;\r
-        }\r
-\r
-        //\r
-        // Allocate memory for the Adapter structure. This represents both the\r
-        // protocol context as well as the adapter structure when the miniport\r
-        // is initialized.\r
-        //\r
-        // In addition to the base structure, allocate space for the device\r
-        // instance string.\r
-        //\r
-        TotalSize = sizeof(ADAPT) + Param->ParameterData.StringData.MaximumLength;\r
-\r
-        NdisAllocateMemoryWithTag(&pAdapt, TotalSize, TAG);\r
-\r
-        if (pAdapt == NULL)\r
-        {\r
-            *Status = NDIS_STATUS_RESOURCES;\r
-            break;\r
-        }\r
-\r
-        //\r
-        // Initialize the adapter structure. We copy in the IM device\r
-        // name as well, because we may need to use it in a call to\r
-        // NdisIMCancelInitializeDeviceInstance. The string returned\r
-        // by NdisReadConfiguration is active (i.e. available) only\r
-        // for the duration of this call to our BindAdapter handler.\r
-        //\r
-        NdisZeroMemory(pAdapt, TotalSize);\r
-        pAdapt->DeviceName.MaximumLength = Param->ParameterData.StringData.MaximumLength;\r
-        pAdapt->DeviceName.Length = Param->ParameterData.StringData.Length;\r
-        pAdapt->DeviceName.Buffer = (PWCHAR)((ULONG_PTR)pAdapt + sizeof(ADAPT));\r
-        NdisMoveMemory(pAdapt->DeviceName.Buffer,\r
-                       Param->ParameterData.StringData.Buffer,\r
-                       Param->ParameterData.StringData.MaximumLength);\r
-\r
-\r
-\r
-        NdisInitializeEvent(&pAdapt->Event);\r
-        NdisAllocateSpinLock(&pAdapt->Lock);\r
-\r
-        //\r
-        // Allocate a packet pool for sends. We need this to pass sends down.\r
-        // We cannot use the same packet descriptor that came down to our send\r
-        // handler (see also NDIS 5.1 packet stacking).\r
-        //\r
-        NdisAllocatePacketPoolEx(Status,\r
-                                   &pAdapt->SendPacketPoolHandle,\r
-                                   MIN_PACKET_POOL_SIZE,\r
-                                   MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,\r
-                                   sizeof(SEND_RSVD));\r
-\r
-        if (*Status != NDIS_STATUS_SUCCESS)\r
-        {\r
-            break;\r
-        }\r
-\r
-        //\r
-        // Allocate a packet pool for receives. We need this to indicate receives.\r
-        // Same consideration as sends (see also NDIS 5.1 packet stacking).\r
-        //\r
-        NdisAllocatePacketPoolEx(Status,\r
-                                   &pAdapt->RecvPacketPoolHandle,\r
-                                   MIN_PACKET_POOL_SIZE,\r
-                                   MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,\r
-                                   PROTOCOL_RESERVED_SIZE_IN_PACKET);\r
-\r
-        if (*Status != NDIS_STATUS_SUCCESS)\r
-        {\r
-            break;\r
-        }\r
-\r
-        //\r
-        // Now open the adapter below and complete the initialization\r
-        //\r
-        NdisOpenAdapter(Status,\r
-                          &Sts,\r
-                          &pAdapt->BindingHandle,\r
-                          &MediumIndex,\r
-                          MediumArray,\r
-                          sizeof(MediumArray)/sizeof(NDIS_MEDIUM),\r
-                          ProtHandle,\r
-                          pAdapt,\r
-                          DeviceName,\r
-                          0,\r
-                          NULL);\r
-\r
-        if (*Status == NDIS_STATUS_PENDING)\r
-        {\r
-            NdisWaitEvent(&pAdapt->Event, 0);\r
-            *Status = pAdapt->Status;\r
-        }\r
-\r
-        if (*Status != NDIS_STATUS_SUCCESS)\r
-        {\r
-            break;\r
-        }\r
-        PtReferenceAdapt(pAdapt);\r
-\r
-#pragma prefast(suppress: __WARNING_POTENTIAL_BUFFER_OVERFLOW, "Ndis guarantees MediumIndex to be within bounds");\r
-        pAdapt->Medium = MediumArray[MediumIndex];\r
-\r
-        //\r
-        // Now ask NDIS to initialize our miniport (upper) edge.\r
-        // Set the flag below to synchronize with a possible call\r
-        // to our protocol Unbind handler that may come in before\r
-        // our miniport initialization happens.\r
-        //\r
-        pAdapt->MiniportInitPending = TRUE;\r
-        NdisInitializeEvent(&pAdapt->MiniportInitEvent);\r
-\r
-        PtReferenceAdapt(pAdapt);\r
-\r
-        *Status = NdisIMInitializeDeviceInstanceEx(DriverHandle,\r
-                                           &pAdapt->DeviceName,\r
-                                           pAdapt);\r
-\r
-        if (*Status != NDIS_STATUS_SUCCESS)\r
-        {\r
-            if (pAdapt->MiniportIsHalted == TRUE)\r
-            {\r
-                NoCleanUpNeeded = TRUE;\r
-            }\r
-            \r
-            DBGPRINT(("BindAdapter: Adapt %p, IMInitializeDeviceInstance error %x\n",\r
-                pAdapt, *Status));\r
-            \r
-            if (PtDereferenceAdapt(pAdapt))\r
-            {\r
-                pAdapt = NULL;\r
-            }\r
-            \r
-            break;\r
-        }\r
-        \r
-        PtDereferenceAdapt(pAdapt);\r
-\r
-    } while(FALSE);\r
-\r
-    //\r
-    // Close the configuration handle now - see comments above with\r
-    // the call to NdisIMInitializeDeviceInstanceEx.\r
-    //\r
-    if (ConfigHandle != NULL)\r
-    {\r
-        NdisCloseConfiguration(ConfigHandle);\r
-    }\r
-\r
-    if ((*Status != NDIS_STATUS_SUCCESS) && (NoCleanUpNeeded == FALSE))\r
-    {\r
-        if (pAdapt != NULL)\r
-        {\r
-            if (pAdapt->BindingHandle != NULL)\r
-            {\r
-                NDIS_STATUS    LocalStatus;\r
-\r
-                //\r
-                // Close the binding we opened above.\r
-                //\r
-\r
-                NdisResetEvent(&pAdapt->Event);\r
-                \r
-                NdisCloseAdapter(&LocalStatus, pAdapt->BindingHandle);\r
-                pAdapt->BindingHandle = NULL;\r
-\r
-                if (LocalStatus == NDIS_STATUS_PENDING)\r
-                {\r
-                     NdisWaitEvent(&pAdapt->Event, 0);\r
-                     LocalStatus = pAdapt->Status;\r
-\r
-                     \r
-                }\r
-                if (PtDereferenceAdapt(pAdapt))\r
-                {\r
-                     pAdapt = NULL;\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-\r
-    DBGPRINT(("<== Protocol BindAdapter: pAdapt %p, Status %x\n", pAdapt, *Status));\r
-}\r
-\r
-\r
-VOID\r
-PtOpenAdapterComplete(\r
-    IN  NDIS_HANDLE             ProtocolBindingContext,\r
-    IN  NDIS_STATUS             Status,\r
-    IN  NDIS_STATUS             OpenErrorStatus\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Completion routine for NdisOpenAdapter issued from within the PtBindAdapter. Simply\r
-    unblock the caller.\r
-\r
-Arguments:\r
-\r
-    ProtocolBindingContext    Pointer to the adapter\r
-    Status                    Status of the NdisOpenAdapter call\r
-    OpenErrorStatus            Secondary status(ignored by us).\r
-\r
-Return Value:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-    PADAPT      pAdapt =(PADAPT)ProtocolBindingContext;\r
-    \r
-    UNREFERENCED_PARAMETER(OpenErrorStatus);\r
-    \r
-    DBGPRINT(("==> PtOpenAdapterComplete: Adapt %p, Status %x\n", pAdapt, Status));\r
-    pAdapt->Status = Status;\r
-    NdisSetEvent(&pAdapt->Event);\r
-}\r
-\r
-\r
-VOID\r
-PtUnbindAdapter(\r
-    OUT PNDIS_STATUS           Status,\r
-    IN  NDIS_HANDLE            ProtocolBindingContext,\r
-    IN  NDIS_HANDLE            UnbindContext\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Called by NDIS when we are required to unbind to the adapter below.\r
-    This functions shares functionality with the miniport's HaltHandler.\r
-    The code should ensure that NdisCloseAdapter and NdisFreeMemory is called\r
-    only once between the two functions\r
-\r
-Arguments:\r
-\r
-    Status                    Placeholder for return status\r
-    ProtocolBindingContext    Pointer to the adapter structure\r
-    UnbindContext            Context for NdisUnbindComplete() if this pends\r
-\r
-Return Value:\r
-\r
-    Status for NdisIMDeinitializeDeviceContext\r
-\r
---*/\r
-{\r
-    PADAPT         pAdapt =(PADAPT)ProtocolBindingContext;\r
-    NDIS_STATUS    LocalStatus;\r
-\r
-    UNREFERENCED_PARAMETER(UnbindContext);\r
-    \r
-    DBGPRINT(("==> PtUnbindAdapter: Adapt %p\n", pAdapt));\r
-\r
-    //\r
-    // Set the flag that the miniport below is unbinding, so the request handlers will\r
-    // fail any request comming later\r
-    // \r
-    NdisAcquireSpinLock(&pAdapt->Lock);\r
-    pAdapt->UnbindingInProcess = TRUE;\r
-    if (pAdapt->QueuedRequest == TRUE)\r
-    {\r
-        pAdapt->QueuedRequest = FALSE;\r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-\r
-        PtRequestComplete(pAdapt,\r
-                         &pAdapt->Request,\r
-                         NDIS_STATUS_FAILURE );\r
-\r
-    }\r
-    else\r
-    {\r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-    }\r
-#ifndef WIN9X\r
-    //\r
-    // Check if we had called NdisIMInitializeDeviceInstanceEx and\r
-    // we are awaiting a call to MiniportInitialize.\r
-    //\r
-    if (pAdapt->MiniportInitPending == TRUE)\r
-    {\r
-        //\r
-        // Try to cancel the pending IMInit process.\r
-        //\r
-        LocalStatus = NdisIMCancelInitializeDeviceInstance(\r
-                        DriverHandle,\r
-                        &pAdapt->DeviceName);\r
-\r
-        if (LocalStatus == NDIS_STATUS_SUCCESS)\r
-        {\r
-            //\r
-            // Successfully cancelled IM Initialization; our\r
-            // Miniport Initialize routine will not be called\r
-            // for this device.\r
-            //\r
-            pAdapt->MiniportInitPending = FALSE;\r
-            ASSERT(pAdapt->MiniportHandle == NULL);\r
-        }\r
-        else\r
-        {\r
-            //\r
-            // Our Miniport Initialize routine will be called\r
-            // (may be running on another thread at this time).\r
-            // Wait for it to finish.\r
-            //\r
-            NdisWaitEvent(&pAdapt->MiniportInitEvent, 0);\r
-            ASSERT(pAdapt->MiniportInitPending == FALSE);\r
-        }\r
-\r
-    }\r
-#endif // !WIN9X\r
-\r
-    //\r
-    // Call NDIS to remove our device-instance. We do most of the work\r
-    // inside the HaltHandler.\r
-    //\r
-    // The Handle will be NULL if our miniport Halt Handler has been called or\r
-    // if the IM device was never initialized\r
-    //\r
-    \r
-    if (pAdapt->MiniportHandle != NULL)\r
-    {\r
-        *Status = NdisIMDeInitializeDeviceInstance(pAdapt->MiniportHandle);\r
-\r
-        if (*Status != NDIS_STATUS_SUCCESS)\r
-        {\r
-            *Status = NDIS_STATUS_FAILURE;\r
-        }\r
-    }\r
-    else\r
-    {\r
-        //\r
-        // We need to do some work here. \r
-        // Close the binding below us \r
-        // and release the memory allocated.\r
-        //\r
-        \r
-        if(pAdapt->BindingHandle != NULL)\r
-        {\r
-            NdisResetEvent(&pAdapt->Event);\r
-\r
-            NdisCloseAdapter(Status, pAdapt->BindingHandle);\r
-\r
-            //\r
-            // Wait for it to complete\r
-            //\r
-            if(*Status == NDIS_STATUS_PENDING)\r
-            {\r
-                 NdisWaitEvent(&pAdapt->Event, 0);\r
-                 *Status = pAdapt->Status;\r
-            }\r
-            pAdapt->BindingHandle = NULL;\r
-        }\r
-        else\r
-        {\r
-            //\r
-            // Both Our MiniportHandle and Binding Handle  should not be NULL.\r
-            //\r
-            *Status = NDIS_STATUS_FAILURE;\r
-            ASSERT(0);\r
-        }\r
-\r
-        //\r
-        //    Free the memory here, if was not released earlier(by calling the HaltHandler)\r
-        //\r
-        MPFreeAllPacketPools(pAdapt);\r
-        NdisFreeSpinLock(&pAdapt->Lock);\r
-        NdisFreeMemory(pAdapt, 0, 0);\r
-    }\r
-\r
-    DBGPRINT(("<== PtUnbindAdapter: Adapt %p\n", pAdapt));\r
-}\r
-\r
-VOID\r
-PtUnloadProtocol(\r
-    VOID\r
-)\r
-{\r
-    NDIS_STATUS Status;\r
-\r
-    if (ProtHandle != NULL)\r
-    {\r
-        NdisDeregisterProtocol(&Status, ProtHandle);\r
-        ProtHandle = NULL;\r
-    }\r
-\r
-    DBGPRINT(("PtUnloadProtocol: done!\n"));\r
-}\r
-\r
-\r
-\r
-VOID\r
-PtCloseAdapterComplete(\r
-    IN    NDIS_HANDLE            ProtocolBindingContext,\r
-    IN    NDIS_STATUS            Status\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Completion for the CloseAdapter call.\r
-\r
-Arguments:\r
-\r
-    ProtocolBindingContext    Pointer to the adapter structure\r
-    Status                    Completion status\r
-\r
-Return Value:\r
-\r
-    None.\r
-\r
---*/\r
-{\r
-    PADAPT      pAdapt =(PADAPT)ProtocolBindingContext;\r
-\r
-    DBGPRINT(("CloseAdapterComplete: Adapt %p, Status %x\n", pAdapt, Status));\r
-    pAdapt->Status = Status;\r
-    NdisSetEvent(&pAdapt->Event);\r
-}\r
-\r
-\r
-VOID\r
-PtResetComplete(\r
-    IN  NDIS_HANDLE            ProtocolBindingContext,\r
-    IN  NDIS_STATUS            Status\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Completion for the reset.\r
-\r
-Arguments:\r
-\r
-    ProtocolBindingContext    Pointer to the adapter structure\r
-    Status                    Completion status\r
-\r
-Return Value:\r
-\r
-    None.\r
-\r
---*/\r
-{\r
-\r
-    UNREFERENCED_PARAMETER(ProtocolBindingContext);\r
-    UNREFERENCED_PARAMETER(Status);\r
-    //\r
-    // We never issue a reset, so we should not be here.\r
-    //\r
-    ASSERT(0);\r
-}\r
-\r
-\r
-VOID\r
-PtRequestComplete(\r
-    IN  NDIS_HANDLE            ProtocolBindingContext,\r
-    IN  PNDIS_REQUEST          NdisRequest,\r
-    IN  NDIS_STATUS            Status\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Completion handler for the previously posted request. All OIDS\r
-    are completed by and sent to the same miniport that they were requested for.\r
-    If Oid == OID_PNP_QUERY_POWER then the data structure needs to returned with all entries =\r
-    NdisDeviceStateUnspecified\r
-\r
-Arguments:\r
-\r
-    ProtocolBindingContext    Pointer to the adapter structure\r
-    NdisRequest                The posted request\r
-    Status                    Completion status\r
-\r
-Return Value:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-    PADAPT        pAdapt = (PADAPT)ProtocolBindingContext;\r
-    NDIS_OID      Oid = pAdapt->Request.DATA.SET_INFORMATION.Oid ;\r
-\r
-    //\r
-    // Since our request is not outstanding anymore\r
-    //\r
-    ASSERT(pAdapt->OutstandingRequests == TRUE);\r
-\r
-    pAdapt->OutstandingRequests = FALSE;\r
-\r
-    //\r
-    // Complete the Set or Query, and fill in the buffer for OID_PNP_CAPABILITIES, if need be.\r
-    //\r
-    switch (NdisRequest->RequestType)\r
-    {\r
-      case NdisRequestQueryInformation:\r
-\r
-        //\r
-        // We never pass OID_PNP_QUERY_POWER down.\r
-        //\r
-        ASSERT(Oid != OID_PNP_QUERY_POWER);\r
-\r
-        if ((Oid == OID_PNP_CAPABILITIES) && (Status == NDIS_STATUS_SUCCESS))\r
-        {\r
-            MPQueryPNPCapabilities(pAdapt, &Status);\r
-        }\r
-        *pAdapt->BytesReadOrWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten;\r
-        *pAdapt->BytesNeeded = NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded;\r
-\r
-        if (((Oid == OID_GEN_MAC_OPTIONS) \r
-              && (Status == NDIS_STATUS_SUCCESS))\r
-              && (NdisDotSysVersion >= NDIS_SYS_VERSION_51))\r
-        {\r
-            //\r
-            // Only do this on Windows XP or greater (NDIS.SYS v 5.1); \r
-            // do not do in Windows 2000 (NDIS.SYS v 5.0))\r
-            //\r
-                \r
-            //\r
-            // Remove the no-loopback bit from mac-options. In essence we are\r
-            // telling NDIS that we can handle loopback. We don't, but the\r
-            // interface below us does. If we do not do this, then loopback\r
-            // processing happens both below us and above us. This is wasteful\r
-            // at best and if Netmon is running, it will see multiple copies\r
-            // of loopback packets when sniffing above us.\r
-            //\r
-            // Only the lowest miniport is a stack of layered miniports should\r
-            // ever report this bit set to NDIS.\r
-            //\r
-            *(PULONG)NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer &= ~NDIS_MAC_OPTION_NO_LOOPBACK;\r
-        }\r
-\r
-        NdisMQueryInformationComplete(pAdapt->MiniportHandle,\r
-                                      Status);\r
-        break;\r
-\r
-      case NdisRequestSetInformation:\r
-\r
-        ASSERT( Oid != OID_PNP_SET_POWER);\r
-\r
-        *pAdapt->BytesReadOrWritten = NdisRequest->DATA.SET_INFORMATION.BytesRead;\r
-        *pAdapt->BytesNeeded = NdisRequest->DATA.SET_INFORMATION.BytesNeeded;\r
-        NdisMSetInformationComplete(pAdapt->MiniportHandle,\r
-                                    Status);\r
-        break;\r
-\r
-      default:\r
-        ASSERT(0);\r
-        break;\r
-    }\r
-    \r
-}\r
-\r
-\r
-VOID\r
-PtStatus(\r
-    IN  NDIS_HANDLE         ProtocolBindingContext,\r
-    IN  NDIS_STATUS         GeneralStatus,\r
-    IN  PVOID               StatusBuffer,\r
-    IN  UINT                StatusBufferSize\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Status handler for the lower-edge(protocol).\r
-\r
-Arguments:\r
-\r
-    ProtocolBindingContext    Pointer to the adapter structure\r
-    GeneralStatus             Status code\r
-    StatusBuffer              Status buffer\r
-    StatusBufferSize          Size of the status buffer\r
-\r
-Return Value:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-    PADAPT      pAdapt = (PADAPT)ProtocolBindingContext;\r
-\r
-    //\r
-    // Pass up this indication only if the upper edge miniport is initialized\r
-    // and powered on. Also ignore indications that might be sent by the lower\r
-    // miniport when it isn't at D0.\r
-    //\r
-    if ((pAdapt->MiniportHandle != NULL)  &&\r
-        (pAdapt->MPDeviceState == NdisDeviceStateD0) &&\r
-        (pAdapt->PTDeviceState == NdisDeviceStateD0))    \r
-    {\r
-        if ((GeneralStatus == NDIS_STATUS_MEDIA_CONNECT) || \r
-            (GeneralStatus == NDIS_STATUS_MEDIA_DISCONNECT))\r
-        {\r
-            \r
-            pAdapt->LastIndicatedStatus = GeneralStatus;\r
-        }\r
-        NdisMIndicateStatus(pAdapt->MiniportHandle,\r
-                            GeneralStatus,\r
-                            StatusBuffer,\r
-                            StatusBufferSize);\r
-    }\r
-    //\r
-    // Save the last indicated media status \r
-    //\r
-    else\r
-    {\r
-        if ((pAdapt->MiniportHandle != NULL) && \r
-        ((GeneralStatus == NDIS_STATUS_MEDIA_CONNECT) || \r
-            (GeneralStatus == NDIS_STATUS_MEDIA_DISCONNECT)))\r
-        {\r
-            pAdapt->LatestUnIndicateStatus = GeneralStatus;\r
-        }\r
-    }\r
-    \r
-}\r
-\r
-\r
-VOID\r
-PtStatusComplete(\r
-    IN NDIS_HANDLE            ProtocolBindingContext\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-\r
-Arguments:\r
-\r
-\r
-Return Value:\r
-\r
-\r
---*/\r
-{\r
-    PADAPT      pAdapt = (PADAPT)ProtocolBindingContext;\r
-\r
-    //\r
-    // Pass up this indication only if the upper edge miniport is initialized\r
-    // and powered on. Also ignore indications that might be sent by the lower\r
-    // miniport when it isn't at D0.\r
-    //\r
-    if ((pAdapt->MiniportHandle != NULL)  &&\r
-        (pAdapt->MPDeviceState == NdisDeviceStateD0) &&\r
-        (pAdapt->PTDeviceState == NdisDeviceStateD0))    \r
-    {\r
-        NdisMIndicateStatusComplete(pAdapt->MiniportHandle);\r
-    }\r
-}\r
-\r
-\r
-VOID\r
-PtSendComplete(\r
-    IN  NDIS_HANDLE            ProtocolBindingContext,\r
-    IN  PNDIS_PACKET           Packet,\r
-    IN  NDIS_STATUS            Status\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Called by NDIS when the miniport below had completed a send. We should\r
-    complete the corresponding upper-edge send this represents.\r
-\r
-Arguments:\r
-\r
-    ProtocolBindingContext - Points to ADAPT structure\r
-    Packet - Low level packet being completed\r
-    Status - status of send\r
-\r
-Return Value:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-    PADAPT            pAdapt = (PADAPT)ProtocolBindingContext;\r
-    PNDIS_PACKET      Pkt; \r
-    NDIS_HANDLE       PoolHandle;\r
-\r
-#ifdef NDIS51\r
-    //\r
-    // Packet stacking:\r
-    //\r
-    // Determine if the packet we are completing is the one we allocated. If so, then\r
-    // get the original packet from the reserved area and completed it and free the\r
-    // allocated packet. If this is the packet that was sent down to us, then just\r
-    // complete it\r
-    //\r
-    PoolHandle = NdisGetPoolFromPacket(Packet);\r
-    if (PoolHandle != pAdapt->SendPacketPoolHandle)\r
-    {\r
-        //\r
-        // We had passed down a packet belonging to the protocol above us.\r
-        //\r
-        // DBGPRINT(("PtSendComp: Adapt %p, Stacked Packet %p\n", pAdapt, Packet));\r
-\r
-        NdisMSendComplete(pAdapt->MiniportHandle,\r
-                          Packet,\r
-                          Status);\r
-    }\r
-    else\r
-#endif // NDIS51\r
-    {\r
-        PSEND_RSVD        SendRsvd;\r
-\r
-        SendRsvd = (PSEND_RSVD)(Packet->ProtocolReserved);\r
-        Pkt = SendRsvd->OriginalPkt;\r
-    \r
-#ifndef WIN9X\r
-        NdisIMCopySendCompletePerPacketInfo (Pkt, Packet);\r
-#endif\r
-    \r
-        NdisDprFreePacket(Packet);\r
-\r
-        NdisMSendComplete(pAdapt->MiniportHandle,\r
-                                 Pkt,\r
-                                 Status);\r
-    }\r
-    //\r
-    // Decrease the outstanding send count\r
-    //\r
-    ADAPT_DECR_PENDING_SENDS(pAdapt);\r
-}       \r
-\r
-\r
-VOID\r
-PtTransferDataComplete(\r
-    IN  NDIS_HANDLE         ProtocolBindingContext,\r
-    IN  PNDIS_PACKET        Packet,\r
-    IN  NDIS_STATUS         Status,\r
-    IN  UINT                BytesTransferred\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Entry point called by NDIS to indicate completion of a call by us\r
-    to NdisTransferData.\r
-\r
-    See notes under SendComplete.\r
-\r
-Arguments:\r
-\r
-Return Value:\r
-\r
---*/\r
-{\r
-    PADAPT      pAdapt =(PADAPT)ProtocolBindingContext;\r
-\r
-    if(pAdapt->MiniportHandle)\r
-    {\r
-        NdisMTransferDataComplete(pAdapt->MiniportHandle,\r
-                                  Packet,\r
-                                  Status,\r
-                                  BytesTransferred);\r
-    }\r
-}\r
-\r
-\r
-NDIS_STATUS\r
-PtReceive(\r
-    IN  NDIS_HANDLE         ProtocolBindingContext,\r
-    IN  NDIS_HANDLE         MacReceiveContext,\r
-    IN  PVOID               HeaderBuffer,\r
-    IN  UINT                HeaderBufferSize,\r
-    IN  PVOID               LookAheadBuffer,\r
-    IN  UINT                LookAheadBufferSize,\r
-    IN  UINT                PacketSize\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Handle receive data indicated up by the miniport below. We pass\r
-    it along to the protocol above us.\r
-\r
-    If the miniport below indicates packets, NDIS would more\r
-    likely call us at our ReceivePacket handler. However we\r
-    might be called here in certain situations even though\r
-    the miniport below has indicated a receive packet, e.g.\r
-    if the miniport had set packet status to NDIS_STATUS_RESOURCES.\r
-        \r
-Arguments:\r
-\r
-    <see DDK ref page for ProtocolReceive>\r
-\r
-Return Value:\r
-\r
-    NDIS_STATUS_SUCCESS if we processed the receive successfully,\r
-    NDIS_STATUS_XXX error code if we discarded it.\r
-\r
---*/\r
-{\r
-    PADAPT            pAdapt = (PADAPT)ProtocolBindingContext;\r
-    PNDIS_PACKET      MyPacket, Packet = NULL;\r
-    NDIS_STATUS       Status = NDIS_STATUS_SUCCESS;\r
-    ULONG             Proc = KeGetCurrentProcessorNumber();      \r
-    \r
-    if ((!pAdapt->MiniportHandle) || (pAdapt->MPDeviceState > NdisDeviceStateD0))\r
-    {\r
-        Status = NDIS_STATUS_FAILURE;\r
-    }\r
-    else do\r
-    {\r
-        //\r
-        // Get at the packet, if any, indicated up by the miniport below.\r
-        //\r
-        Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext);\r
-        if (Packet != NULL)\r
-        {\r
-            //\r
-            // The miniport below did indicate up a packet. Use information\r
-            // from that packet to construct a new packet to indicate up.\r
-            //\r
-\r
-#ifdef NDIS51\r
-            //\r
-            // NDIS 5.1 NOTE: Do not reuse the original packet in indicating\r
-            // up a receive, even if there is sufficient packet stack space.\r
-            // If we had to do so, we would have had to overwrite the\r
-            // status field in the original packet to NDIS_STATUS_RESOURCES,\r
-            // and it is not allowed for protocols to overwrite this field\r
-            // in received packets.\r
-            //\r
-#endif // NDIS51\r
-\r
-            //\r
-            // Get a packet off the pool and indicate that up\r
-            //\r
-            NdisDprAllocatePacket(&Status,\r
-                                &MyPacket,\r
-                                pAdapt->RecvPacketPoolHandle);\r
-\r
-            if (Status == NDIS_STATUS_SUCCESS)\r
-            {\r
-                //\r
-                // Make our packet point to data from the original\r
-                // packet. NOTE: this works only because we are\r
-                // indicating a receive directly from the context of\r
-                // our receive indication. If we need to queue this\r
-                // packet and indicate it from another thread context,\r
-                // we will also have to allocate a new buffer and copy\r
-                // over the packet contents, OOB data and per-packet\r
-                // information. This is because the packet data\r
-                // is available only for the duration of this\r
-                // receive indication call.\r
-                //\r
-                NDIS_PACKET_FIRST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_FIRST_NDIS_BUFFER(Packet);\r
-                NDIS_PACKET_LAST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_LAST_NDIS_BUFFER(Packet);\r
-\r
-                //\r
-                // Get the original packet (it could be the same packet as the\r
-                // one received or a different one based on the number of layered\r
-                // miniports below) and set it on the indicated packet so the OOB\r
-                // data is visible correctly at protocols above.  If the IM driver \r
-                // modifies the packet in any way it should not set the new packet's\r
-                // original packet equal to the original packet of the packet that \r
-                // was indicated to it from the underlying driver, in this case, the \r
-                // IM driver should also ensure that the related per packet info should\r
-                // be copied to the new packet.\r
-                // we can set the original packet to the original packet of the packet\r
-                // indicated from the underlying driver because the driver doesn't modify\r
-                // the data content in the packet.\r
-                //\r
-                NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet));\r
-                NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize);\r
-\r
-                //\r
-                // Copy packet flags.\r
-                //\r
-                NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);\r
-\r
-                //\r
-                // Force protocols above to make a copy if they want to hang\r
-                // on to data in this packet. This is because we are in our\r
-                // Receive handler (not ReceivePacket) and we can't return a\r
-                // ref count from here.\r
-                //\r
-                NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);\r
-\r
-                //\r
-                // By setting NDIS_STATUS_RESOURCES, we also know that we can reclaim\r
-                // this packet as soon as the call to NdisMIndicateReceivePacket\r
-                // returns.\r
-                //\r
-\r
-                if (pAdapt->MiniportHandle != NULL)\r
-                {\r
-                    NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);\r
-                }\r
-\r
-                //\r
-                // Reclaim the indicated packet. Since we had set its status\r
-                // to NDIS_STATUS_RESOURCES, we are guaranteed that protocols\r
-                // above are done with it.\r
-                //\r
-                NdisDprFreePacket(MyPacket);\r
-\r
-                break;\r
-            }\r
-        }\r
-        else\r
-        {\r
-            //\r
-            // The miniport below us uses the old-style (not packet)\r
-            // receive indication. Fall through.\r
-            //\r
-        }\r
-\r
-        //\r
-        // Fall through if the miniport below us has either not\r
-        // indicated a packet or we could not allocate one\r
-        //\r
-        pAdapt->ReceivedIndicationFlags[Proc] = TRUE;\r
-        if (pAdapt->MiniportHandle == NULL)\r
-        {\r
-            break;\r
-        }\r
-        switch (pAdapt->Medium)\r
-        {\r
-            case NdisMedium802_3:\r
-            case NdisMediumWan:\r
-                NdisMEthIndicateReceive(pAdapt->MiniportHandle,\r
-                                             MacReceiveContext,\r
-                                             HeaderBuffer,\r
-                                             HeaderBufferSize,\r
-                                             LookAheadBuffer,\r
-                                             LookAheadBufferSize,\r
-                                             PacketSize);\r
-                break;\r
-\r
-            case NdisMedium802_5:\r
-                NdisMTrIndicateReceive(pAdapt->MiniportHandle,\r
-                                            MacReceiveContext,\r
-                                            HeaderBuffer,\r
-                                            HeaderBufferSize,\r
-                                            LookAheadBuffer,\r
-                                            LookAheadBufferSize,\r
-                                            PacketSize);\r
-                break;\r
-\r
-#if FDDI\r
-                 case NdisMediumFddi:\r
-                        NdisMFddiIndicateReceive(pAdapt->MiniportHandle,\r
-                                                                                         MacReceiveContext,\r
-                                                                                         HeaderBuffer,\r
-                                                                                         HeaderBufferSize,\r
-                                                                                         LookAheadBuffer,\r
-                                                                                         LookAheadBufferSize,\r
-                                                                                         PacketSize);\r
-                        break;\r
-#endif\r
-                 default:\r
-                        ASSERT(FALSE);\r
-                        break;\r
-               }\r
-\r
-    } while(FALSE);\r
-\r
-    return Status;\r
-}\r
-\r
-\r
-VOID\r
-PtReceiveComplete(\r
-    IN NDIS_HANDLE        ProtocolBindingContext\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Called by the adapter below us when it is done indicating a batch of\r
-    received packets.\r
-\r
-Arguments:\r
-\r
-    ProtocolBindingContext    Pointer to our adapter structure.\r
-\r
-Return Value:\r
-\r
-    None\r
-\r
---*/\r
-{\r
-    PADAPT        pAdapt =(PADAPT)ProtocolBindingContext;\r
-    ULONG         Proc = KeGetCurrentProcessorNumber();      \r
-\r
-    if (((pAdapt->MiniportHandle != NULL)\r
-                && (pAdapt->MPDeviceState == NdisDeviceStateD0))\r
-                && (pAdapt->ReceivedIndicationFlags[Proc]))\r
-    {\r
-        switch (pAdapt->Medium)\r
-        {\r
-            case NdisMedium802_3:\r
-            case NdisMediumWan:\r
-                NdisMEthIndicateReceiveComplete(pAdapt->MiniportHandle);\r
-                break;\r
-\r
-                 case NdisMedium802_5:\r
-                       NdisMTrIndicateReceiveComplete(pAdapt->MiniportHandle);\r
-                       break;\r
-#if FDDI\r
-                 case NdisMediumFddi:\r
-                       NdisMFddiIndicateReceiveComplete(pAdapt->MiniportHandle);\r
-                       break;\r
-#endif\r
-                 default:\r
-                       ASSERT(FALSE);\r
-                       break;\r
-               }\r
-       }\r
-\r
-    pAdapt->ReceivedIndicationFlags[Proc] = FALSE;\r
-}\r
-\r
-\r
-INT\r
-PtReceivePacket(\r
-    IN NDIS_HANDLE            ProtocolBindingContext,\r
-    IN PNDIS_PACKET           Packet\r
-    )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    ReceivePacket handler. Called by NDIS if the miniport below supports\r
-    NDIS 4.0 style receives. Re-package the buffer chain in a new packet\r
-    and indicate the new packet to protocols above us. Any context for\r
-    packets indicated up must be kept in the MiniportReserved field.\r
-\r
-    NDIS 5.1 - packet stacking - if there is sufficient "stack space" in\r
-    the packet passed to us, we can use the same packet in a receive\r
-    indication.\r
-\r
-Arguments:\r
-\r
-    ProtocolBindingContext - Pointer to our adapter structure.\r
-    Packet - Pointer to the packet\r
-\r
-Return Value:\r
-\r
-    == 0 -> We are done with the packet\r
-    != 0 -> We will keep the packet and call NdisReturnPackets() this\r
-            many times when done.\r
---*/\r
-{\r
-    PADAPT              pAdapt =(PADAPT)ProtocolBindingContext;\r
-    NDIS_STATUS         Status;\r
-    PNDIS_PACKET        MyPacket;\r
-    BOOLEAN             Remaining;\r
-\r
-    //\r
-    // Drop the packet silently if the upper miniport edge isn't initialized or\r
-    // the miniport edge is in low power state\r
-    //\r
-    if ((!pAdapt->MiniportHandle) || (pAdapt->MPDeviceState > NdisDeviceStateD0))\r
-    {\r
-          return 0;\r
-    }\r
-\r
-#ifdef NDIS51\r
-    //\r
-    // Check if we can reuse the same packet for indicating up.\r
-    // See also: PtReceive(). \r
-    //\r
-    (VOID)NdisIMGetCurrentPacketStack(Packet, &Remaining);\r
-    if (Remaining)\r
-    {\r
-        //\r
-        // We can reuse "Packet". Indicate it up and be done with it.\r
-        //\r
-        Status = NDIS_GET_PACKET_STATUS(Packet);\r
-        NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &Packet, 1);\r
-        return((Status != NDIS_STATUS_RESOURCES) ? 1 : 0);\r
-    }\r
-#endif // NDIS51\r
-\r
-    //\r
-    // Get a packet off the pool and indicate that up\r
-    //\r
-    NdisDprAllocatePacket(&Status,\r
-                           &MyPacket,\r
-                           pAdapt->RecvPacketPoolHandle);\r
-\r
-    if (Status == NDIS_STATUS_SUCCESS)\r
-    {\r
-        PRECV_RSVD            RecvRsvd;\r
-\r
-        RecvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);\r
-        RecvRsvd->OriginalPkt = Packet;\r
-\r
-        NDIS_PACKET_FIRST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_FIRST_NDIS_BUFFER(Packet);\r
-        NDIS_PACKET_LAST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_LAST_NDIS_BUFFER(Packet);\r
-\r
-        //\r
-        // Get the original packet (it could be the same packet as the one\r
-        // received or a different one based on the number of layered miniports\r
-        // below) and set it on the indicated packet so the OOB data is visible\r
-        // correctly to protocols above us.\r
-        //\r
-        NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet));\r
-\r
-        //\r
-        // Set Packet Flags\r
-        //\r
-        NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);\r
-\r
-        Status = NDIS_GET_PACKET_STATUS(Packet);\r
-\r
-        NDIS_SET_PACKET_STATUS(MyPacket, Status);\r
-        NDIS_SET_PACKET_HEADER_SIZE(MyPacket, NDIS_GET_PACKET_HEADER_SIZE(Packet));\r
-\r
-        if (pAdapt->MiniportHandle != NULL)\r
-        {\r
-            NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);\r
-        }\r
-\r
-        //\r
-        // Check if we had indicated up the packet with NDIS_STATUS_RESOURCES\r
-        // NOTE -- do not use NDIS_GET_PACKET_STATUS(MyPacket) for this since\r
-        // it might have changed! Use the value saved in the local variable.\r
-        //\r
-        if (Status == NDIS_STATUS_RESOURCES)\r
-        {\r
-            //\r
-            // Our ReturnPackets handler will not be called for this packet.\r
-            // We should reclaim it right here.\r
-            //\r
-            NdisDprFreePacket(MyPacket);\r
-        }\r
-\r
-        return((Status != NDIS_STATUS_RESOURCES) ? 1 : 0);\r
-    }\r
-    else\r
-    {\r
-        //\r
-        // We are out of packets. Silently drop it.\r
-        //\r
-        return(0);\r
-    }\r
-}\r
-\r
-\r
-NDIS_STATUS\r
-PtPNPHandler(\r
-    IN NDIS_HANDLE        ProtocolBindingContext,\r
-    IN PNET_PNP_EVENT     pNetPnPEvent\r
-    )\r
-\r
-/*++\r
-Routine Description:\r
-\r
-    This is called by NDIS to notify us of a PNP event related to a lower\r
-    binding. Based on the event, this dispatches to other helper routines.\r
-\r
-    NDIS 5.1: forward this event to the upper protocol(s) by calling\r
-    NdisIMNotifyPnPEvent.\r
-\r
-Arguments:\r
-\r
-    ProtocolBindingContext - Pointer to our adapter structure. Can be NULL\r
-                for "global" notifications\r
-\r
-    pNetPnPEvent - Pointer to the PNP event to be processed.\r
-\r
-Return Value:\r
-\r
-    NDIS_STATUS code indicating status of event processing.\r
-\r
---*/\r
-{\r
-    PADAPT            pAdapt  =(PADAPT)ProtocolBindingContext;\r
-    NDIS_STATUS       Status  = NDIS_STATUS_SUCCESS;\r
-\r
-    DBGPRINT(("PtPnPHandler: Adapt %p, Event %d\n", pAdapt, pNetPnPEvent->NetEvent));\r
-\r
-    switch (pNetPnPEvent->NetEvent)\r
-    {\r
-        case NetEventSetPower:\r
-            Status = PtPnPNetEventSetPower(pAdapt, pNetPnPEvent);\r
-            break;\r
-\r
-         case NetEventReconfigure:\r
-            Status = PtPnPNetEventReconfigure(pAdapt, pNetPnPEvent);\r
-            break;\r
-\r
-         default:\r
-#ifdef NDIS51\r
-            //\r
-            // Pass on this notification to protocol(s) above, before\r
-            // doing anything else with it.\r
-            //\r
-            if (pAdapt && pAdapt->MiniportHandle)\r
-            {\r
-                Status = NdisIMNotifyPnPEvent(pAdapt->MiniportHandle, pNetPnPEvent);\r
-            }\r
-#else\r
-            Status = NDIS_STATUS_SUCCESS;\r
-\r
-#endif // NDIS51\r
-\r
-            break;\r
-    }\r
-\r
-    return Status;\r
-}\r
-\r
-\r
-NDIS_STATUS\r
-PtPnPNetEventReconfigure(\r
-    IN PADAPT            pAdapt,\r
-    IN PNET_PNP_EVENT    pNetPnPEvent\r
-    )\r
-/*++\r
-Routine Description:\r
-\r
-    This routine is called from NDIS to notify our protocol edge of a\r
-    reconfiguration of parameters for either a specific binding (pAdapt\r
-    is not NULL), or global parameters if any (pAdapt is NULL).\r
-\r
-Arguments:\r
-\r
-    pAdapt - Pointer to our adapter structure.\r
-    pNetPnPEvent - the reconfigure event\r
-\r
-Return Value:\r
-\r
-    NDIS_STATUS_SUCCESS\r
-\r
---*/\r
-{\r
-    NDIS_STATUS    ReconfigStatus = NDIS_STATUS_SUCCESS;\r
-    NDIS_STATUS    ReturnStatus = NDIS_STATUS_SUCCESS;\r
-\r
-    do\r
-    {\r
-        //\r
-        // Is this is a global reconfiguration notification ?\r
-        //\r
-        if (pAdapt == NULL)\r
-        {\r
-            //\r
-            // An important event that causes this notification to us is if\r
-            // one of our upper-edge miniport instances was enabled after being\r
-            // disabled earlier, e.g. from Device Manager in Win2000. Note that\r
-            // NDIS calls this because we had set up an association between our\r
-            // miniport and protocol entities by calling NdisIMAssociateMiniport.\r
-            //\r
-            // Since we would have torn down the lower binding for that miniport,\r
-            // we need NDIS' assistance to re-bind to the lower miniport. The\r
-            // call to NdisReEnumerateProtocolBindings does exactly that.\r
-            //\r
-            NdisReEnumerateProtocolBindings (ProtHandle);        \r
-            \r
-            break;\r
-        }\r
-\r
-#ifdef NDIS51\r
-        //\r
-        // Pass on this notification to protocol(s) above before doing anything\r
-        // with it.\r
-        //\r
-        if (pAdapt->MiniportHandle)\r
-        {\r
-            ReturnStatus = NdisIMNotifyPnPEvent(pAdapt->MiniportHandle, pNetPnPEvent);\r
-        }\r
-#endif // NDIS51\r
-\r
-        ReconfigStatus = NDIS_STATUS_SUCCESS;\r
-\r
-    } while(FALSE);\r
-\r
-    DBGPRINT(("<==PtPNPNetEventReconfigure: pAdapt %p\n", pAdapt));\r
-\r
-#ifdef NDIS51\r
-    //\r
-    // Overwrite status with what upper-layer protocol(s) returned.\r
-    //\r
-    ReconfigStatus = ReturnStatus;\r
-#endif\r
-\r
-    return ReconfigStatus;\r
-}\r
-\r
-\r
-NDIS_STATUS\r
-PtPnPNetEventSetPower(\r
-    IN PADAPT            pAdapt,\r
-    IN PNET_PNP_EVENT    pNetPnPEvent\r
-    )\r
-/*++\r
-Routine Description:\r
-\r
-    This is a notification to our protocol edge of the power state\r
-    of the lower miniport. If it is going to a low-power state, we must\r
-    wait here for all outstanding sends and requests to complete.\r
-\r
-    NDIS 5.1:  Since we use packet stacking, it is not sufficient to\r
-    check usage of our local send packet pool to detect whether or not\r
-    all outstanding sends have completed. For this, use the new API\r
-    NdisQueryPendingIOCount.\r
-\r
-    NDIS 5.1: Use the 5.1 API NdisIMNotifyPnPEvent to pass on PnP\r
-    notifications to upper protocol(s).\r
-\r
-Arguments:\r
-\r
-    pAdapt            -    Pointer to the adpater structure\r
-    pNetPnPEvent    -    The Net Pnp Event. this contains the new device state\r
-\r
-Return Value:\r
-\r
-    NDIS_STATUS_SUCCESS or the status returned by upper-layer protocols.\r
-\r
---*/\r
-{\r
-    PNDIS_DEVICE_POWER_STATE       pDeviceState  =(PNDIS_DEVICE_POWER_STATE)(pNetPnPEvent->Buffer);\r
-    NDIS_DEVICE_POWER_STATE        PrevDeviceState = pAdapt->PTDeviceState;  \r
-    NDIS_STATUS                    Status;\r
-    NDIS_STATUS                    ReturnStatus;\r
-\r
-    ReturnStatus = NDIS_STATUS_SUCCESS;\r
-\r
-    //\r
-    // Set the Internal Device State, this blocks all new sends or receives\r
-    //\r
-    NdisAcquireSpinLock(&pAdapt->Lock);\r
-    pAdapt->PTDeviceState = *pDeviceState;\r
-\r
-    //\r
-    // Check if the miniport below is going to a low power state.\r
-    //\r
-    if (pAdapt->PTDeviceState > NdisDeviceStateD0)\r
-    {\r
-        //\r
-        // If the miniport below is going to standby, fail all incoming requests\r
-        //\r
-        if (PrevDeviceState == NdisDeviceStateD0)\r
-        {\r
-            pAdapt->StandingBy = TRUE;\r
-        }\r
-\r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-\r
-#ifdef NDIS51\r
-        //\r
-        // Notify upper layer protocol(s) first.\r
-        //\r
-        if (pAdapt->MiniportHandle != NULL)\r
-        {\r
-            ReturnStatus = NdisIMNotifyPnPEvent(pAdapt->MiniportHandle, pNetPnPEvent);\r
-        }\r
-#endif // NDIS51\r
-\r
-        //\r
-        // Wait for outstanding sends and requests to complete.\r
-        //\r
-        while (pAdapt->OutstandingSends != 0)\r
-        {\r
-            NdisMSleep(2);\r
-        }\r
-\r
-        while (pAdapt->OutstandingRequests == TRUE)\r
-        {\r
-            //\r
-            // sleep till outstanding requests complete\r
-            //\r
-            NdisMSleep(2);\r
-        }\r
-\r
-        //\r
-        // If the below miniport is going to low power state, complete the queued request\r
-        //\r
-        NdisAcquireSpinLock(&pAdapt->Lock);\r
-        if (pAdapt->QueuedRequest)\r
-        {\r
-            pAdapt->QueuedRequest = FALSE;\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-            PtRequestComplete(pAdapt, &pAdapt->Request, NDIS_STATUS_FAILURE);\r
-        }\r
-        else\r
-        {\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-        }\r
-            \r
-\r
-        ASSERT(NdisPacketPoolUsage(pAdapt->SendPacketPoolHandle) == 0);\r
-        ASSERT(pAdapt->OutstandingRequests == FALSE);\r
-    }\r
-    else\r
-    {\r
-        //\r
-        // If the physical miniport is powering up (from Low power state to D0), \r
-        // clear the flag\r
-        //\r
-        if (PrevDeviceState > NdisDeviceStateD0)\r
-        {\r
-            pAdapt->StandingBy = FALSE;\r
-        }\r
-        //\r
-        // The device below is being turned on. If we had a request\r
-        // pending, send it down now.\r
-        //\r
-        if (pAdapt->QueuedRequest == TRUE)\r
-        {\r
-            pAdapt->QueuedRequest = FALSE;\r
-        \r
-            pAdapt->OutstandingRequests = TRUE;\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-\r
-            NdisRequest(&Status,\r
-                        pAdapt->BindingHandle,\r
-                        &pAdapt->Request);\r
-\r
-            if (Status != NDIS_STATUS_PENDING)\r
-            {\r
-                PtRequestComplete(pAdapt,\r
-                                  &pAdapt->Request,\r
-                                  Status);\r
-                \r
-            }\r
-        }\r
-        else\r
-        {\r
-            NdisReleaseSpinLock(&pAdapt->Lock);\r
-        }\r
-\r
-\r
-#ifdef NDIS51\r
-        //\r
-        // Pass on this notification to protocol(s) above\r
-        //\r
-        if (pAdapt->MiniportHandle)\r
-        {\r
-            ReturnStatus = NdisIMNotifyPnPEvent(pAdapt->MiniportHandle, pNetPnPEvent);\r
-        }\r
-#endif // NDIS51\r
-\r
-    }\r
-\r
-    return ReturnStatus;\r
-}\r
-\r
-VOID\r
-PtReferenceAdapt(\r
-    IN PADAPT     pAdapt\r
-    )\r
-{\r
-    NdisAcquireSpinLock(&pAdapt->Lock);\r
-    \r
-    ASSERT(pAdapt->RefCount >= 0);\r
-\r
-    pAdapt->RefCount ++;\r
-    NdisReleaseSpinLock(&pAdapt->Lock);\r
-}\r
-\r
-\r
-BOOLEAN\r
-PtDereferenceAdapt(\r
-    IN PADAPT     pAdapt\r
-    )\r
-{\r
-    NdisAcquireSpinLock(&pAdapt->Lock);\r
-\r
-    ASSERT(pAdapt->RefCount > 0);\r
-\r
-    pAdapt->RefCount--;\r
-\r
-    if (pAdapt->RefCount == 0)\r
-    {\r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-        \r
-        //\r
-        // Free all resources on this adapter structure.\r
-        //\r
-        MPFreeAllPacketPools (pAdapt);;\r
-        NdisFreeSpinLock(&pAdapt->Lock);\r
-        NdisFreeMemory(pAdapt, 0 , 0);\r
-        \r
-        return TRUE;\r
-        \r
-    }\r
-    else\r
-    {\r
-        NdisReleaseSpinLock(&pAdapt->Lock);\r
-\r
-        return FALSE;\r
-    }\r
-}\r
-\r
-\r
diff --git a/original_passthru/sources b/original_passthru/sources
deleted file mode 100644 (file)
index d52d78f..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-TARGETNAME=passthru\r
-TARGETTYPE=DRIVER\r
-\r
-C_DEFINES=$(C_DEFINES) -DNDIS_MINIPORT_DRIVER -DNDIS_WDM=1\r
-\r
-MSC_WARNING_LEVEL=/WX /W4\r
-\r
-!if "$(DDK_TARGET_OS)"=="Win2K"\r
-#\r
-# The driver is built in the Win2K build environment\r
-#\r
-C_DEFINES=$(C_DEFINES) -DNDIS40_MINIPORT=1\r
-C_DEFINES=$(C_DEFINES) -DNDIS40=1\r
-!else \r
-#\r
-# The driver is built in the XP or .NET build environment\r
-# So let us build NDIS 5.1 version.\r
-#\r
-C_DEFINES=$(C_DEFINES) -DNDIS51_MINIPORT=1\r
-C_DEFINES=$(C_DEFINES) -DNDIS51=1\r
-!endif\r
-\r
-# Uncomment the following to build for Win98/SE/WinMe\r
-# This causes several APIs that are not present in Win9X to be\r
-# ifdef'ed out.\r
-# C_DEFINES=$(C_DEFINES) -DWIN9X=1\r
-\r
-PRECOMPILED_INCLUDE=precomp.h\r
-\r
-TARGETLIBS=$(DDK_LIB_PATH)\ndis.lib\r
-\r
-INCLUDES=\r
-\r
-SOURCES=\\r
-    miniport.c \\r
-    passthru.c \\r
-    passthru.rc \\r
-    protocol.c\r
-\r