How to create a named pipe in kernel?

Hello,

I want to create a named pipe in kernel mode, IoCreateFile parameters are valid, but ObOpenObjectByName (in IoCreateFile) fails, one of the return codes are: STATUS_OBJECT_PATH_NOT_FOUND, STATUS_INVALID_PARAMETER, …

Maybe because I’m not sure what pipe name it really should be, I’ve tried:
??\pipe\MyPipeName
\DosDevices\pipe\MyPipeName (but DosDevices should be ?? equivalent)
\Device\NamedPipe\MyPipeName
etc.

Eventually, I’d create a named pipe in user-mode and open it in kerne - it’d be much easier, but still…

My source code is here:

// create a name
swprintf((wchar_t*) &szwPipeName, CALLBACK_PIPE_NAME_KERNEL, uRegisteredID );
RtlInitUnicodeString( &uPipeName, szwPipeName );
InitializeObjectAttributes( &objAttr, &uPipeName, OBJ_CASE_INSENSITIVE, NULL, NULL );

NAMED_PIPE_CREATE_PARAMETERS namedPipeCreateParams;

namedPipeCreateParams.NamedPipeType = FILE_PIPE_BYTE_STREAM_TYPE;
namedPipeCreateParams.ReadMode = FILE_PIPE_BYTE_STREAM_MODE;
namedPipeCreateParams.CompletionMode = FILE_PIPE_COMPLETE_OPERATION; // non-blocking mode
namedPipeCreateParams.MaximumInstances = -1;
namedPipeCreateParams.InboundQuota = 4096;
namedPipeCreateParams.OutboundQuota = 4096;
namedPipeCreateParams.TimeoutSpecified = FALSE;

status = IoCreateFile( &crNode.hPipe, GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE,
&objAttr, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_CREATE,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL, 0, CreateFileTypeNamedPipe, &namedPipeCreateParams, IO_NO_PARAMETER_CHECKING );

thanks,
Petr Kurtin

Why in the world would you want to communicate between the kernel and user
space this way?


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Petr Kurtin” wrote in message news:xxxxx@ntdev…
Hello,

I want to create a named pipe in kernel mode, IoCreateFile parameters
are valid, but ObOpenObjectByName (in IoCreateFile) fails, one of the return
codes are: STATUS_OBJECT_PATH_NOT_FOUND, STATUS_INVALID_PARAMETER, …

Maybe because I’m not sure what pipe name it really should be, I’ve
tried:
??\pipe\MyPipeName
\DosDevices\pipe\MyPipeName (but DosDevices should be ?? equivalent)
\Device\NamedPipe\MyPipeName
etc.

Eventually, I’d create a named pipe in user-mode and open it in kerne -
it’d be much easier, but still…

My source code is here:

// create a name
swprintf((wchar_t*) &szwPipeName, CALLBACK_PIPE_NAME_KERNEL,
uRegisteredID );
RtlInitUnicodeString( &uPipeName, szwPipeName );
InitializeObjectAttributes( &objAttr, &uPipeName, OBJ_CASE_INSENSITIVE,
NULL, NULL );

NAMED_PIPE_CREATE_PARAMETERS namedPipeCreateParams;

namedPipeCreateParams.NamedPipeType = FILE_PIPE_BYTE_STREAM_TYPE;
namedPipeCreateParams.ReadMode = FILE_PIPE_BYTE_STREAM_MODE;
namedPipeCreateParams.CompletionMode = FILE_PIPE_COMPLETE_OPERATION;
// non-blocking mode
namedPipeCreateParams.MaximumInstances = -1;
namedPipeCreateParams.InboundQuota = 4096;
namedPipeCreateParams.OutboundQuota = 4096;
namedPipeCreateParams.TimeoutSpecified = FALSE;

status = IoCreateFile( &crNode.hPipe, GENERIC_READ | GENERIC_WRITE |
SYNCHRONIZE,
&objAttr, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_CREATE,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL, 0, CreateFileTypeNamedPipe, &namedPipeCreateParams,
IO_NO_PARAMETER_CHECKING );

