TDI driver

TDI driver is a legacy NT driver. not WDM driver I
suppose.Then in the TdiDispatchRoutines how does it
call lower NDIS drivers?(in WDM driver model it passes
the IRP the lower driver in the stack…is it same for
TDI driver as well)

— Arlie Davis wrote:

> The thing that irritates me, is that I used
> build.exe for years as a
> Microsoft employee to build every conceivable type
> of component. I know
> what it is capable of doing, and although it might
> not be perfect, it is
> good for building a large tree of components in a
> consistent, predictable,
> and automatable way. And it is far better than
> hand-crafted makefiles,
> because “sources” files are far more declarative
> than makefiles are.
>
> I realize the priority of the DDK is device drivers.
> But device drivers
> rarely exist in a vacuum; there is nearly always
> some user-mode component
> nearby. Which is why I would like to be able to
> build all my components
> with it – nice, clean, consistent builds, no
> frills, and all command-line
> driven.
>
> Oh well. The consensus appears to be that the
> subset of the Platform DK
> that is shipped with the DDK is not sufficient for
> building many user-mode
> apps (such as those with an ATL dependency). I can
> accept that. What I
> wanted was definite knowledge, and this thread has
> given me that – thanks
> for the responses, everyone.
>
> At times I have been frustrated, as both a Microsoft
> developer and as a
> non-Microsoft developer, that Microsoft does not
> make available some of its
> development tools that would be quite useful to
> developers who are already
> committed to Microsoft platforms. Build.exe (and
> related friends, such as
> the missing and beloved binplace.exe) isn’t
> beautiful, but it is very
> useful. (Oh, just checked, and binplace was added
> to DDK 3790. Hmm! Time
> to investigate!)
>
> – arlie
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf
> Of Alberto Moreira
> Sent: Saturday, September 24, 2005 10:41 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] ATL build problem, zmouse.h
>
> Michal,
>
> I don’t think it’s a good idea to develop or build
> applications from the DDK
> because the support it offers is far too limited,
> and hence you need to put
> up a lot of additional work. Moreover the DDK
> environment may be
> “controlled” for drivers, but not for
> applications: it leaves much to be desired.
>
> Also, an app should not use DDK headers. If you have
> a set including drivers
> and apps, the correct thing to do is to write a few
> app-safe include files
> that encapsulate the minimum functionality that the
> app and the driver must
> share, and you stop at that point: a few defines and
> Ioctl layouts should
> suffice.
>
> Now, the OS is not an application, hence, it may be
> the case that build.exe
> is feasible to build it; although I’m pretty sure
> that they’d save a lot of
> money if they switched to using the MSVC.NET tools
> they themselves created.
>
> One last thing: build.exe is just a wrapper around
> nmake, and I myself have
> never been able to make the transition. I’d rather
> use nmake than build, if
> nothing else because using nmake makes me feel in
> control. Solutions and
> projects, however, are also no more than containers
> around nmake, but
> they’re a lot more flexible and they save a lot of
> work. You know, the
> difference is like writing drivers in C++ instead of
> machine code; there’s
> got to be some purists out there who still think
> assembler is best for
> drivers and for OS work, but after Unix that school
> of thought has been
> proven inadequate. The same thing happens with
> command-line tools! This is
> the GUI era.
>
>
> Alberto.
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

__________________________________
Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
> TDI driver is a legacy NT driver. not WDM driver I
> suppose.Then in the TdiDispatchRoutines how does it
> call lower NDIS drivers?(in WDM driver model it passes
> the IRP the lower driver in the stack…is it same for
> TDI driver as well)
>
Depends on what kind of “TDI Driver” you are thinking of.

The TCP/IP “transport driver” registers as a NDIS protocol on it’s
lower-edge. That provides the capability to send/receive network packets. It
registers with TDI to expose an upper-edge TDI interface for TCP, UDP, etc.
to the rest of the system.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.pcausa.com

