Sending a UDP packet using TDI at IRQL == DISPATCH_LEVEL

Discussion in 'Windows Vista Drivers' started by wolverine, Apr 18, 2006.

  1. wolverine

    wolverine Guest

    Hi,

    I am writing a kernel mode driver from which I need to send a UDP
    packet to a remote machine. I need to be doing it in a handler at IRQL
    == DISPATCH_LEVEL, possibly using TDI since that seems a simpler
    approach.

    Now, TDI documentation suggests ZwCreateFile -> TDIBuildxxx ->
    IoCallDriver approach but, most of the mentioned functions can be
    called only at IRQL==PASSIVE_LEVEL.

    Is there a way out? Please help!
     
    wolverine, Apr 18, 2006
    #1
    1. Advertisements

  2. wolverine

    Jeff Henkels Guest

    You might try having the driver hand off the sending of the packet to a
    user-mode service -- use the inverted-call technique.
     
    Jeff Henkels, Apr 18, 2006
    #2
    1. Advertisements

  3. Surely there is.

    First of all, IoCallDriver can be called at IRQL <= DISPATCH_LEVEL. So, you
    can use that.

    TdiBuildInternalDeviceControlIrp must be called at IRQL == PASSIVE_LEVEL.
    So, there is a problem there. However, you can do one of these things:

    1.) Build your own IRP by calling IoAllocateIrp (which can be called at IRQL
    <= DISPATCH_LEVEL) and initializing your allocated IRP. Then call
    TdiBuildSendDatagram with this IRP.
    2.) Pre-allocate the IRPs at some point in your driver when you are at IRQL
    == PASSIVE_LEVEL.
    3.) Start a worker thread to do the send. Worker threads run at IRQL ==
    PASSIVE_LEVEL.

    For ZwCreateFile - simply open the handle at some earlier point when you are
    safely at IRQL == PASSIVE_LEVEL.

    Good luck,

    Thomas F. Divine, Windows DDK MVP
    http://www.pcausa.com
     
    Thomas F. Divine [DDK MVP], Apr 18, 2006
    #3
  4. First of all, IoCallDriver can be called at IRQL <= DISPATCH_LEVEL. So, you
    Yes, this way really works, and my old kernel sockets code used it on
    DISPATCH_LEVEL.
     
    Maxim S. Shatskih, Apr 19, 2006
    #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.