thanks,
Petr Kurtin

well, what other methods would you suggest? I use pending IRPs for main
communication between kernel and user mode – but some information will need
to be send very frequently (e.g. what all new network connections have been
created, how many data have been transfered - small structures, but it’s not
needed for IRP wasting)… what do you think?

thanks, Petr

“Don Burn” wrote in message news:xxxxx@ntdev…
> Why in the world would you want to communicate between the kernel and user
> space this way?
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
>
>
>
> “Petr Kurtin” wrote in message news:xxxxx@ntdev…
> Hello,
>
> I want to create a named pipe in kernel mode, IoCreateFile parameters
> are valid, but ObOpenObjectByName (in IoCreateFile) fails, one of the
> return codes are: STATUS_OBJECT_PATH_NOT_FOUND, STATUS_INVALID_PARAMETER,
> …
>
> Maybe because I’m not sure what pipe name it really should be, I’ve
> tried:
> ??\pipe\MyPipeName
> \DosDevices\pipe\MyPipeName (but DosDevices should be ??
> equivalent)
> \Device\NamedPipe\MyPipeName
> etc.
>
> Eventually, I’d create a named pipe in user-mode and open it in kerne -
> it’d be much easier, but still…
>
> My source code is here:
>
> // create a name
> swprintf((wchar_t*) &szwPipeName, CALLBACK_PIPE_NAME_KERNEL,
> uRegisteredID );
> RtlInitUnicodeString( &uPipeName, szwPipeName );
> InitializeObjectAttributes( &objAttr, &uPipeName, OBJ_CASE_INSENSITIVE,
> NULL, NULL );
>
> NAMED_PIPE_CREATE_PARAMETERS namedPipeCreateParams;
>
> namedPipeCreateParams.NamedPipeType = FILE_PIPE_BYTE_STREAM_TYPE;
> namedPipeCreateParams.ReadMode = FILE_PIPE_BYTE_STREAM_MODE;
> namedPipeCreateParams.CompletionMode = FILE_PIPE_COMPLETE_OPERATION; //
> non-blocking mode
> namedPipeCreateParams.MaximumInstances = -1;
> namedPipeCreateParams.InboundQuota = 4096;
> namedPipeCreateParams.OutboundQuota = 4096;
> namedPipeCreateParams.TimeoutSpecified = FALSE;
>
> status = IoCreateFile( &crNode.hPipe, GENERIC_READ | GENERIC_WRITE |
> SYNCHRONIZE,
> &objAttr, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
> FILE_CREATE,
> FILE_SYNCHRONOUS_IO_NONALERT,
> NULL, 0, CreateFileTypeNamedPipe, &namedPipeCreateParams,
> IO_NO_PARAMETER_CHECKING );
>
> thanks,
> Petr Kurtin
>
>
>
>
>

Communication over a pipe uses irps as well, you just don’t see them.
Actually, I would assume that it would be worse since now both your
writes to the pipe and the app’s reads to the pipe will both result in
pipes being created and sent. Using named pipes in the kernel is not
documented, sticking with the inverted call model is documented (and in
this case, uses one less PIRP per transaction).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Petr Kurtin
Sent: Wednesday, December 14, 2005 2:05 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to create a named pipe in kernel?

well, what other methods would you suggest? I use pending IRPs for main
communication between kernel and user mode – but some information will
need
to be send very frequently (e.g. what all new network connections have
been
created, how many data have been transfered - small structures, but it’s
not
needed for IRP wasting)… what do you think?

thanks, Petr

“Don Burn” wrote in message news:xxxxx@ntdev…
> Why in the world would you want to communicate between the kernel and
user
> space this way?
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
>
>
>
> “Petr Kurtin” wrote in message news:xxxxx@ntdev…
> Hello,
>
> I want to create a named pipe in kernel mode, IoCreateFile
parameters
> are valid, but ObOpenObjectByName (in IoCreateFile) fails, one of the
> return codes are: STATUS_OBJECT_PATH_NOT_FOUND,
STATUS_INVALID_PARAMETER,
> …
>
> Maybe because I’m not sure what pipe name it really should be, I’ve