I want to write “legacy” NT TDI driver & TDI client. Now suppose TDI client want to send datagram(connectionless). It will open transport address. Then for sending data it will call TdiBuildInternalDeviceControlIrp() & then tdiBuildSendDatagram(with manor function codeTDI_SEND_DATAGRAM). So now my drivers InternalControldispatchroutine will be called.
Now my question is how to pass the IRP to the lower drivers in dispatch routine? (as this is a legacy driver I dint attach it in any stack so how can I pass this to NDIS)

“Thomas F. Divine” wrote:

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
> TDI driver is a legacy NT driver. not WDM driver I
> suppose.Then in the TdiDispatchRoutines how does it
> call lower NDIS drivers?(in WDM driver model it passes
> the IRP the lower driver in the stack…is it same for
> TDI driver as well)
>
Depends on what kind of “TDI Driver” you are thinking of.

The TCP/IP “transport driver” registers as a NDIS protocol on it’s
lower-edge. That provides the capability to send/receive network packets. It
registers with TDI to expose an upper-edge TDI interface for TCP, UDP, etc.
to the rest of the system.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.pcausa.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Amlan,

The good news is that you do not need to. NDIS Protocols do not pass IRPs
to NDIS but instead pass NDIS Packets, a completely independent structure.
I recommend that you review carefully the DDK sample (from 2K3 SP1 DDK)
NDISPROT to see how to manage using the MDL from an IRP to generate an NDIS
Packet to send or how to take a recieved NDIS Packet and copy the data from
it into a buffer provided by a pending IRP.

I also recommend that you get the NT4 DDK and study the sample TDI Transport
Driver in that DDK. It is a complete sample which shows many of the typical
techniques for handling packets, bindings, etc. in a TDI Transport Driver.
When you have become comfortable with what can be learned from that sample,
I recommend that you search the Microsoft Research web site for the TCPIP6
driver project for NT4 and download the source code. This is a much more
sophisticated TDI transport implementation.

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Amlan Mandal
Sent: Tuesday, September 27, 2005 2:09 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] TDI driver

I want to write “legacy” NT TDI driver & TDI client. Now suppose TDI client
want to send datagram(connectionless). It will open transport address. Then
for sending data it will call TdiBuildInternalDeviceControlIrp() & then
tdiBuildSendDatagram(with manor function codeTDI_SEND_DATAGRAM). So now my
drivers InternalControldispatchroutine will be called.
Now my question is how to pass the IRP to the lower drivers in dispatch
routine? (as this is a legacy driver I dint attach it in any stack so how
can I pass this to NDIS)

“Thomas F. Divine” wrote:

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
> TDI driver is a legacy NT driver. not WDM driver I
> suppose.Then in the TdiDispatchRoutines how does it
> call lower NDIS drivers?(in WDM driver model it passes
> the IRP the lower driver in the stack…is it same for
> TDI driver as well)
>
Depends on what kind of “TDI Driver” you are thinking of.

The TCP/IP “transport driver” registers as a NDIS protocol on it’s
lower-edge. That provides the capability to send/receive network packets. It

registers with TDI to expose an upper-edge TDI interface for TCP, UDP, etc.
to the rest of the system.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.pcausa.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com — Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 You are currently subscribed to
ntdev as: xxxxx@msn.com To unsubscribe send a blank email to
xxxxx@lists.osr.com

tnaks a lot for David for ur valuable suggestion

“David R. Cattley” wrote:Amlan,

The good news is that you do not need to. NDIS Protocols do not pass IRPs to NDIS but instead pass NDIS Packets, a completely independent structure. I recommend that you review carefully the DDK sample (from 2K3 SP1 DDK) NDISPROT to see how to manage using the MDL from an IRP to generate an NDIS Packet to send or how to take a recieved NDIS Packet and copy the data from it into a buffer provided by a pending IRP.

I also recommend that you get the NT4 DDK and study the sample TDI Transport Driver in that DDK. It is a complete sample which shows many of the typical techniques for handling packets, bindings, etc. in a TDI Transport Driver. When you have become comfortable with what can be learned from that sample, I recommend that you search the Microsoft Research web site for the TCPIP6 driver project for NT4 and download the source code. This is a much more sophisticated TDI transport implementation.

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development

