Calling NdisSend

Discussion in 'Windows Vista Drivers' started by Peter Schmitz, Mar 24, 2007.

  1. Hi,

    I've got some driver development problem I really cannot solve:

    I'm trying to call NdisSend in the ProtocolReceive handler of a NDIS IM
    driver (don't ask me why I do this - just testing). Of course, I have created
    a duplicate of the packet I got through NdisGetReceivedPacket - but when I
    try to send my duplicate the system crashes. No blue screen, no memory dump,
    nothing. does anyone know why this could happen?

    thanks a lot,

    Peter Schmitz, Mar 24, 2007
    1. Advertisements

  2. What do you mean when you say that "You created a duplicate"? Do you mean
    that you allocated your own non-paged memory for the packet bytes and copied
    the original packet's data to your memory. Then you allocated your own
    NDIS_BUFFER, allocated and initialized your own NDIS_PACKET (from the
    sending adapter's send packet pool)?

    Or, something less than an actual duplicate...

    When your send completes do yolu take care not to call NdisMSendComplete for
    your own packet? That would cause a problem because you would be telling the
    higher-level protocol about completion of a packet that the higher-level
    protocol actually did not send.

    Do you test the return from NdisGetReceivedPacket? That that does not always
    fetch a packet.

    There are a lot of issues that you must understand to get this right.

    In any event, get a debugger and debug the problem.

    Thomas F. Divine
    Thomas F. Divine, Mar 24, 2007
    1. Advertisements

  3. Peter Schmitz

    Anton Bassov Guest

    First of all, if you mean bouncing off exactly the same data to miniport,
    then the whole concept is flawed in itself solely because of discepancy in
    MAC header - you are asking NIC to send data to itself...

    This is purely about the logic behind the whole thing. Now let's proceed to
    NDIS part.

    First of all, NdisGetReceivedPacket() call will be successfull only if
    miniport relies upon multipacket indications - otherwise, you have to
    retrieve packet data with NdisTransferData(). Are you sure that your call to
    NdisGetReceivedPacket() is successfull???

    Assuming that it is, what do you mean by "duplicate"??? What info do you
    copy from the original packet descriptor? Do you copy data from the packet's
    buffer into your own one, or you just specify the same buffer, i.e. do things
    the way you do it when indicating packets? Please note that the original
    packet's buffer is owned by miniport and not by your driver - this is why
    it is valid only for the duration of ProtocolReceive() call. Therefore,
    specifying this buffer in outgoing packet is quite dodgy thing, so to say....

    Furthermore, if you are speaking about NDIS IM, then SendComplete() has to
    make a distinction between packets that IM sends on its own initiative and
    the ones that have been originated by the bound protocols. Are you sure that
    you made provisions here???

    As you can see, there are quite a few things to consider, so that we need a
    bit more info - it is hard to say anything without seeing your code....

    Anton Bassov
    Anton Bassov, Mar 24, 2007
  4. Peter,

    just to add something to what Anton and Thomas said, the easiest way to
    understand what's going on is to attach a debugger and see where it actually
    crashes. Since you are developing a software only driver (NDIS IM), for this
    kind of problems the fastest way to debug is using a virtual machine for the
    testing and the host as the debugger. It's usually my preferred debugging
    strategy when I don't need to deal with performance or synchronization

    Have a nice day
    Gianluca Varenni, Mar 26, 2007
    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.