> tried:
> ??\pipe\MyPipeName
> \DosDevices\pipe\MyPipeName (but DosDevices should be ??
> equivalent)
> \Device\NamedPipe\MyPipeName
> etc.
>
> Eventually, I’d create a named pipe in user-mode and open it in
kerne -
> it’d be much easier, but still…
>
> My source code is here:
>
> // create a name
> swprintf((wchar_t*) &szwPipeName, CALLBACK_PIPE_NAME_KERNEL,
> uRegisteredID );
> RtlInitUnicodeString( &uPipeName, szwPipeName );
> InitializeObjectAttributes( &objAttr, &uPipeName,
OBJ_CASE_INSENSITIVE,
> NULL, NULL );
>
> NAMED_PIPE_CREATE_PARAMETERS namedPipeCreateParams;
>
> namedPipeCreateParams.NamedPipeType = FILE_PIPE_BYTE_STREAM_TYPE;
> namedPipeCreateParams.ReadMode = FILE_PIPE_BYTE_STREAM_MODE;
> namedPipeCreateParams.CompletionMode = FILE_PIPE_COMPLETE_OPERATION;
//
> non-blocking mode
> namedPipeCreateParams.MaximumInstances = -1;
> namedPipeCreateParams.InboundQuota = 4096;
> namedPipeCreateParams.OutboundQuota = 4096;
> namedPipeCreateParams.TimeoutSpecified = FALSE;
>
> status = IoCreateFile( &crNode.hPipe, GENERIC_READ | GENERIC_WRITE |
> SYNCHRONIZE,
> &objAttr, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
> FILE_CREATE,
> FILE_SYNCHRONOUS_IO_NONALERT,
> NULL, 0, CreateFileTypeNamedPipe, &namedPipeCreateParams,
> IO_NO_PARAMETER_CHECKING );
>
> thanks,
> Petr Kurtin
>
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Named pipes use IRPs and are going to be much more expensive than I/O
controls would be.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Petr Kurtin
Sent: Wednesday, December 14, 2005 2:05 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to create a named pipe in kernel?

well, what other methods would you suggest? I use pending IRPs for main
communication between kernel and user mode – but some information will
need to be send very frequently (e.g. what all new network connections
have been created, how many data have been transfered - small
structures, but it’s not needed for IRP wasting)… what do you think?

thanks, Petr

“Don Burn” wrote in message news:xxxxx@ntdev…
> Why in the world would you want to communicate between the kernel and
> user space this way?
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam
> from the email to reply
>
>
>
>
> “Petr Kurtin” wrote in message news:xxxxx@ntdev…
> Hello,
>
> I want to create a named pipe in kernel mode, IoCreateFile
> parameters are valid, but ObOpenObjectByName (in IoCreateFile) fails,
> one of the return codes are: STATUS_OBJECT_PATH_NOT_FOUND,
> STATUS_INVALID_PARAMETER, …
>
> Maybe because I’m not sure what pipe name it really should be, I’ve
> tried:
> ??\pipe\MyPipeName
> \DosDevices\pipe\MyPipeName (but DosDevices should be ??
> equivalent)
> \Device\NamedPipe\MyPipeName
> etc.
>
> Eventually, I’d create a named pipe in user-mode and open it in
> kerne - it’d be much easier, but still…
>
> My source code is here:
>
> // create a name
> swprintf((wchar_t*) &szwPipeName, CALLBACK_PIPE_NAME_KERNEL,
> uRegisteredID ); RtlInitUnicodeString( &uPipeName, szwPipeName );
> InitializeObjectAttributes( &objAttr, &uPipeName,
> OBJ_CASE_INSENSITIVE, NULL, NULL );
>
> NAMED_PIPE_CREATE_PARAMETERS namedPipeCreateParams;
>
> namedPipeCreateParams.NamedPipeType = FILE_PIPE_BYTE_STREAM_TYPE;
> namedPipeCreateParams.ReadMode = FILE_PIPE_BYTE_STREAM_MODE;
> namedPipeCreateParams.CompletionMode = FILE_PIPE_COMPLETE_OPERATION;
> // non-blocking mode namedPipeCreateParams.MaximumInstances = -1;
> namedPipeCreateParams.InboundQuota = 4096;
> namedPipeCreateParams.OutboundQuota = 4096;
> namedPipeCreateParams.TimeoutSpecified = FALSE;
>
> status = IoCreateFile( &crNode.hPipe, GENERIC_READ | GENERIC_WRITE |
> SYNCHRONIZE,
> &objAttr, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
> FILE_CREATE,
> FILE_SYNCHRONOUS_IO_NONALERT,
> NULL, 0, CreateFileTypeNamedPipe, &namedPipeCreateParams,
> IO_NO_PARAMETER_CHECKING );
>
> thanks,
> Petr Kurtin
>
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

