Dear all:

Recently I developed a TDI client driver. It is a very simple project which
receives UDP packets from particular IP address and port.

I tried two methods to achieve the goal.
One is to allocate Irp/Mdl and TdiBuildReceiveDatagram to obtain data
directly from underlying transport. It works fine! Another is to register
ClientEventReceiveDatagram handler, and in the handler I also receive UDP
data.

However, in the case that the input parameter BytesIndicated !=
BytesAvailable, I wanted to build a Irp returned to underlying transport for
the remainder of the TSDU. It failed!

In this handler, I tried two ways to build the Irp, IoAllocateIrp and
TdiBuildInternalDeviceControlIrp. As mentioned by DDK documentation,
"Callers of TdiBuildInternalDeviceControlIrp must be running at IRQL =
PASSIVE_LEVEL".So I pre-call the function to build Irp and in other thread,
such as dispatch_IoControl.

But both of them failed. OS crashed,and the message is
"DRIVER_NO_LESS_OR_EQUAL_IRQL". I don't know how to set up the Irp as
*IoRequestPacket for the remainder data.

Any idea is appreciated, thanks in advance.


Regards,
Zhou

How to set up IoRequestPacket in ClientEventReceiveDatagram? by Steve

Steve
Mon Feb 14 18:52:29 CST 2005

From what I understand you have registered a receive
datagram event handler. When your handler is called
sometimes not all data is indicated, i.e. BytesIndicated
is less than BytesAvailable. So I think all that is
necessary is for you to copy BytesIndicated from Tsdu and
set *BytesTaken to BytesIndicated, then set
*IoRequestPacket to the address of your irp. This irp
would have been pre-allocated (because of running IRQL of
your callback) and must be set up using
TdiBuildReceiveDatagram() before your handler returns.
Also, your handler must return
STATUS_MORE_PROCESSING_REQUIRED. By supplying a pointer
in IoRequestPacket and returning
STATUS_MORE_PROCESSING_REQUIRED you are telling the
transport that you want the rest of the data!


If you have done all this and it still causes blue screen
then you will have to examine the crash dump in WinDbg -
perhaps your irp contains some invalid pointers or
something.

Steve.
>-----Original Message-----
>Dear all:
>
>Recently I developed a TDI client driver. It is a very
simple project which
>receives UDP packets from particular IP address and port.
>
>I tried two methods to achieve the goal.
>One is to allocate Irp/Mdl and TdiBuildReceiveDatagram
to obtain data
>directly from underlying transport. It works fine!
Another is to register
>ClientEventReceiveDatagram handler, and in the handler I
also receive UDP
>data.
>
>However, in the case that the input parameter
BytesIndicated !=
>BytesAvailable, I wanted to build a Irp returned to
underlying transport for
>the remainder of the TSDU. It failed!
>
>In this handler, I tried two ways to build the Irp,
IoAllocateIrp and
>TdiBuildInternalDeviceControlIrp. As mentioned by DDK
documentation,
>"Callers of TdiBuildInternalDeviceControlIrp must be
running at IRQL =
>PASSIVE_LEVEL".So I pre-call the function to build Irp
and in other thread,
>such as dispatch_IoControl.
>
>But both of them failed. OS crashed,and the message is
>"DRIVER_NO_LESS_OR_EQUAL_IRQL". I don't know how to set
up the Irp as
>*IoRequestPacket for the remainder data.
>
>Any idea is appreciated, thanks in advance.
>
>
>Regards,
>Zhou
>
>
>.
>

Re: How to set up IoRequestPacket in ClientEventReceiveDatagram? by Zhou

Zhou
Mon Feb 14 20:38:43 CST 2005

Yes, I have already done all of these steps, but it still cuases blue
screen.
I think that the reason is probably *IoRequestPacket not built correctly, as
you said.
I will try it again.
Thanks.

"Steve" <swoodberry@foursticks.com> wrote in message
news:164f01c512f8$a0308190$a501280a@phx.gbl...
> From what I understand you have registered a receive
> datagram event handler. When your handler is called
> sometimes not all data is indicated, i.e. BytesIndicated
> is less than BytesAvailable. So I think all that is
> necessary is for you to copy BytesIndicated from Tsdu and
> set *BytesTaken to BytesIndicated, then set
> *IoRequestPacket to the address of your irp. This irp
> would have been pre-allocated (because of running IRQL of
> your callback) and must be set up using
> TdiBuildReceiveDatagram() before your handler returns.
> Also, your handler must return
> STATUS_MORE_PROCESSING_REQUIRED. By supplying a pointer
> in IoRequestPacket and returning
> STATUS_MORE_PROCESSING_REQUIRED you are telling the
> transport that you want the rest of the data!
>
>
> If you have done all this and it still causes blue screen
> then you will have to examine the crash dump in WinDbg -
> perhaps your irp contains some invalid pointers or
> something.
>
> Steve.
> >-----Original Message-----
> >Dear all:
> >
> >Recently I developed a TDI client driver. It is a very
> simple project which
> >receives UDP packets from particular IP address and port.
> >
> >I tried two methods to achieve the goal.
> >One is to allocate Irp/Mdl and TdiBuildReceiveDatagram
> to obtain data
> >directly from underlying transport. It works fine!
> Another is to register
> >ClientEventReceiveDatagram handler, and in the handler I
> also receive UDP
> >data.
> >
> >However, in the case that the input parameter
> BytesIndicated !=
> >BytesAvailable, I wanted to build a Irp returned to
> underlying transport for
> >the remainder of the TSDU. It failed!
> >
> >In this handler, I tried two ways to build the Irp,
> IoAllocateIrp and
> >TdiBuildInternalDeviceControlIrp. As mentioned by DDK
> documentation,
> >"Callers of TdiBuildInternalDeviceControlIrp must be
> running at IRQL =
> >PASSIVE_LEVEL".So I pre-call the function to build Irp
> and in other thread,
> >such as dispatch_IoControl.
> >
> >But both of them failed. OS crashed,and the message is
> >"DRIVER_NO_LESS_OR_EQUAL_IRQL". I don't know how to set
> up the Irp as
> >*IoRequestPacket for the remainder data.
> >
> >Any idea is appreciated, thanks in advance.
> >
> >
> >Regards,
> >Zhou
> >
> >
> >.
> >



Re: How to set up IoRequestPacket in ClientEventReceiveDatagram? by Maxim

Maxim
Tue Feb 15 07:56:59 CST 2005

> BytesAvailable, I wanted to build a Irp returned to underlying transport for
> the remainder of the TSDU. It failed!
>
> In this handler, I tried two ways to build the Irp, IoAllocateIrp and

IoAllocateIrp is fine if you will set up the stack location properly.
Do not forget to call IoSetNextIrpStackLocation(Irp) before return though.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: How to set up IoRequestPacket in ClientEventReceiveDatagram? by Zhou

Zhou
Wed Feb 16 03:06:10 CST 2005

> Do not forget to call IoSetNextIrpStackLocation(Irp) before return though.

Oh, yeah! Just this call helps me.

I always pre-allocated Irp/Mdl and TdiBuildReceiveDatagram without
IoSetNextIrpStackLocation, but always failed. Once i add this function, it
works fine immediately.

I guess that because TdiBuildReceiveDatagram only sets the next stack
location and I don't call IoCallDriver, "current stack location" in the
underlying transport is still not built properly. So it fails without
IoSetNextIrpStackLocation(Irp).

Thanks a looooot.


Regards
Zhou