---------------------------------
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Amlan Mandal
Sent: Tuesday, September 27, 2005 2:09 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] TDI driver

I want to write “legacy” NT TDI driver & TDI client. Now suppose TDI client want to send datagram(connectionless). It will open transport address. Then for sending data it will call TdiBuildInternalDeviceControlIrp() & then tdiBuildSendDatagram(with manor function codeTDI_SEND_DATAGRAM). So now my drivers InternalControldispatchroutine will be called.
Now my question is how to pass the IRP to the lower drivers in dispatch routine? (as this is a legacy driver I dint attach it in any stack so how can I pass this to NDIS)

“Thomas F. Divine” wrote:

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
> TDI driver is a legacy NT driver. not WDM driver I
> suppose.Then in the TdiDispatchRoutines how does it
> call lower NDIS drivers?(in WDM driver model it passes
> the IRP the lower driver in the stack…is it same for
> TDI driver as well)
>
Depends on what kind of “TDI Driver” you are thinking of.

The TCP/IP “transport driver” registers as a NDIS protocol on it’s
lower-edge. That provides the capability to send/receive network packets. It
registers with TDI to expose an upper-edge TDI interface for TCP, UDP, etc.
to the rest of the system.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.pcausa.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@msn.com To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.

Thanks a lot David for ur valuable suggestion

“David R. Cattley” wrote: Amlan,

The good news is that you do not need to. NDIS Protocols do not pass IRPs to NDIS but instead pass NDIS Packets, a completely independent structure. I recommend that you review carefully the DDK sample (from 2K3 SP1 DDK) NDISPROT to see how to manage using the MDL from an IRP to generate an NDIS Packet to send or how to take a recieved NDIS Packet and copy the data from it into a buffer provided by a pending IRP.

I also recommend that you get the NT4 DDK and study the sample TDI Transport Driver in that DDK. It is a complete sample which shows many of the typical techniques for handling packets, bindings, etc. in a TDI Transport Driver. When you have become comfortable with what can be learned from that sample, I recommend that you search the Microsoft Research web site for the TCPIP6 driver project for NT4 and download the source code. This is a much more sophisticated TDI transport implementation.

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development

---------------------------------
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Amlan Mandal
Sent: Tuesday, September 27, 2005 2:09 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] TDI driver

I want to write “legacy” NT TDI driver & TDI client. Now suppose TDI client want to send datagram(connectionless). It will open transport address. Then for sending data it will call TdiBuildInternalDeviceControlIrp() & then tdiBuildSendDatagram(with manor function codeTDI_SEND_DATAGRAM). So now my drivers InternalControldispatchroutine will be called.
Now my question is how to pass the IRP to the lower drivers in dispatch routine? (as this is a legacy driver I dint attach it in any stack so how can I pass this to NDIS)

“Thomas F. Divine” wrote:

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
> TDI driver is a legacy NT driver. not WDM driver I
> suppose.Then in the TdiDispatchRoutines how does it
> call lower NDIS drivers?(in WDM driver model it passes
> the IRP the lower driver in the stack…is it same for
> TDI driver as well)
>
Depends on what kind of “TDI Driver” you are thinking of.

The TCP/IP “transport driver” registers as a NDIS protocol on it’s
lower-edge. That provides the capability to send/receive network packets. It
registers with TDI to expose an upper-edge TDI interface for TCP, UDP, etc.
to the rest of the system.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.pcausa.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@msn.com To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

I want to write TDI client. My question is can TCP/IP9tcp.sys) driver work as “TDI driver provider”. I mean can I send data to network from my client without writing any TDI driver provider.

Example: Suppose I want to open transport address. I initialize my OBJECTS _ATTRIBUTE with \device\tcp & with ZwCreareFile call open transport adreess,. Then send data through data through connection point in connectionless or connectionoriented mode in KERNEL LEVEL


Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
I want to write TDI client. My question is can TCP/IP9tcp.sys) driver work as “TDI driver provider”. I mean can I send data to network from my client without writing any TDI driver provider.