thanks

I’d need to send lot of small structures to user-mode very often (to notify GUI about actual states on the network: what connection is sending, how much, etc) - therefore I thought, pending IRPs wouldn’t be the best - as alternative method, I could use a shared memory between kernel and user (although there might be some problems with synchronization).

-pk

“Doron Holan” wrote in message news:xxxxx@ntdev…
Communication over a pipe uses irps as well, you just don’t see them.
Actually, I would assume that it would be worse since now both your
writes to the pipe and the app’s reads to the pipe will both result in
pipes being created and sent. Using named pipes in the kernel is not
documented, sticking with the inverted call model is documented (and in
this case, uses one less PIRP per transaction).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Petr Kurtin
Sent: Wednesday, December 14, 2005 2:05 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to create a named pipe in kernel?

well, what other methods would you suggest? I use pending IRPs for main
communication between kernel and user mode – but some information will
need
to be send very frequently (e.g. what all new network connections have
been
created, how many data have been transfered - small structures, but it’s
not
needed for IRP wasting)… what do you think?

thanks, Petr

“Don Burn” wrote in message news:xxxxx@ntdev…
> Why in the world would you want to communicate between the kernel and
user
> space this way?
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
>
>
>
> “Petr Kurtin” wrote in message news:xxxxx@ntdev…
> Hello,
>
> I want to create a named pipe in kernel mode, IoCreateFile
parameters
> are valid, but ObOpenObjectByName (in IoCreateFile) fails, one of the
> return codes are: STATUS_OBJECT_PATH_NOT_FOUND,
STATUS_INVALID_PARAMETER,
> …
>
> Maybe because I’m not sure what pipe name it really should be, I’ve

> tried:
> ??\pipe\MyPipeName
> \DosDevices\pipe\MyPipeName (but DosDevices should be ??
> equivalent)
> \Device\NamedPipe\MyPipeName
> etc.
>
> Eventually, I’d create a named pipe in user-mode and open it in
kerne -
> it’d be much easier, but still…
>
> My source code is here:
>
> // create a name
> swprintf((wchar_t*) &szwPipeName, CALLBACK_PIPE_NAME_KERNEL,
> uRegisteredID );
> RtlInitUnicodeString( &uPipeName, szwPipeName );
> InitializeObjectAttributes( &objAttr, &uPipeName,
OBJ_CASE_INSENSITIVE,
> NULL, NULL );
>
> NAMED_PIPE_CREATE_PARAMETERS namedPipeCreateParams;
>
> namedPipeCreateParams.NamedPipeType = FILE_PIPE_BYTE_STREAM_TYPE;
> namedPipeCreateParams.ReadMode = FILE_PIPE_BYTE_STREAM_MODE;
> namedPipeCreateParams.CompletionMode = FILE_PIPE_COMPLETE_OPERATION;
//
> non-blocking mode
> namedPipeCreateParams.MaximumInstances = -1;
> namedPipeCreateParams.InboundQuota = 4096;
> namedPipeCreateParams.OutboundQuota = 4096;
> namedPipeCreateParams.TimeoutSpecified = FALSE;
>
> status = IoCreateFile( &crNode.hPipe, GENERIC_READ | GENERIC_WRITE |
> SYNCHRONIZE,
> &objAttr, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
> FILE_CREATE,
> FILE_SYNCHRONOUS_IO_NONALERT,
> NULL, 0, CreateFileTypeNamedPipe, &namedPipeCreateParams,
> IO_NO_PARAMETER_CHECKING );
>
> thanks,
> Petr Kurtin
>
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Petr Kurtin wrote:

