Hello,
I would link data from user-mode <-> kernel-mode using pipes.
In user-mode and I use API function
CreateNamedPipe(\\\\.\\Pipe\\MyNamedPipe,....)
and in kernel-mode I use InitializeObject ... and
ZwCreateFile("\\??\\Pipe\MyNamedPipe").
Question in kernel-mode :
If the buffer of the pipe is empty , the function ZwReadfile on a pipe
handle can it return NTSTATUS STATUS_PENDING or waits until the buffer
pipe is not empty ?
If the buffer of the pipe is full ZwReadFile on a handle can also
return NTSTATUS STATUS_PENDING or waits until the buffer pipe is not full ?
If they returned STATUS_PENDING how waiting data from the pipe ?
A solution but .....
NTSTATUS
ZwReadFile(
IN HANDLE FileHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID Buffer,
IN ULONG Length,
IN PLARGE_INTEGER ByteOffset OPTIONAL,
IN PULONG Key OPTIONAL
);
NTSTATUS
ZwWriteFile(
IN HANDLE FileHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN PVOID Buffer,
IN ULONG Length,
IN PLARGE_INTEGER ByteOffset OPTIONAL,
IN PULONG Key OPTIONAL
);
Make call function waitevent with the parameter "Event"
previously initialised.
Have you other solution for waiting data from the pipe in a kernel-mode ??
#user-mode:
#include <windows.h>
#define g_szPipeName "\\\\.\\Pipe\\MyNamedPipe"
#define BUFSIZE 10 //1k
//Open file driver
...
...
HANDLE hPipe = CreateNamedPipe(
g_szPipeName, // pipe name
PIPE_ACCESS_DUPLEX, // read/write access
PIPE_TYPE_MESSAGE | // message type pipe
PIPE_READMODE_MESSAGE | // message-read mode
PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // max. instances
BUFSIZE, // output buffer size
BUFSIZE, // input buffer size
100, // client time-out
NULL);
DWORD thid=0;
DeviceIoControl (....)
// default security attribute
bool fConnected = ConnectNamedPipe(hPipe, NULL) ?
TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
//Server in the user-mode . Data receive sended by driver in kernel-mode
//
Thank you.