TDI open address problem

Despite looking over information on this list, I can’t get ZwCreateFile to open a transport address. The problem seems to be with an incorrectly formed EA address structure, as ZwCreateFile returns STATUS_EA_LIST_INCONSISTENT.

All I want to do is open an address on the local machine on any old non-reserved port number.

Maybe someone has a clear code snipped filling out an EA buffer for opening an address???

Here’s what I’ve got:

OBJECT_ATTRIBUTES objectAttrib;
IO_STATUS_BLOCK ioStatusBlock;
NTSTATUS ntStatus;
PFILE_FULL_EA_INFORMATION eaBuffer;
LONG eaLength;

TA_IP_ADDRESS tAddr;
TDI_ADDRESS_IP tIpAddr;

ANSI_STRING AnsiDeviceName;
UNICODE_STRING UniDeviceName;

RtlInitAnsiString(&AnsiDeviceName, “\Device\Tcp”);
ntStatus = RtlAnsiStringToUnicodeString(&UniDeviceName, &AnsiDeviceName, TRUE);

if ( !NT_SUCCESS(ntStatus) )
{
dprintf(“RtlAnsiStringToUnicodeString failed\n”);
return;
}

tIpAddr.sin_port = 34835;
tIpAddr.in_addr = 0;
RtlZeroMemory(&tIpAddr.sin_zero[0], 8);

tAddr.TAAddressCount = 1;
tAddr.Address[0].AddressLength = 14;
tAddr.Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
RtlCopyMemory(&tAddr.Address[0].Address[0], &tIpAddr, sizeof(TDI_ADDRESS_IP));

eaLength = FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) +
TDI_TRANSPORT_ADDRESS_LENGTH + sizeof(TA_IP_ADDRESS);

eaBuffer = (PFILE_FULL_EA_INFORMATION)
ExAllocatePool(PagedPoolCacheAligned, eaLength);

if(!eaBuffer) return;

RtlZeroMemory(eaBuffer, eaLength);
eaBuffer->NextEntryOffset = 0;
eaBuffer->Flags = 0;
eaBuffer->EaNameLength = strlen(TdiTransportAddress);
eaBuffer->EaValueLength = sizeof(TA_IP_ADDRESS);

RtlCopyMemory(&eaBuffer->EaName[0], TdiTransportAddress, strlen(TdiTransportAddress) + 1);

RtlCopyMemory(&eaBuffer->EaName[0] + strlen(TdiTransportAddress) + 1,
&tAddr, sizeof(TA_IP_ADDRESS));

InitializeObjectAttributes(&objectAttrib,
&UniDeviceName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);

//request an open address handle
ntStatus = ZwCreateFile(&tdiOpenAddress,
GENERIC_READ | GENERIC_WRITE,
&objectAttrib,
&ioStatusBlock,
0L,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_OPEN_IF,
0L,
&eaBuffer,
sizeof(eaBuffer));

Having seen your code fragment, I’d suggest taking a closer look at how you
calculate eaLength. I haven’t looked closely, but it looks fishy.

Good luck,

Thomas F. Divine

PCAUSA - Tools & Resources For Network Software Developers
NDIS Protocol/Intermediate/Hooking - TDI Client/Filter
http: - http:

“skip” wrote in message news:xxxxx@ntdev…
>
> Despite looking over information on this list, I can’t get ZwCreateFile to
open a transport address. The problem seems to be with an incorrectly formed
EA address structure, as ZwCreateFile returns STATUS_EA_LIST_INCONSISTENT.
>
> All I want to do is open an address on the local machine on any old
non-reserved port number.
>
> Maybe someone has a clear code snipped filling out an EA buffer for
opening an address???
>
> Here’s what I’ve got:
>
> OBJECT_ATTRIBUTES objectAttrib;
> IO_STATUS_BLOCK ioStatusBlock;
> NTSTATUS ntStatus;
> PFILE_FULL_EA_INFORMATION eaBuffer;
> LONG eaLength;
>
> TA_IP_ADDRESS tAddr;
> TDI_ADDRESS_IP tIpAddr;
>
> ANSI_STRING AnsiDeviceName;
> UNICODE_STRING UniDeviceName;
>
>
> RtlInitAnsiString(&AnsiDeviceName, “\Device\Tcp”);
> ntStatus = RtlAnsiStringToUnicodeString(&UniDeviceName, &AnsiDeviceName,
TRUE);
>
> if ( !NT_SUCCESS(ntStatus) )
> {
> dprintf(“RtlAnsiStringToUnicodeString failed\n”);
> return;
> }
>
> tIpAddr.sin_port = 34835;
> tIpAddr.in_addr = 0;
> RtlZeroMemory(&tIpAddr.sin_zero[0], 8);
>
> tAddr.TAAddressCount = 1;
> tAddr.Address[0].AddressLength = 14;
> tAddr.Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
> RtlCopyMemory(&tAddr.Address[0].Address[0], &tIpAddr,
sizeof(TDI_ADDRESS_IP));
>
> eaLength = FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) +
> TDI_TRANSPORT_ADDRESS_LENGTH + sizeof(TA_IP_ADDRESS);
>
>
> eaBuffer = (PFILE_FULL_EA_INFORMATION)
> ExAllocatePool(PagedPoolCacheAligned, eaLength);
>
> if(!eaBuffer) return;
>
> RtlZeroMemory(eaBuffer, eaLength);
> eaBuffer->NextEntryOffset = 0;
> eaBuffer->Flags = 0;
> eaBuffer->EaNameLength = strlen(TdiTransportAddress);
> eaBuffer->EaValueLength = sizeof(TA_IP_ADDRESS);
>
> RtlCopyMemory(&eaBuffer->EaName[0], TdiTransportAddress,
strlen(TdiTransportAddress) + 1);
>
> RtlCopyMemory(&eaBuffer->EaName[0] + strlen(TdiTransportAddress) + 1,
> &tAddr, sizeof(TA_IP_ADDRESS));
>
> InitializeObjectAttributes(&objectAttrib,
> &UniDeviceName,
> OBJ_CASE_INSENSITIVE,
> NULL,
> NULL);
>
> //request an open address handle
> ntStatus = ZwCreateFile(&tdiOpenAddress,
> GENERIC_READ | GENERIC_WRITE,
> &objectAttrib,
> &ioStatusBlock,
> 0L,
> FILE_ATTRIBUTE_NORMAL,
> FILE_SHARE_READ | FILE_SHARE_WRITE,
> FILE_OPEN_IF,
> 0L,
> &eaBuffer,
> sizeof(eaBuffer));
>
></http:></http:>