I’d need to send lot of small structures to user-mode very often (to
notify GUI about actual states on the network: what connection is
sending, how much, etc) - therefore I thought, pending IRPs wouldn’t
be the best - as alternative method, I could use a shared memory
between kernel and user (although there might be some problems with
synchronization).

Step back for a moment and think about your requirement.

What would you gain by updating a shared memory structure? After the
information has been updated, in order to DO anything with that
information, the system is going to have to get out of your driver, do a
context switch back to your application, and shift back into user mode,
just so you can check to see whether anything has updated, and then
(presumably) update a UI somewhere.

Instead, you should just have your driver keep the statistics to
itself. When your application wants to update the UI, it should send
one synchronous ioctl. The driver can copy the statistics information
in, and return. One IRP, in and out, no queueing. It’s the same
overhead, but a much safer process.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Pending IRPs has smaller overhead then the NPFS which does lots of work
internally (yes, including pending the IRPs).

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Petr Kurtin”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Thursday, December 15, 2005 1:04 AM
Subject: Re:[ntdev] How to create a named pipe in kernel?

> well, what other methods would you suggest? I use pending IRPs for main
> communication between kernel and user mode – but some information will need
> to be send very frequently (e.g. what all new network connections have been
> created, how many data have been transfered - small structures, but it’s not
> needed for IRP wasting)… what do you think?
>
> thanks, Petr
>
>
> “Don Burn” wrote in message news:xxxxx@ntdev…
> > Why in the world would you want to communicate between the kernel and user
> > space this way?
> >
> > –
> > Don Burn (MVP, Windows DDK)
> > Windows 2k/XP/2k3 Filesystem and Driver Consulting
> > Remove StopSpam from the email to reply
> >
> >
> >
> >
> > “Petr Kurtin” wrote in message news:xxxxx@ntdev…
> > Hello,
> >
> > I want to create a named pipe in kernel mode, IoCreateFile parameters
> > are valid, but ObOpenObjectByName (in IoCreateFile) fails, one of the
> > return codes are: STATUS_OBJECT_PATH_NOT_FOUND, STATUS_INVALID_PARAMETER,
> > …
> >
> > Maybe because I’m not sure what pipe name it really should be, I’ve
> > tried:
> > ??\pipe\MyPipeName
> > \DosDevices\pipe\MyPipeName (but DosDevices should be ??
> > equivalent)
> > \Device\NamedPipe\MyPipeName
> > etc.
> >
> > Eventually, I’d create a named pipe in user-mode and open it in kerne -
> > it’d be much easier, but still…
> >
> > My source code is here:
> >
> > // create a name
> > swprintf((wchar_t*) &szwPipeName, CALLBACK_PIPE_NAME_KERNEL,
> > uRegisteredID );
> > RtlInitUnicodeString( &uPipeName, szwPipeName );
> > InitializeObjectAttributes( &objAttr, &uPipeName, OBJ_CASE_INSENSITIVE,
> > NULL, NULL );
> >
> > NAMED_PIPE_CREATE_PARAMETERS namedPipeCreateParams;
> >
> > namedPipeCreateParams.NamedPipeType = FILE_PIPE_BYTE_STREAM_TYPE;
> > namedPipeCreateParams.ReadMode = FILE_PIPE_BYTE_STREAM_MODE;
> > namedPipeCreateParams.CompletionMode = FILE_PIPE_COMPLETE_OPERATION; //
> > non-blocking mode
> > namedPipeCreateParams.MaximumInstances = -1;
> > namedPipeCreateParams.InboundQuota = 4096;
> > namedPipeCreateParams.OutboundQuota = 4096;
> > namedPipeCreateParams.TimeoutSpecified = FALSE;
> >
> > status = IoCreateFile( &crNode.hPipe, GENERIC_READ | GENERIC_WRITE |
> > SYNCHRONIZE,
> > &objAttr, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
> > FILE_CREATE,
> > FILE_SYNCHRONOUS_IO_NONALERT,
> > NULL, 0, CreateFileTypeNamedPipe, &namedPipeCreateParams,
> > IO_NO_PARAMETER_CHECKING );
> >
> > thanks,
> > Petr Kurtin
> >
> >
> >
> >
> >
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

