Hello,
I try to make my TCP TDI client to listen for connection
(that is I try to bring the server side of the connection up).
This is, I hope, 5 steps process:
1) Open transport address. (I use 0.0.0.0:5000)
2) Open connection endpoint
3) Associate transport with the connection
4) Hook some event grabbers (I have set event handlers
for TDI_EVENT_CONNECT and TDI_EVENT_RECEIVE)
5) Listen...
The first 4 steps of the 5 succeed, but the last TDI_LISTEN CallDriver
return STATUS_PENDING which never ends. (below please find a code fragment).
I expected that TDI listen request must never hang, because this is (i hope)
a
transport service "mode" setting only. What could be the reason for it to
hang?
How to make the server listen?
Please help.
(probably somebody could post few lines of sample code)
Thanks,
Sergei.
//-----------------------------------------------------------
//------------------------------------------------------------
//
// Tdi_Listen
//
NTSTATUS Tdi_Listen(PFILE_OBJECT pConnection)
{
NTSTATUS NtStatus = STATUS_INSUFFICIENT_RESOURCES;
PIRP pIrp;
PDEVICE_OBJECT pTdiDevice;
TDI_COMPLETION_CONTEXT TdiCompletionContext;
TDI_CONNECTION_INFORMATION ConnectionInfo_ret;
TDI_CONNECTION_INFORMATION ConnectionInfo = {0};
IO_STATUS_BLOCK IoStatusBlock = {0};
ULONG User_D = 0x40404040; // a "don't care" value
// PAGED_CODE();
KeInitializeEvent(&TdiCompletionContext.kCompleteE vent,
NotificationEvent, FALSE);
//
// TDI Device Object to send requests to the TDI Driver.
//
pTdiDevice = IoGetRelatedDeviceObject(pConnection);
//
// Build the IRP.
//
pIrp = TdiBuildInternalDeviceControlIrp(TDI_LISTEN,
pTdiDevice,
pConnection,
&TdiCompletionContext.kCompleteEvent,
&IoStatusBlock);
if(pIrp)
{
//
// Add the correct parameters into the IRP.
//
ConnectionInfo.UserData = &User_D;
ConnectionInfo.UserDataLength = sizeof(ULONG);
ConnectionInfo.Options = NULL;
ConnectionInfo.OptionsLength = 0;
ConnectionInfo.RemoteAddress = NULL;
ConnectionInfo.RemoteAddressLength = 0;
TdiBuildListen(pIrp, pTdiDevice,
pConnection, NULL, NULL,
0, // Flags,
&ConnectionInfo,
&ConnectionInfo_ret); // PTDI_CONNECTION_INFORMATION
NtStatus = IoCallDriver(pTdiDevice, pIrp);
//
// If TDI_LISTEN will not hang I'll have BSOD(CC01).
//
if(NtStatus == STATUS_PENDING)
{
KeWaitForSingleObject(&TdiCompletionContext.kCompl eteEvent,
Executive, KernelMode, FALSE, NULL);
NtStatus = IoStatusBlock.Status;
KeBugCheckEx(0xDEADCC01, 0, 0, 0, NtStatus);
}else{
KeBugCheckEx(0xDEADCC02, 0, 0, 0, NtStatus);
}
}
return NtStatus;
} // Tdi_Listen