Shared memory

Hello Everyone,

I have the following quick question and hope someone can help me.

A while ago I have written a shared memory buffer for exchange of data
between applications. It utilizes Win32 functions such as
CreateFileMapping() and MapViewOfFile()… I am now trying to create an
interface for this shared memory buffer in a kernel mode driver, however I
have not been able to find functions that I could use in conjunction with
the CreateFileMapping()/MapViewOfFile() that are used in user mode.

I have looked at ZwOpenSection() and ZwMapViewOfSection() but they do not
seem to have a notion of a “named” object…

I am mostly aware of how the memory is managed in kernel mode and wondering
if the whole approach I am taking is wrong and instead I should just take a
user app buffer and somehow lock it thus creating a shared area… However
it must be fast, there should be no context switches.

Thanks,

Anton

Hello,

ZwOpenSection *does* allow one to open named section
objects. You can specify the name of the section in
ObjectName field in OBJECT_ATTRIBUTES structure.

-Prasad

— “Anton S. Yemelyanov” wrote:
> Hello Everyone,
>
> I have the following quick question and hope someone
> can help me.
>
> A while ago I have written a shared memory buffer
> for exchange of data
> between applications. It utilizes Win32 functions
> such as
> CreateFileMapping() and MapViewOfFile()… I am now
> trying to create an
> interface for this shared memory buffer in a kernel
> mode driver, however I
> have not been able to find functions that I could
> use in conjunction with
> the CreateFileMapping()/MapViewOfFile() that are
> used in user mode.
>
> I have looked at ZwOpenSection() and
> ZwMapViewOfSection() but they do not
> seem to have a notion of a “named” object…
>
> I am mostly aware of how the memory is managed in
> kernel mode and wondering
> if the whole approach I am taking is wrong and
> instead I should just take a
> user app buffer and somehow lock it thus creating a
> shared area… However
> it must be fast, there should be no context
> switches.
>
> Thanks,
>
> Anton
>

=====
Prasad S. Dabak
Director of Engineering, Windows NT/2000 Division
Cybermedia Software Private Limited
http://www.cybermedia.co.in
Co-author of the book “Undocumented Windows NT”
ISBN 0764545698

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

Actually ZwOpenSection do allow to open named sections.
You must call InitializeObjectAttributes with ObjetAttributes structure
initialized to your desired name.

Sharing memory mapped areas between user and kernel mode is common practice
and it is fast.

To avoid context switches while you are working with this buffer you may
create a thread in user mode and then pass this thread down
using an IOCTL call. Then you may use this thread in kernel mode to perform
any task you need.
Note that you can access also SYSTEM space from this thread/context .

Inaki.

-----Original Message-----
From: Anton S. Yemelyanov
Sent: mi?rcoles 15 de marzo de 2000 12:36
To: File Systems Developers
Subject: [ntfsd] Shared memory

Hello Everyone,

I have the following quick question and hope someone can help me.

A while ago I have written a shared memory buffer for exchange of data
between applications. It utilizes Win32 functions such as
CreateFileMapping() and MapViewOfFile()… I am now trying to create an
interface for this shared memory buffer in a kernel mode driver, however I
have not been able to find functions that I could use in conjunction with
the CreateFileMapping()/MapViewOfFile() that are used in user mode.

I have looked at ZwOpenSection() and ZwMapViewOfSection() but they do not
seem to have a notion of a “named” object…

I am mostly aware of how the memory is managed in kernel mode and
wondering if the whole approach I am taking is wrong and instead I should
just take a user app buffer and somehow lock it thus creating a shared
area… However it must be fast, there should be no context switches.

Thanks,

Anton

>I have looked at ZwOpenSection() and ZwMapViewOfSection() but they do

not seem to have a notion of a “named” object…

ZwOpenSection must have the ObjectAttributes parameter where the name
is stored. Use InitializeObjectAttributes.

wondering if the whole approach I am taking is wrong and instead I should
just take a user app buffer and somehow lock it thus creating a shared
area…

This is possible. And this is a good way if the buffer is small - locking
large
buffers degrades the system performance.

Max