Example: Suppose I want to open transport address. I initialize my OBJECTS _ATTRIBUTE with \device\tcp & with ZwCreareFile call open transport adreess,. Then send data through data through connection point in connectionless or connectionoriented mode in KERNEL LEVEL

Yes, your TDI client can open TCP connections and send/receive TCP streans as well as send and receive UDP datagrams while in kernel mode.

Thomas F. Divine, Windows DDK MVP

http://www.pcausa.com

------------------------------------------------------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.

Thanks Thomas.
I have one more question. Now suppose I want to send UDP datagrams from my client, then to call IoCallDriver() from my client I need DeviceObject.(IRP will be built by TdiBuildInternalControlDeviceirp) My question is how or what function to use to get the device object from \Device\UDP (the device name)

Once gain thanks in advance
Amlan

“Thomas F. Divine” wrote:

“Amlan Mandal” wrote in message news:xxxxx@ntdev…

I want to write TDI client. My question is can TCP/IP9tcp.sys) driver work as “TDI driver provider”. I mean can I send data to network from my client without writing any TDI driver provider.

Example: Suppose I want to open transport address. I initialize my OBJECTS _ATTRIBUTE with \device\tcp & with ZwCreareFile call open transport adreess,. Then send data through data through connection point in connectionless or connectionoriented mode in KERNEL LEVEL

Yes, your TDI client can open TCP connections and send/receive TCP streans as well as send and receive UDP datagrams while in kernel mode.

Thomas F. Divine, Windows DDK MVP

http://www.pcausa.com

---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
Thanks Thomas.
I have one more question. Now suppose I want to send UDP datagrams from my client, then to call IoCallDriver() from my client I need DeviceObject.(IRP will be built by TdiBuildInternalControlDeviceirp) My question is how or what function to use to get the device object from \Device\UDP (the device name)

Once gain thanks in advance
Amlan

That would be ObReferenceObjectByHandle.

Thomas F. Divine, Windows DDK MVP
http://www.rawether.net

Amlan,

I think that Thomas might have thought you were wondering how to get the
DeviceObject from the handle returned by ZwCreateFile() and
ObReferenceObjectByHandle() will allow you to get an ObjectPointer to the
FileObject from which you can get the DeviceObject by calling
IoGetRelatedDeviceObject().

If you are just trying to get the DeviceObject of \Device\UDP, you can get
it with IoGetDeviceObjectPointer(). However, the returned FileObject will
*not* be a TDI Address File object (it will be a ‘control’ object).

With UDP, just as with TCP (and any TDI Transport) you must create a TDI
Address File Object with ZwCreateFile() and specify the appropriate EA
argument, in the case of UDP it would be TdiTransportAddress
(“TransportAddress”).

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Thomas F. Divine
Sent: Wednesday, September 28, 2005 10:26 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Re:TDI driver

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
Thanks Thomas.
I have one more question. Now suppose I want to send UDP datagrams from my
client, then to call IoCallDriver() from my client I need DeviceObject.(IRP
will be built by TdiBuildInternalControlDeviceirp) My question is how or
what function to use to get the device object from \Device\UDP (the device
name)

Once gain thanks in advance
Amlan

That would be ObReferenceObjectByHandle.

Thomas F. Divine, Windows DDK MVP
http://www.rawether.net


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks Dave for your elaborate answer. Can I call IoSetCompletetion routine from my “TDI client” function?. I should elaborate. In my TDI SetHandler routine I call IoDriver. If IoCallDriver sends status STATUS_PENDING I have to block the thread with some event(of type Kevent)
So now can I set some completion routine with IoSetCompletion routine so that it will be called when IRP is done to signal the event & unblock my event set handler routine.

Thanks in advance
Amlan

“David R. Cattley” wrote:
Amlan,

I think that Thomas might have thought you were wondering how to get the DeviceObject from the handle returned by ZwCreateFile() and ObReferenceObjectByHandle() will allow you to get an ObjectPointer to the FileObject from which you can get the DeviceObject by calling IoGetRelatedDeviceObject().

