TDI and IRP dispatch context

Discussion in 'Windows Vista Drivers' started by h.wulff, May 1, 2005.

  1. h.wulff

    h.wulff Guest

    Hello,

    I have a Device I/O Control that connects to a remote machine using TDI.
    When the connection is successfully established I can send and receive
    Data. This works fine in this IRP dispatch context. But when this
    dispatch routine has finished, the remote host says "Connection reset by
    peer".

    I believe this is because the process (the IRP dispatch context of the
    NET.EXE command) has finished and all open handles are closed by the
    system.

    My question is how can I have one TDI connection in different IRP
    dispatch contexts?

    My idea is to start a System Thread inside the DriverEntry() routine,
    that the different IRP dispatch contexts processes talk to, i.e. System
    Thread (inside the System Process) and NET.EXE Process.
    Or this there an easier way?

    Thank you for your efforts!
     
    h.wulff, May 1, 2005
    #1
    1. Advertisements

  2. Create the connection (I mean ZwCreateFile/ObReferenceObjectByHandle) from
    ExQueueWorkItem callback.
    The file object pointer - and thus the rest of TDI work - can be used from
    any process context.
    ZwClose in the very end will also require ExQueueWorkItem callback, unless
    you will use OBJ_KERNEL_HANDLE flag - which exists in w2k and later.
     
    Maxim S. Shatskih, May 1, 2005
    #2
    1. Advertisements

  3. h.wulff

    h.wulff Guest

    Hello,

    Thanks! This was quite a good idea... :)
     
    h.wulff, May 3, 2005
    #3
  4. If the TDI file objects are not to be associated with the current process
    (current at the time of the ZwCreateFile) you should specify the
    OBJ_KERNEL_HANDLE flag in the ObjectAttributes structure passed to
    ZwCreateFile. This will ensure that the I/O manager allocates a kernel mode
    handle that is meaningful in all process contexts. The file object will not
    be closed until you close the handle (and any duplicates of the handle).

    You do not need to running in the context of the System process (as in a
    work-item callback) to do this but it does not hurt.

    Good Luck,
    Dave Cattley
    Consulting Engineer
    Systems Software Development
     
    David R. Cattley, May 7, 2005
    #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.