Just needs a + 1

eaLength = FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) +
TDI_TRANSPORT_ADDRESS_LENGTH + 1 + sizeof(TA_IP_ADDRESS)

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Thomas F. Divine [mailto:xxxxx@hotmail.com]
Sent: Thursday, March 14, 2002 11:13 AM
To: NT Developers Interest List
Subject: [ntdev] Re: TDI open address problem

Having seen your code fragment, I’d suggest taking a closer look at how
you calculate eaLength. I haven’t looked closely, but it looks fishy.

Good luck,

Thomas F. Divine

PCAUSA - Tools & Resources For Network Software Developers
NDIS Protocol/Intermediate/Hooking - TDI Client/Filter
http: - http:

“skip” wrote in message news:xxxxx@ntdev…
>
> Despite looking over information on this list, I can’t get
> ZwCreateFile to
open a transport address. The problem seems to be with an incorrectly
formed EA address structure, as ZwCreateFile returns
STATUS_EA_LIST_INCONSISTENT.
>
> All I want to do is open an address on the local machine on any old
non-reserved port number.
>
> Maybe someone has a clear code snipped filling out an EA buffer for
opening an address???
>
> Here’s what I’ve got:
>
> OBJECT_ATTRIBUTES objectAttrib;
> IO_STATUS_BLOCK ioStatusBlock;
> NTSTATUS ntStatus;
> PFILE_FULL_EA_INFORMATION eaBuffer;
> LONG eaLength;
>
> TA_IP_ADDRESS tAddr;
> TDI_ADDRESS_IP tIpAddr;
>
> ANSI_STRING AnsiDeviceName;
> UNICODE_STRING UniDeviceName;
>
>
> RtlInitAnsiString(&AnsiDeviceName, “\Device\Tcp”);
> ntStatus = RtlAnsiStringToUnicodeString(&UniDeviceName,
> &AnsiDeviceName,
TRUE);
>
> if ( !NT_SUCCESS(ntStatus) )
> {
> dprintf(“RtlAnsiStringToUnicodeString failed\n”);
> return;
> }
>
> tIpAddr.sin_port = 34835;
> tIpAddr.in_addr = 0;
> RtlZeroMemory(&tIpAddr.sin_zero[0], 8);
>
> tAddr.TAAddressCount = 1;
> tAddr.Address[0].AddressLength = 14; tAddr.Address[0].AddressType =
> TDI_ADDRESS_TYPE_IP; RtlCopyMemory(&tAddr.Address[0].Address[0],
> &tIpAddr,
sizeof(TDI_ADDRESS_IP));
>
> eaLength = FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) +
> TDI_TRANSPORT_ADDRESS_LENGTH + sizeof(TA_IP_ADDRESS);
>
>
> eaBuffer = (PFILE_FULL_EA_INFORMATION)
> ExAllocatePool(PagedPoolCacheAligned, eaLength);
>
> if(!eaBuffer) return;
>
> RtlZeroMemory(eaBuffer, eaLength);
> eaBuffer->NextEntryOffset = 0;
> eaBuffer->Flags = 0;
> eaBuffer->EaNameLength = strlen(TdiTransportAddress); EaValueLength =
> eaBuffer->sizeof(TA_IP_ADDRESS);
>
> RtlCopyMemory(&eaBuffer->EaName[0], TdiTransportAddress,
strlen(TdiTransportAddress) + 1);
>
> RtlCopyMemory(&eaBuffer->EaName[0] + strlen(TdiTransportAddress) + 1,
> &tAddr, sizeof(TA_IP_ADDRESS));
>
> InitializeObjectAttributes(&objectAttrib,
> &UniDeviceName,
> OBJ_CASE_INSENSITIVE,
> NULL,
> NULL);
>
> //request an open address handle
> ntStatus = ZwCreateFile(&tdiOpenAddress,
> GENERIC_READ | GENERIC_WRITE,
> &objectAttrib,
> &ioStatusBlock,
> 0L,
> FILE_ATTRIBUTE_NORMAL,
> FILE_SHARE_READ | FILE_SHARE_WRITE,
> FILE_OPEN_IF,
> 0L,
> &eaBuffer,
> sizeof(eaBuffer));
>
>


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%</http:></http:>