TDI UDP troubles :-(

Hi,
I’m currently an novice in TDI.

After successful creation a transport-address at \Device\Udp, I got
two troubles:

  1. IoCallDriver(TDI_SET_EVENT_HANDLER) for EventType =
    TDI_EVENT_CHAINED_RECEIVE_DATAGRAM and TDI_EVENT_RECEIVE_DATAGRAM
    returns STATUS_INVALID_ADDRESS (C0000141);

  2. IoCallDriver(TDI_SEND_DATAGRAM) return STATUS_CANCELLED;

What can be wrong? Incorrect parameters where transport-address
creation, or may be other mistake?

Transport-address creation code is like following:

EaLength = sizeof(FILE_FULL_EA_INFORMATION) +
TDI_TRANSPORT_ADDRESS_LENGTH + sizeof(TA_IP_ADDRESS);

RtlZeroMemory(pEaBuffer, EaLength);
pEaBuffer->EaNameLength = TDI_TRANSPORT_ADDRESS_LENGTH;
RtlCopyMemory(pEaBuffer->EaName, TdiTransportAddress, TDI_TRANSPORT_ADDRESS_LENGTH);

TA_IP_ADDRESS *Ip4 = (TA_IP_ADDRESS *) (pEaBuffer->EaName + TDI_TRANSPORT_ADDRESS_LENGTH + 1);
Ip4->TAAddressCount = 1;

pEaBuffer->EaValueLength = sizeof(TA_IP_ADDRESS);
Ip4->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
Ip4->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
Ip4->Address[0].Address[0].sin_port = UDP_PORT_NETWORK_ORDER;
Ip4->Address[0].Address[0].in_addr = IPv4_ADDRESS_NETWORK_ORDER;

RtlInitUnicodeString(&TransportDeviceObjectName, L"\Device\Udp");
InitializeObjectAttributes(&ObjectAttributes, &TransportDeviceObjectName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 0, 0);

Status = ZwCreateFile(&AddressHandle, 0, &ObjectAttributes,
&IoStatusBlock, 0, FILE_ATTRIBUTE_NORMAL, ShareMode, FILE_OPEN, 0,
pEaBuffer, EaLength);

if(NT_SUCCESS(Status))
{
Status = ObReferenceObjectByHandle(AddressHandle, 0, 0,
KernelMode, (void**) &AddressFileObject, 0);
ZwClose(AddressHandle);
}

From what I remember on UDP, it does not support chained receives.

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

----- Original Message -----
From: “Leo Yuriev”
To: “Windows System Software Devs Interest List”
Sent: Monday, July 12, 2004 9:08 PM
Subject: [ntdev] TDI UDP troubles :frowning:

> Hi,
> I’m currently an novice in TDI.
>
> After successful creation a transport-address at \Device\Udp, I got
> two troubles:
>
> 1. IoCallDriver(TDI_SET_EVENT_HANDLER) for EventType =
> TDI_EVENT_CHAINED_RECEIVE_DATAGRAM and TDI_EVENT_RECEIVE_DATAGRAM
> returns STATUS_INVALID_ADDRESS (C0000141);
>
> 2. IoCallDriver(TDI_SEND_DATAGRAM) return STATUS_CANCELLED;
>
> What can be wrong? Incorrect parameters where transport-address
> creation, or may be other mistake?
>
> Transport-address creation code is like following:
>
> EaLength = sizeof(FILE_FULL_EA_INFORMATION) +
> TDI_TRANSPORT_ADDRESS_LENGTH + sizeof(TA_IP_ADDRESS);
>
> RtlZeroMemory(pEaBuffer, EaLength);
> pEaBuffer->EaNameLength = TDI_TRANSPORT_ADDRESS_LENGTH;
> RtlCopyMemory(pEaBuffer->EaName, TdiTransportAddress,
TDI_TRANSPORT_ADDRESS_LENGTH);
>
> TA_IP_ADDRESS Ip4 = (TA_IP_ADDRESS ) (pEaBuffer->EaName +
TDI_TRANSPORT_ADDRESS_LENGTH + 1);
> Ip4->TAAddressCount = 1;
>
> pEaBuffer->EaValueLength = sizeof(TA_IP_ADDRESS);
> Ip4->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
> Ip4->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
> Ip4->Address[0].Address[0].sin_port = UDP_PORT_NETWORK_ORDER;
> Ip4->Address[0].Address[0].in_addr = IPv4_ADDRESS_NETWORK_ORDER;
>
> RtlInitUnicodeString(&TransportDeviceObjectName, L"\Device\Udp");
> InitializeObjectAttributes(&ObjectAttributes, &TransportDeviceObjectName,
> OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 0, 0);
>
> Status = ZwCreateFile(&AddressHandle, 0, &ObjectAttributes,
> &IoStatusBlock, 0, FILE_ATTRIBUTE_NORMAL, ShareMode, FILE_OPEN, 0,
> pEaBuffer, EaLength);
>
> if(NT_SUCCESS(Status))
> {
> Status = ObReferenceObjectByHandle(AddressHandle, 0, 0,
> KernelMode, (void
) &AddressFileObject, 0);
> ZwClose(AddressHandle);
> }
>
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi,
I found the bug, ZwClose() was too early…

After successful creation a transport-address at \Device\Udp, I got
two troubles:

  1. IoCallDriver(TDI_SET_EVENT_HANDLER) for EventType =
    TDI_EVENT_CHAINED_RECEIVE_DATAGRAM and TDI_EVENT_RECEIVE_DATAGRAM
    returns STATUS_INVALID_ADDRESS (C0000141);

  2. IoCallDriver(TDI_SEND_DATAGRAM) return STATUS_CANCELLED;

What can be wrong? Incorrect parameters where transport-address
creation, or may be other mistake?