Viet Long
September 10th, 2004, 02:28 AM
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,
BJ_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,
ENERIC_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.
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,
BJ_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,
ENERIC_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.