>I’d need to send lot of small structures to user-mode very often (to notify
GUI

about actual states on the network: what connection is sending, how much,

This is not lots. 2-3 times per second is enough. Tiny load.

etc) ?- therefore I thought, pending IRPs wouldn’t be the best - as
alternative
method, I could use a shared memory between kernel and user

Pending IRPs is always better.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Shared memory would be good. You could then use a shared event + mutex, or
a semaphore, to synchronize access to the shared memory segment. You
should, of course, batch your transfers. That is, if you need to send many
transfers to user-mode, then your driver should handle combining them in the
shared memory segment. The reader and writer of that buffer should only
have to deal with the synchronization primitives once, in order to transfer
a large number of messages.

Shared memory will probably get you close to the theoretical maximum,
especially if you are smart with buffer ownership / management. Your goal
should be to reduce the number of buffer copies and lock acquisitions /
releases. Also, it’s easy to set up, is reliable, and is documented. You
will need to be careful to deal with the fact that the section view is
mapped into a particular process, though. If your driver is running in the
context of a different process (and it will be, in many cases!), you can’t
touch the section view.

Which is why you should still consider using pended IRPs. Your application
can keep a pool of I/O control requests pended to your driver. The best
number of IRPs could be found through experimentation, but a good
off-the-cuff number is 8 buffers, each containing (say) 64K. Use direct
I/O, not buffered, for your requests. This will get you very close to the
shared memory performance.

Seriously, don’t underestimate the IRP path. And with small buffer sizes,
even buffered I/O can be quite fast. As always, measure measure measure!
Use a profiler before you assume that solution X “must be better” than
solution Y.

– arlie


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Petr Kurtin
Sent: Wednesday, December 14, 2005 6:59 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to create a named pipe in kernel?

thanks

I’d need to send lot of small structures to user-mode very often (to notify
GUI about actual states on the network: what connection is sending, how
much, etc) - therefore I thought, pending IRPs wouldn’t be the best - as
alternative method, I could use a shared memory between kernel and user
(although there might be some problems with synchronization).

-pk

“Doron Holan”
> wrote in message news:xxxxx@ntdev news:xxxxx
Communication over a pipe uses irps as well, you just don’t see them.
Actually, I would assume that it would be worse since now both your
writes to the pipe and the app’s reads to the pipe will both result in
pipes being created and sent. Using named pipes in the kernel is not
documented, sticking with the inverted call model is documented (and in
this case, uses one less PIRP per transaction).

d

-----Original Message-----
From: xxxxx@lists.osr.com
mailto:xxxxx
[mailto:xxxxx@lists.osr.com] On Behalf Of Petr Kurtin
Sent: Wednesday, December 14, 2005 2:05 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to create a named pipe in kernel?

well, what other methods would you suggest? I use pending IRPs for main
communication between kernel and user mode – but some information will
need
to be send very frequently (e.g. what all new network connections have
been
created, how many data have been transfered - small structures, but it’s
not
needed for IRP wasting)… what do you think?

thanks, Petr</mailto:xxxxx></news:xxxxx>