If you are just trying to get the DeviceObject of \Device\UDP, you can get it with IoGetDeviceObjectPointer(). However, the returned FileObject will not be a TDI Address File object (it will be a ‘control’ object).

With UDP, just as with TCP (and any TDI Transport) you must create a TDI Address File Object with ZwCreateFile() and specify the appropriate EA argument, in the case of UDP it would be TdiTransportAddress (“TransportAddress”).

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development

---------------------------------
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Thomas F. Divine
Sent: Wednesday, September 28, 2005 10:26 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Re:TDI driver

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
Thanks Thomas.
I have one more question. Now suppose I want to send UDP datagrams from my client, then to call IoCallDriver() from my client I need DeviceObject.(IRP will be built by TdiBuildInternalControlDeviceirp) My question is how or what function to use to get the device object from \Device\UDP (the device name)

Once gain thanks in advance
Amlan

That would be ObReferenceObjectByHandle.

Thomas F. Divine, Windows DDK MVP
http://www.rawether.net


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.

Amlan,

Whether or not you can set an I/O completion routine is determined by how
you allocate the IRP. The IRP must have a IO_STACK_LOCATION allocated and
available for *your* driver for it to be possible to call
IoSetCompletionRoutine(). The

In a typical TDI Client implemenation, the client will allocate IRPs using
IoAllocateIrp() and specify that the I/O stack size in the IRP should be one
greater than the I/O stack requirement of the target device object (the
transport). After setting up the IRP, the client copies the current I/O
stack location to the next I/O stack location, advances the I/O stack
pointer, and sets a completion routine. When the CRTN is called, the client
sets an event (or other procesing) and then returns STATUS_MORE_PROCESSING
required to prevent the I/O Manager from continuing IRP completion (it would
break if it did continue). The CRTN then either frees the IRP or prepares
it to be reused.

I recomend that you search for a TDI client example in source code . If you
have the IFS kit for NT4 (or later, I presume) it has a TDI Client
implemenation for use with network redirectors. I believe that Thomas still
sells a TDI client sample - see http://www.pcausa.com.

The following articles may be of some interest as they cover quite a bit
about handling IRPs.

http://support.microsoft.com/default.aspx?scid=kb;en-us;320275
http://support.microsoft.com/default.aspx?scid=kb;en-us;326315
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndevice/ht
ml/IRP_Handle.asp

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Amlan Mandal
Sent: Thursday, September 29, 2005 4:42 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Re:TDI driver

Thanks Dave for your elaborate answer. Can I call IoSetCompletetion routine
from my “TDI client” function?. I should elaborate. In my TDI SetHandler
routine I call IoDriver. If IoCallDriver sends status STATUS_PENDING I have
to block the thread with some event(of type Kevent)
So now can I set some completion routine with IoSetCompletion routine so
that it will be called when IRP is done to signal the event & unblock my
event set handler routine.

Thanks in advance
Amlan

“David R. Cattley” wrote:

Amlan,

I think that Thomas might have thought you were wondering how to get the
DeviceObject from the handle returned by ZwCreateFile() and
ObReferenceObjectByHandle() will allow you to get an ObjectPointer to the
FileObject from which you can get the DeviceObject by calling
IoGetRelatedDeviceObject().

If you are just trying to get the DeviceObject of \Device\UDP, you can get
it with IoGetDeviceObjectPointer(). However, the returned FileObject will
not be a TDI Address File object (it will be a ‘control’ object).

With UDP, just as with TCP (and any TDI Transport) you must create a TDI
Address File Object with ZwCreateFile() and specify the appropriate EA
argument, in the case of UDP it would be TdiTransportAddress
(“TransportAddress”).

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development



From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Thomas F. Divine
Sent: Wednesday, September 28, 2005 10:26 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Re:TDI driver

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
Thanks Thomas.
I have one more question. Now suppose I want to send UDP datagrams from my
client, then to call IoCallDriver() from my client I need DeviceObject.(IRP
will be built by TdiBuildInternalControlDeviceirp) My question is how or
what function to use to get the device object from \Device\UDP (the device
name)

