Home › Forums › Discussions › General › Create TDI enpoint connection error, please help?
- This topic has 2 replies, 2 voices, and was last updated 20 years, 3 months ago by rvd.
-
AuthorPosts
-
September 10, 2004 at 6:22 am #4875
Dear expert,
I have a big problem that i have spent more time to solve it, but cannot solve it. My code below:
NTSTATUS CreateConnection(PHANDLE Handle,
PFILE_OBJECT *FileObject)
{
NTSTATUS status;
UNICODE_STRING FullFileName;
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK ioStatus;
PFILE_FULL_EA_INFORMATION eaInfo;
ULONG dwSize;RtlInitUnicodeString(&FullFileName, L”\Device\Tcp”);
InitializeObjectAttributes(&ObjectAttributes,&FullFileName, OBJ_CASE_INSENSITIVE,NULL,NULL);dwSize = sizeof(FILE_FULL_EA_INFORMATION) +
strlen(TdiConnectionContext);eaInfo = (PFILE_FULL_EA_INFORMATION)ExAllocatePool(NonPagedPool, dwSize);
if(!eaInfo)
{
VLSDLogS(“VLSD: Failure of insufficient resources.”);
return STATUS_INSUFFICIENT_RESOURCES;
}RtlZeroMemory(eaInfo, dwSize);
eaInfo->NextEntryOffset = 0;
eaInfo->Flags = 0;
eaInfo->EaNameLength = strlen(TdiConnectionContext);
eaInfo->EaValueLength = 0;RtlCopyMemory(eaInfo->EaName, TdiConnectionContext, strlen(TdiConnectionContext) + 1);
status = ZwCreateFile(Handle, FILE_READ_EA | FILE_WRITE_EA, &ObjectAttributes,
&ioStatus,
NULL,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OPEN,
0,
eaInfo,
dwSize) ;if (!NT_SUCCESS(status))
{
VLSDLogSL(“VLSD: Creating connection handle fail. Error number 0x”, status);
return STATUS_INSUFFICIENT_RESOURCES;
}status = ObReferenceObjectByHandle(*Handle,
GENERIC_READ|GENERIC_WRITE,
NULL,
KernelMode,
(PVOID *)FileObject,
NULL);
if(!NT_SUCCESS(status))
ZwClose(*Handle);ExFreePool(eaInfo);
return status;
}Error always occur at function ZwCreateFile with status = 80000013 (system error code: 254 = ERROR_INVALID_EA_NAME) or status = 80000014 (255 = ERROR_EA_LIST_INCONSISTENT).
Please help me, thanks in adv!
VL.
September 10, 2004 at 11:35 am #56251. You should set EaValue to ULONG “Connetion context”
dwSize = FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + TDI_CONNECTION_CONTEXT_LENGTH + 1 + sizeof(CONNECTION_CONTEXT);
eaInfo = (PFILE_FULL_EA_INFORMATION)ExAllocatePool(PagedPool, dwSize);
eaInfo->NextEntryOffset = 0;
eaInfo->Flags = 0;
eaInfo->EaNameLength = TDI_CONNECTION_CONTEXT_LENGTH;
eaInfo->EaValueLength = sizeof(CONNECTION_CONTEXT);RtlCopyMemory(
eaInfo->EaName,
TdiConnectionContext,
TDI_CONNECTION_CONTEXT_LENGTH+1
);RtlCopyMemory(
&eaInfo->EaName[TDI_CONNECTION_CONTEXT_LENGTH+1],
pConnectionContext,
sizeof(CONNECTION_CONTEXT)
);2. It’s better to open “connection endpoint” with the following attributes:
ZwCreateFile(
Handle, // Handle
GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, // Desired Access
&ObjectAttributes, // Object Attributes
&IoStatusBlock, // Final I/O status block
0, // Allocation Size
FILE_ATTRIBUTE_NORMAL, // Normal attributes
FILE_SHARE_READ, // Sharing attributes
FILE_OPEN_IF, // Create disposition
0, // CreateOptions
pConnectionContextEa, // EA Buffer
TransportEaBufferLength // EA length
);September 12, 2004 at 12:04 pm #5626Dear Anton, thanks so much for your help. Thank you again. 😆
-
AuthorPosts
- You must be logged in to reply to this topic.