I still developing a virtual device driver based on the MS Ramdisk demo.
I Run a named pipe host (overlaped) in user mode w/o problems when my clients is also in user mode, also my driver in kernel mode can write to this pipe very good, but when read, the pipe host (in user mode) return an error 232 (ERROR_NO_DATA), the pipe is configured as PIPE_WAIT, the driver at NTSTATUS returns 0x103 (status_pending), (the driver previously performs two writes to the pipe, before to read the pipe w/o disconecting), also the driver returns at IOstatus: IO NFO FILE_OPENED, NT_STATUS (IO_STATUS) 0L (SUCCESS ?)
Whats going on, what can I do, looks like a client that don’t know that the pipe is in blocking mode (PIPE_WAIT).
Thanks,
J.A. Acosta
This is my kernel mode pipe client code:BOOL RdPipe(ULONG offset, void* pBuf,ULONG bufSize){NTSTATUS ntStatus;int i = 0;LARGE_INTEGER duetime = {1000};//PWSTR lpszPipename = L"\??\pipe\RamDrvIn";HANDLE hPipe; OBJECT_ATTRIBUTES objectAttributes;UNICODE_STRING fullFileName;IO_STATUS_BLOCK ioStatus;RtlInitUnicodeString (&fullFileName, L"\??\pipe\RamDrvIn");InitializeObjectAttributes (&objectAttributes, &fullFileName, OBJ_CASE_INSENSITIVE|OBJ_PERMANENT , NULL, NULL);// Try to open a named pipe; wait for it, if necessary. InitializeObjectAttributes (&objectAttributes, &fullFileName, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);Dump(“RdPipe++ Offset:0x%X Sz:%i”,offset,bufSize);// Try to open a named pipe; wait for it, if necessary.for ( i = 0; i<30; i++){ ntStatus = ZwCreateFile (&hPipe,FILE_WRITE_DATA | FILE_READ_DATA | SYNCHRONIZE,&objectAttributes,&ioStatus,NULL,0,FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE ,FILE_OPEN,//FILE_NON_DIRECTORY_FILE,NULL,0);// Break if the pipe handle is valid. if( STATUS_PIPE_NOT_AVAILABLE != ntStatus )break;KeDelayExecutionThread(KernelMode ,FALSE, &duetime);}if( !NT_SUCCESS(ntStatus) ){ReportError(ntStatus,&ioStatus,“RdPIPE-Open-Failed”);return -1;} if (hPipe == INVALID_HANDLE_VALUE ){return -1;}ntStatus = ZwWriteFile(hPipe,NULL,NULL,NULL,&ioStatus,&offset,sizeof(offset),NULL,NULL);if (!NT_SUCCESS(ntStatus)){ReportError(ntStatus,&ioStatus,“RdPIPE-Write1”);ZwClose(hPipe); return -1;}ntStatus = ZwWriteFile(hPipe,NULL,NULL,NULL,&ioStatus,&bufSize,sizeof(bufSize),NULL,NULL);if (!NT_SUCCESS(ntStatus)){ReportError(ntStatus,&ioStatus,“RdPIPE-Write2”);ZwClose(hPipe); return -1;}do { // Read from the pipe. ntStatus = ZwReadFile (hPipe, NULL, NULL, NULL,&ioStatus, pBuf, bufSize, NULL, NULL);ReportError(ntStatus,&ioStatus,“RdPIPE-Read(3) here the error”);if (!NT_SUCCESS(ntStatus) && /*GetLastError()*/ ioStatus.Status != 324L /*ERROR_MORE_DATA*/) break; } while (!NT_SUCCESS(ntStatus)); // repeat loop if ERROR_MORE_DATA if (!NT_SUCCESS(ntStatus)){ReportError(ntStatus,&ioStatus,“RdPIPE-Read(3)”);ZwClose(hPipe); return -1;}ntStatus = ZwClose(hPipe); if(!NT_SUCCESS(ntStatus))ReportError(ntStatus,&ioStatus,“RdPIPE-Close”);Dump(“RdPipe–”);return ntStatus; }