BindAdapterHandler for WDM/ NDIS protocol driver not called

Discussion in 'Windows Vista Drivers' started by QuasiCodo, Sep 19, 2003.

  1. QuasiCodo

    QuasiCodo Guest

    On XP, I have a WDM driver which uses the PnP mechanism to load. Once
    loaded, I called NdisRegisterProtocol to register the protocol portion of
    the driver with NDIS. The problem I am having is the my
    BindAdapterHandler() is not being called. The PnpEventHandler() is being
    called with NetPnpEvent->NetEvent set to NetEventBindsComplete (i.e. NDIS
    tells me that all bindings for this protocol have been performed).

    A BindsComplete indication without any BindAdapterHandler() callbacks is
    what I would expect if I had not installed the protocol in the system.
    However, I have a separate INF file in which I install the protocol.
    BindView shows this that my protocol is installed and bound to the NIC card.

    The only thing I can think of is that protocol identifier in the INF file
    does not match the protocol name I gave to NdisRegisterProtocol().

    Any ideas?

    ((&-<
     
    QuasiCodo, Sep 19, 2003
    #1
    1. Advertisements

  2. If you installed the driver via an INF (and, yes, the name passed in
    NdisRegisterProtocol MUST match the name under Services in the INF -- see
    the documentation for Name in NdisRegisterProtocol), then the binding
    engine will run and determine the miniports that you should bind to. In
    that case, NDIS will load you automatically and, after you call
    NdisRegisterProtocol, it will call your bind handler for each adapter the
    binding engine (part of the network class installer) has previously
    identified as a binding partner during the install phase.

    If you're just dynamically loading and the class installer doesn't have a
    record of any bindings for you, then it won't call your bind adapter
    handler at all. Further, as far as it's concerned, it completed all
    bindings for you -- thus the NetEventBindsComplete message.

    When your bind handler is called NDIS passes you the name of the adapter.
    As you know, you take that string and pass it to NdisOpenAdapter. In past
    versions, it was possible to call NdisOpenAdapter during DriverEntry -- for
    cases where you already knew the adapter name. However, this is no longer
    supported. See the comments in the DDK documentation for NdisOpenAdapter.

    HTH,

    Bryan S. Burgin


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Bryan S. Burgin [MSFT], Sep 20, 2003
    #2
    1. Advertisements

  3. QuasiCodo

    QuasiCodo Guest

    Basically this is what I have:

    I started with the WinDDK 3790 Toaster example. From this sample, I use
    BusEnum.sys, Toaster.sys (from the Featured2 directory) and Enum.exe.

    First I install BusEnum by installing a new device (Add New HW, etc...).

    Next I run "enum -p 1" from the cmd line. This loads Toaster.sys.

    In ToasterStartDevice(), I call NdisRegisterProtocol(). The Protocol Name
    (aka ComponentID) that I am registering is "WFA_PROTO_3". The registration
    succeeds OK, but ProtocolBindAdapter() is never called and
    ProtocolPnpEventHandler() with NetPnpEvent->NetEvent ==
    NetEventBindsComplete is called.

    I also created a new INF file (PROTOCOL.INF) which defines a protocol the
    Component ID WFA_PROTO_3. I install this protocol INF file manually from
    the Local Area Connection Properties. After the protocol installation,
    ProtocolBindAdapter() is still not called.

    It doesn't matter if the protocol is installed before or after Toaster.sys
    is loaded, ProtocolBindAdapter() is still never called.
    Do you suggest that I need to make the class installer (network?) aware that
    my WDM driver is a protocol. How is this done?

    I assumed the following INF statements would properly inform NDIS about the
    protocol:

    [WfaProto]
    %PACKET_Desc%=CTMProto, WFA_PROTO_3

    and

    [CTMProto_reg]
    HKR,Ndi,Service,,"Toaster"

    I am starting to suspect that only root enumerated devices are allowed to
    have protocols. If you look at the WinDDK 3790 NdisProt example, this
    driver is root enumerated. In WinDbg, !devnode 0 1 reveals that "Toaster"
    is a child to the root enumerated device "BusEnum". Perhaps I should put
    "BusEnum" as the service in the INF file.

    Thanks,

    ((&-<

    PS Here is a listing of my protocol registration routine and my
    PROTOCOL.INF:

    // NOTE: Put this in FdoData later
    HANDLE ProtocolHandle = NULL;

    NTSTATUS
    RegisterProtocol (
    IN PFDO_DATA FdoData)
    {
    NTSTATUS status = STATUS_SUCCESS;
    NDIS_PROTOCOL_CHARACTERISTICS protocolChar;
    NDIS_STRING protoName = NDIS_STRING_CONST("WFA_PROTO_3");
    int i;

    DbgPrint("RegisterProtocol\n");
    _asm int 3;

    // Check if we are already registered
    if (ProtocolHandle != NULL)
    {
    DbgPrint("Protocol already registered\n");
    return (STATUS_SUCCESS);
    }

    // Initialize the NDIS Protocol Characteristics structure
    RtlZeroMemory (&protocolChar, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
    protocolChar.MajorNdisVersion = 5;
    protocolChar.MinorNdisVersion = 0;
    protocolChar.OpenAdapterCompleteHandler = ProtocolOpenAdapterComplete;
    protocolChar.CloseAdapterCompleteHandler = ProtocolCloseAdapterComplete;
    protocolChar.SendCompleteHandler = ProtocolSendComplete;
    protocolChar.TransferDataCompleteHandler = ProtocolTransferDataComplete;
    protocolChar.ResetCompleteHandler = ProtocolResetComplete;
    protocolChar.RequestCompleteHandler = ProtocolRequestComplete;
    protocolChar.ReceiveHandler = ProtocolReceiveIndicate;
    protocolChar.ReceiveCompleteHandler = ProtocolReceiveComplete;
    protocolChar.StatusHandler = ProtocolStatus;
    protocolChar.StatusCompleteHandler = ProtocolStatusComplete;
    protocolChar.Name = protoName;
    protocolChar.ReceivePacketHandler = NULL;
    protocolChar.BindAdapterHandler = ProtocolBindAdapter;
    protocolChar.UnbindAdapterHandler = ProtocolUnBindAdapter;
    protocolChar.PnPEventHandler = ProtocolPnPEvent;
    protocolChar.UnloadHandler = ProtocolUnload;

    // Register the protocol with NDIS
    NdisRegisterProtocol(
    (PNDIS_STATUS)&status,
    &ProtocolHandle,
    &protocolChar,
    sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
    if (status != NDIS_STATUS_SUCCESS)
    {
    DbgPrint("NdisRegisterProtocol FAILED, status = %x\n", status);
    return status;
    }
    DbgPrint("Protocol successfully registered, protocol handle = %x\n",
    ProtocolHandle);

    return status;
    }


    ;-------------------------------------------------------------------------
    ; Protocol.inf
    ;
    ; WFA Protocol 3 INF.
    ;
    ;-------------------------------------------------------------------------
    [version]
    Signature = "$Windows NT$"
    Class = NetTrans
    ClassGUID = {4d36e975-e325-11ce-bfc1-08002be10318}
    Provider = %WfaCorp%
    DriverVer = 03/12/2003,1.00

    [Manufacturer]
    %WfaCorp%=WfaProto

    [WfaProto]
    %PACKET_Desc%=CTMProto, WFA_PROTO_3

    ;-------------------------------------------------------------------------
    ; Installation Section
    ;-------------------------------------------------------------------------
    [CTMProto]
    AddReg=CTMProto_reg
    Characteristics=0 ; Has no characterstic

    ;-------------------------------------------------------------------------
    ; Ndi installation support
    ;-------------------------------------------------------------------------
    [CTMProto_reg]
    HKR,Ndi,Service,,"Toaster"
    HKR,Ndi,HelpText,,%PACKET_HelpText%
    HKR, Ndi\Interfaces, UpperRange,, noupper
    HKR,"Ndi\Interfaces","LowerRange",,"ndis5,ndis4"

    [Strings]
    PACKET_Desc = "WFA Protocol 3"
    PACKET_HelpText = "WFA Protocol 3 NDIS Module"
    REG_DWORD = 0x10001
    WfaCorp="WFA Corporation"
     
    QuasiCodo, Sep 22, 2003
    #3
  4. QuasiCodo

    QuasiCodo Guest

    Got it working. Apparently, you must specify the name of the protocol to be
    the exact name of the driver .sys file. In this case, I changed:

    NDIS_STRING protoName = NDIS_STRING_CONST("WFA_PROTO_3");

    to

    NDIS_STRING protoName = NDIS_STRING_CONST("TOASTER");

    Now my ProtocolBindAdapter() routine is called! ((&->

    This problem was that I thought that the INF device ID had to match the
    ProtocolName. But in reality, what really matters is that the ProtocolName
    must be the name of the driver .sys file name.
     
    QuasiCodo, Sep 22, 2003
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.