this is my source code for function called from thread creating by driver.
This function read data from other driver using ZwReadFile function.

My problem is that ZwReadFunction always returns STATUS_INVALID_PARAMETER.
I try evryfing for 2 days, but i can't find bug. Please help me




NTSTATUS status;
HANDLE SvanRTHandle;

PBYTE buffor[SVAN_RT_READ_BUFFER_COUNT];
IO_STATUS_BLOCK io_status[SVAN_RT_READ_BUFFER_COUNT];
UNICODE_STRING ReadEventName;
UNICODE_STRING ReadEventNumber;

ULONG size;
LONG i, tmp;
ULONG j;
PBYTE buf;
//handle used to read data from SvanRTDriver
PVOID event[2];
PVOID revent[SVAN_RT_READ_BUFFER_COUNT + 1];
HANDLE h_ReadComplete[SVAN_RT_READ_BUFFER_COUNT];

...............

RtlInitUnicodeString(&USvanRTDeviceName,SvanRTDeviceName);
InitializeObjectAttributes(&ObjectAttributes, &USvanRTDeviceName,
OBJ_KERNEL_HANDLE /*| OBJ_EXCLUSIVE*/ , NULL, NULL);

DPF_ENTER(("READ - OpenFileForRead"));
status = ZwCreateFile(&SvanRTHandle, FILE_READ_DATA, &ObjectAttributes
,io_status, 0, FILE_ATTRIBUTE_NORMAL, 0, FILE_OPEN_IF,
FILE_NON_DIRECTORY_FILE, NULL,0);
if(!NT_SUCCESS(status))
{
DPF_ENTER(("READ - SvanRTDriver open error 0x%x",status));
KeSetEvent(&SvanRTThredEnd, 0, FALSE);
PsTerminateSystemThread(STATUS_SUCCESS);
return status;
}


ReadEventName.Length = 0;
ReadEventName.MaximumLength = 100;
ReadEventName.Buffer = (PWSTR)ExAllocatePool(NonPagedPool, 200);


ReadEventNumber.Length = 0;
ReadEventNumber.MaximumLength = 100;
ReadEventNumber.Buffer = (PWSTR)ExAllocatePool(NonPagedPool, 200);

for(i = 0; i < SVAN_RT_READ_BUFFER_COUNT; i++)
{
ReadEventName.Buffer[0]=0;
ReadEventName.Buffer[1]=0;
ReadEventName.Length = 0;

RtlAppendUnicodeToString(&ReadEventName,L"\\BaseNamedObjects\\SvRTEv");
RtlIntegerToUnicodeString(i,10,&ReadEventNumber);
RtlAppendUnicodeStringToString(&ReadEventName,&ReadEventNumber);

DPF_ENTER(("READ - Create read end notification event
%S,%d",ReadEventName.Buffer ,i));
revent[i + 1] = IoCreateNotificationEvent(&ReadEventName, h_ReadComplete +
i);

buffor[i] = (PBYTE)ExAllocatePool(NonPagedPool, read_buffor_size);

DPF_ENTER(("READ - send read request %d - event object address %p handle
0x%x bufor %p read_buffor_size %d" ,i ,revent [i +
1],h_ReadComplete[i],buffor[i],read_buffor_size));
status = ZwReadFile(SvanRTHandle, h_ReadComplete[i], NULL, NULL, io_status
+ i, buffor[i], read_buffor_size, NULL, NULL);
DPF_ENTER(("READ - Status = 0x%x",status));
}

ps. I need acychronus data read.


Radek