Once gain thanks in advance
Amlan

That would be ObReferenceObjectByHandle.

Thomas F. Divine, Windows DDK MVP
http://www.rawether.net http:</http:>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com



Yahoo! for Good
Click here http:</http:> to donate to the
Hurricane Katrina relief effort. — Questions? First check the Kernel
Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently
subscribed to ntdev as: xxxxx@msn.com To unsubscribe send a blank email
to xxxxx@lists.osr.com

Is TdiBuildInternalDeviceControlIrp is a synchnous call? If it is NOT then as this if follwed by TdiBuildXxx routines t& then IoCallDriver() I have to sunchonize it .How to do it if I cant set Completion routine
Is the following Code OK inside Tdi_SetHandler Routine(assming TdiBuildInternalDeviceControlIrp a synchronous call)
***************************************************************************************************

pIrp = TdiBuildInternalDeviceControlIrp(TDI_SET_EVENT_HANDLER, pTdiDevice, pfoTdiFileObject, &event, &IoStatusBlock);

if(pIrp)
{
/*
* Step 2: Set the IRP Parameters
*/
TdiBuildSetEventHandler(pIrp, pTdiDevice, pfoTdiFileObject, NULL, NULL, InEventType, InEventHandler, InEventContext);

NtStatus = IoCallDriver(pTdiDevice, pIrp);

if(NtStatus == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
/*
* Find the Status of the completed IRP
*/

NtStatus = IoStatusBlock.Status;
}
}
return NtStatus
***************************************************************************************************

“David R. Cattley” wrote:
Amlan,

Whether or not you can set an I/O completion routine is determined by how you allocate the IRP. The IRP must have a IO_STACK_LOCATION allocated and available for your driver for it to be possible to call IoSetCompletionRoutine(). The

In a typical TDI Client implemenation, the client will allocate IRPs using IoAllocateIrp() and specify that the I/O stack size in the IRP should be one greater than the I/O stack requirement of the target device object (the transport). After setting up the IRP, the client copies the current I/O stack location to the next I/O stack location, advances the I/O stack pointer, and sets a completion routine. When the CRTN is called, the client sets an event (or other procesing) and then returns STATUS_MORE_PROCESSING required to prevent the I/O Manager from continuing IRP completion (it would break if it did continue). The CRTN then either frees the IRP or prepares it to be reused.

I recomend that you search for a TDI client example in source code . If you have the IFS kit for NT4 (or later, I presume) it has a TDI Client implemenation for use with network redirectors. I believe that Thomas still sells a TDI client sample - see http://www.pcausa.com.

The following articles may be of some interest as they cover quite a bit about handling IRPs.

http://support.microsoft.com/default.aspx?scid=kb;en-us;320275
http://support.microsoft.com/default.aspx?scid=kb;en-us;326315
http://msdn.microsoft.com/library/defaultasp?url=/library/en-us/dndevice/html/IRP_Handle.asp

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development

---------------------------------
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Amlan Mandal
Sent: Thursday, September 29, 2005 4:42 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Re:TDI driver

Thanks Dave for your elaborate answer. Can I call IoSetCompletetion routine from my “TDI client” function?. I should elaborate. In my TDI SetHandler routine I call IoDriver. If IoCallDriver sends status STATUS_PENDING I have to block the thread with some event(of type Kevent)
So now can I set some completion routine with IoSetCompletion routine so that it will be called when IRP is done to signal the event & unblock my event set handler routine.

Thanks in advance
Amlan

“David R. Cattley” wrote:
Amlan,

I think that Thomas might have thought you were wondering how to get the DeviceObject from the handle returned by ZwCreateFile() and ObReferenceObjectByHandle() will allow you to get an ObjectPointer to the FileObject from which you can get the DeviceObject by calling IoGetRelatedDeviceObject().

If you are just trying to get the DeviceObject of \Device\UDP, you can get it with IoGetDeviceObjectPointer(). However, the returned FileObject will not be a TDI Address File object (it will be a ‘control’ object).

