Hi,
i am trying to assign port number to TDI server using TdiBuildListen fuction. But i have not been able to assign it properly.
Please help me in these regards,
regards,
barun
Hi,
i am trying to assign port number to TDI server using TdiBuildListen fuction. But i have not been able to assign it properly.
Please help me in these regards,
regards,
barun
Well, it is hard to say anything without seeing your code…
Anton Bassov
Here goes my listen and accept code for TDI server. I don’t know what’s wrong with this code.
NTSTATUS
Listen(PFILE_OBJECT FileObject) //UINT Addr
{
NTSTATUS Status = STATUS_INSUFFICIENT_RESOURCES;
PIRP Irp;
IO_STATUS_BLOCK IoStatus = {0};
PDEVICE_OBJECT DeviceObject;
TDI_CONNECTION_INFORMATION RequestConnectionInfo = {0};
TDI_CONNECTION_INFORMATION ReturnConnectionInfo = {0};
KEVENT Event;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
DeviceObject = IoGetRelatedDeviceObject(FileObject);
Irp = TdiBuildInternalDeviceControlIrp(TDI_LISTEN, DeviceObject, FileObject,
&Event, &IoStatus);
if (Irp == 0)
return STATUS_INSUFFICIENT_RESOURCES;
RequestConnectionInfo.RemoteAddress = NULL;
RequestConnectionInfo.RemoteAddressLength = 0;
TdiBuildListen(Irp, DeviceObject, FileObject, NULL, NULL, TDI_QUERY_ACCEPT, &RequestConnectionInfo, &ReturnConnectionInfo);
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
Status = KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); //UserMode
return Status == STATUS_SUCCESS ? IoStatus.Status : Status;
}
/*
* accept
*/
NTSTATUS
Accept(PFILE_OBJECT FileObject)
{
KEVENT Event;
PDEVICE_OBJECT DeviceObject;
IO_STATUS_BLOCK IoStatus;
PIRP Irp;
NTSTATUS Status;
TA_IP_ADDRESS taIpAddress;
TDI_CONNECTION_INFORMATION tdiConnectionInformation;
RtlZeroMemory( &taIpAddress, sizeof( taIpAddress ) );
taIpAddress.TAAddressCount = 1;
taIpAddress.Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
taIpAddress.Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
RtlZeroMemory( &tdiConnectionInformation, sizeof( tdiConnectionInformation ));
tdiConnectionInformation.RemoteAddressLength = sizeof( taIpAddress );
tdiConnectionInformation.RemoteAddress = &taIpAddress;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
DeviceObject = IoGetRelatedDeviceObject(FileObject);
Irp = TdiBuildInternalDeviceControlIrp(TDI_ACCEPT, DeviceObject, FileObject,
&Event, &IoStatus);
if (Irp == 0)
return STATUS_INSUFFICIENT_RESOURCES;
TdiBuildAccept(Irp, DeviceObject, FileObject, NULL, NULL, &tdiConnectionInformation, 0);
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
Status = KeWaitForSingleObject(&Event, UserRequest, KernelMode, FALSE, 0);
return Status == STATUS_SUCCESS ? IoStatus.Status : Status;
}