Hi There Andrei!!
Thanks for your reply. I tried to create a TDI_RECEIVE IRP and
complete it right away, but it does not seem to be working. I am
pasting the code below… Can anyone please take a look at it and tell
me maybe what I am doing wrong? Again, this function below is being
called from the TDI_SEND handler of a connection that is already
established. I look at packets inside of TDI_SEND and I look at the
data for a specific one I am trying to find. This all works fine…
When I see the one I want, I have to basically send a reply back, but
make it look like the machine it was being sent to. So, I wrote the
function below to try to send one back, but make it look like a
TDI_RECEIVE from the remote host. Please take a look:
Int SendReply(PIRP irp, PIO_STACK_LOCATION irps, PCHAR Data, ULONG
DataSize)
{
KEVENT tdi_event;
IO_STATUS_BLOCK iostatus;
PIRP RedirIRP;
NTSTATUS status;
struct ot_entry *ote_conn;
KIRQL irql;
PMDL Mdl;
RtlZeroMemory(&iostatus, sizeof(iostatus));
KeInitializeEvent(&tdi_event, NotificationEvent, FALSE);
Mdl = IoAllocateMdl(Data, DataSize, FALSE, FALSE, NULL);
if ( ! Mdl )
return 1;
MmProbeAndLockPages(Mdl, KernelMode, IoModifyAccess);
RedirIRP = TdiBuildInternalDeviceControlIrp(TDI_RECEIVE,
irps->DeviceObject, irps->FileObject,
&tdi_event, &iostatus);
if ( ! RedirIRP )
{
IoFreeMdl(Mdl);
return 1;
}
TdiBuildReceive(RedirIRP, irps->DeviceObject,
irps->FileObject,
NULL, NULL,
Mdl, TDI_RECEIVE_NORMAL, DataSize);
// Now, I think, we should just complete this IRP… right?

RedirIRP->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest( RedirIRP, IO_NO_INCREMENT ); // I
complete this here, in hopes that it will just be sent up to the
application that I am replying to…
return 0;
}
So, does this look like I am on the right track? Can anyone please tell
me why this is not working? … I just want to make it look like a
packet sent back to the machine…
Please help!
Thanks
Tom
Subject: Re: TDI Driver - TDI_SEND - Need to Get FILE_OBJECT to LOCAL
END POINT!!
From: Andrei Zlate-Podani
Newsgroups: ntdev
To: Windows System Software Devs Interest List
Handal, Thomas wrote:
> Hello All!!
>
> I have a TDI Driver. Inside of my TDI_SEND handler, I look for a
> specific packet. When I find this packet, I want to do a TdiSend to
> send out a packet from scratch. I am doing this just fine using the
> FileObject in the IrpStack. This works and everything is good. The
> problem I am having is that (of course) this FileObject goes to the
> remote machine.
>
TDI drivers work with streams or datagrams, not with packets.
The FileObject is associated to a connection object (for TDI_SEND IRPs).
It is not sent anywhere.
> How would I go about finding the OTHER FileObject that would be the
> local machine?
>
There is only one FileObject. For the event handlers associated with
streams, the clients specify a connection context.
> … Basically, I want to act like I am the remote machine responding
to
> the Local Machine, so I basically want to send a packet to myself! So,
> I need the FileObject for the Local endpoint. Can I get this from the
> connection device object? Or somehow get it from the FileObject that I
> have?
>
You can try calling the ClientEventReceive handler, if the client set
one. Or you can complete the TDI_RECEIVE IRP.
> Any help would be greatly appreciated… Thanks in advance!!!
>
> Tom
>
> —
> 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
>
>-----------------------------------------------------------------------
-
>
>
>
>