With UDP, just as with TCP (and any TDI Transport) you must create a TDI Address File Object with ZwCreateFile() and specify the appropriate EA argument, in the case of UDP it would be TdiTransportAddress (“TransportAddress”).

Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development

---------------------------------
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Thomas F. Divine
Sent: Wednesday, September 28, 2005 10:26 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Re:TDI driver

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
Thanks Thomas.
I have one more question. Now suppose I want to send UDP datagrams from my client, then to call IoCallDriver() from my client I need DeviceObject.(IRP will be built by TdiBuildInternalControlDeviceirp) My question is how or what function to use to get the device object from \Device\UDP (the device name)

Once gain thanks in advance
Amlan

That would be ObReferenceObjectByHandle.

Thomas F. Divine, Windows DDK MVP
http://www.rawether.net


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@msn.com To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.

Surely the call is “synchronous”. There is no mechanism to indicate that the operation would pend. So, the call will not return until the IRP has been initialized.

The biggest issue with TdiBuildInternalDeviceControlIrp is that it must run at IRQL == PASSIVE_LEVEL. If you aren’t at that level, then you must either 1.) pre-allocate IRPs for use at IRQL == DISPATCH_LEVEL or use IoAllocateIrp and friends to manually allocate and initialize an IRP.

In addition, KeWaitForSingleObject may work in this case, but be careful when waiting for non-zero time when IRQL >= DISPATCH_LEVEL.

Finally, my own personal experiance has been that using callbacks instead of waits makes the most effective use of the TDI API. There are, of course, exceptions and this is probably one of them. The set event operation basically just jams the event handler and context into a TCP-owned internal data structure and returns immediately.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.pcausa.com

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
Is TdiBuildInternalDeviceControlIrp is a synchnous call? If it is NOT then as this if follwed by TdiBuildXxx routines t& then IoCallDriver() I have to sunchonize it .How to do it if I cant set Completion routine
Is the following Code OK inside Tdi_SetHandler Routine(assming TdiBuildInternalDeviceControlIrp a synchronous call)


pIrp = TdiBuildInternalDeviceControlIrp(TDI_SET_EVENT_HANDLER, pTdiDevice, pfoTdiFileObject, &event, &IoStatusBlock);

if(pIrp)
{
/

* Step 2: Set the IRP Parameters
/
TdiBuildSetEventHandler(pIrp, pTdiDevice, pfoTdiFileObject, NULL, NULL, InEventType, InEventHandler, InEventContext);

NtStatus = IoCallDriver(pTdiDevice, pIrp);

if(NtStatus == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
/

* Find the Status of the completed IRP
/

NtStatus = IoStatusBlock.Status;
}
}
return NtStatus


<snip…></snip…>

Thomas, Thanks you a lot.
The event argument passed in TdiBuildInternalDeviceControlIrp will be set by I/O Manager when lower drivers complete the IRP. So I dont need any completion rotine to set events to block the thread when its get STATUS_PENDING frm IoCallDriver()

Is my interpretation correct?

“Thomas F. Divine” wrote:
Surely the call is “synchronous”. There is no mechanism to indicate that the operation would pend. So, the call will not return until the IRP has been initialized.

The biggest issue with TdiBuildInternalDeviceControlIrp is that it must run at IRQL == PASSIVE_LEVEL. If you aren’t at that level, then you must either 1.) pre-allocate IRPs for use at IRQL == DISPATCH_LEVEL or use IoAllocateIrp and friends to manually allocate and initialize an IRP.

In addition, KeWaitForSingleObject may work in this case, but be careful when waiting for non-zero time when IRQL >= DISPATCH_LEVEL.

Finally, my own personal experiance has been that using callbacks instead of waits makes the most effective use of the TDI API. There are, of course, exceptions and this is probably one of them. The set event operation basically just jams the event handler and context into a TCP-owned internal data structure and returns immediately.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.pcausa.com

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
Is TdiBuildInternalDeviceControlIrp is a synchnous call? If it is NOT then as this if follwed by TdiBuildXxx routines t& then IoCallDriver() I have to sunchonize it .How to do it if I cant set Completion routine
Is the following Code OK inside Tdi_SetHandler Routine(assming TdiBuildInternalDeviceControlIrp a synchronous call)


