Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

Link data kernel-mode <-> user-mode with pipename

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.
0 Kudos
Message 1 of 2
(7,127 Views)
Hi sivaller,

Are you asking a general Windows user/kernel mode question, or is this in relation to a National Instruments product for use with the Measurements Hardware Driver Developer Kit (DDK)?  It sounds like you might find better luck getting an answer to your question in a different section of ni.com or, perhaps more likely, on a Microsoft forum. 

If you are using the DDK, please list some more background information about your device and use case so we can better understand the context of your question.

Thanks!

-Ed
0 Kudos
Message 2 of 2
(7,121 Views)