pIrp = TdiBuildInternalDeviceControlIrp(TDI_SET_EVENT_HANDLER, pTdiDevice, pfoTdiFileObject, &event, &IoStatusBlock);

if(pIrp)
{
/

* Step 2: Set the IRP Parameters
/
TdiBuildSetEventHandler(pIrp, pTdiDevice, pfoTdiFileObject, NULL, NULL, InEventType, InEventHandler, InEventContext);

NtStatus = IoCallDriver(pTdiDevice, pIrp);

if(NtStatus == STATUS_PENDING)
{
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
/

* Find the Status of the completed IRP
/

NtStatus = IoStatusBlock.Status;
}
}
return NtStatus


<snip…>


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.</snip…>

Do I have to set sin_zero field in in TDI_ADDRESS_IP.
Or just ignore it to set it to LOCAL MACCHINE ADDRESS

— “Thomas F. Divine” wrote:

> Surely the call is “synchronous”. There is no
> mechanism to indicate that the operation would pend.
> So, the call will not return until the IRP has been
> initialized.
>
> The biggest issue with
> TdiBuildInternalDeviceControlIrp is that it must run
> at IRQL == PASSIVE_LEVEL. If you aren’t at that
> level, then you must either 1.) pre-allocate IRPs
> for use at IRQL == DISPATCH_LEVEL or use
> IoAllocateIrp and friends to manually allocate and
> initialize an IRP.
>
> In addition, KeWaitForSingleObject may work in this
> case, but be careful when waiting for non-zero time
> when IRQL >= DISPATCH_LEVEL.
>
> Finally, my own personal experiance has been that
> using callbacks instead of waits makes the most
> effective use of the TDI API. There are, of course,
> exceptions and this is probably one of them. The set
> event operation basically just jams the event
> handler and context into a TCP-owned internal data
> structure and returns immediately.
>
> Good luck,
>
> Thomas F. Divine, Windows DDK MVP
> http://www.pcausa.com
>
> “Amlan Mandal” wrote in
> message news:xxxxx@ntdev…
> Is TdiBuildInternalDeviceControlIrp is a synchnous
> call? If it is NOT then as this if follwed by
> TdiBuildXxx routines t& then IoCallDriver() I have
> to sunchonize it .How to do it if I cant set
> Completion routine
> Is the following Code OK inside Tdi_SetHandler
> Routine(assming TdiBuildInternalDeviceControlIrp a
> synchronous call)
>
>

>
> pIrp =
>
TdiBuildInternalDeviceControlIrp(TDI_SET_EVENT_HANDLER,
> pTdiDevice, pfoTdiFileObject, &event,
> &IoStatusBlock);
>
>
> if(pIrp)
> {
> /

> * Step 2: Set the IRP Parameters
> /
> TdiBuildSetEventHandler(pIrp, pTdiDevice,
> pfoTdiFileObject, NULL, NULL, InEventType,
> InEventHandler, InEventContext);
>
> NtStatus = IoCallDriver(pTdiDevice, pIrp);
>
> if(NtStatus == STATUS_PENDING)
> {
> KeWaitForSingleObject(&event,
> Executive, KernelMode, FALSE, NULL);
> /

> * Find the Status of the completed
> IRP
> /
>
> NtStatus = IoStatusBlock.Status;
> }
> }
> return NtStatus
>
>

>
>
> <snip…>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown
> lmsubst tag argument: ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com

__________________________________
Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com</snip…>

“Amlan Mandal” wrote in message news:xxxxx@ntdev…
> Do I have to set sin_zero field in in TDI_ADDRESS_IP.
> Or just ignore it to set it to LOCAL MACCHINE ADDRESS
>

Why not set it???

Thomas F. Divine

<snip…></snip…>