Hi ,
I need to allocate memory in kernel mode , fill it and then user mode
application has to read from it.

I have created a named section object in kernel space with the name
"\\device\\sharedmemory" using ZwCreateSection function.


But the problem is when I use the function "CreateFileMapping", with
"\\device\\sharedmemory" as its last argument, in user mode application

, it fails to open the section object already created in the kernel
mode.


If I give different name than "\\device\\sharedmemory" in
ZwCreateSection in kernel mode driver, then ZwCreateSection function
fails.


I am not able to figure out the problem .


How to access the kernel mode memory from user mode.


Please help.


Thanking You

Re: Getting Kernel Shared section object name in Appln by Doron

Doron
Mon Sep 11 01:07:26 CDT 2006

once you have a shared section, what are you going to do with it? use it to
share data between your application and a driver? if so, there are easier
(and more documented) ways of doing this.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Chin" <chintin@gmail.com> wrote in message
news:1157950136.857426.78040@p79g2000cwp.googlegroups.com...
> Hi ,
> I need to allocate memory in kernel mode , fill it and then user mode
> application has to read from it.
>
> I have created a named section object in kernel space with the name
> "\\device\\sharedmemory" using ZwCreateSection function.
>
>
> But the problem is when I use the function "CreateFileMapping", with
> "\\device\\sharedmemory" as its last argument, in user mode application
>
> , it fails to open the section object already created in the kernel
> mode.
>
>
> If I give different name than "\\device\\sharedmemory" in
> ZwCreateSection in kernel mode driver, then ZwCreateSection function
> fails.
>
>
> I am not able to figure out the problem .
>
>
> How to access the kernel mode memory from user mode.
>
>
> Please help.
>
>
> Thanking You
>



Re: Getting Kernel Shared section object name in Appln by Chin

Chin
Mon Sep 11 04:29:59 CDT 2006

Thanks, I ll have to look it other way, but do u have any suggestions
as how to open the named objects created in kernel by createfilemapping
.?

Doron Holan [MS] wrote:
> once you have a shared section, what are you going to do with it? use it to
> share data between your application and a driver? if so, there are easier
> (and more documented) ways of doing this.
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
> "Chin" <chintin@gmail.com> wrote in message
> news:1157950136.857426.78040@p79g2000cwp.googlegroups.com...
> > Hi ,
> > I need to allocate memory in kernel mode , fill it and then user mode
> > application has to read from it.
> >
> > I have created a named section object in kernel space with the name
> > "\\device\\sharedmemory" using ZwCreateSection function.
> >
> >
> > But the problem is when I use the function "CreateFileMapping", with
> > "\\device\\sharedmemory" as its last argument, in user mode application
> >
> > , it fails to open the section object already created in the kernel
> > mode.
> >
> >
> > If I give different name than "\\device\\sharedmemory" in
> > ZwCreateSection in kernel mode driver, then ZwCreateSection function
> > fails.
> >
> >
> > I am not able to figure out the problem .
> >
> >
> > How to access the kernel mode memory from user mode.
> >
> >
> > Please help.
> >
> >
> > Thanking You
> >


Re: Getting Kernel Shared section object name in Appln by Anatoly

Anatoly
Sun Sep 10 15:51:26 CDT 2006

Hi Chin,

To use data buffer between application and driver you can either allocate
buffer in the driver and map it to user space or allocate buffer in
application and lock it in kernel space. Either way is documented, see
MmProbeAndLockPages.

Anatoly.

"Chin" <chintin@gmail.com> wrote in message
news:1157950136.857426.78040@p79g2000cwp.googlegroups.com...
> Hi ,
> I need to allocate memory in kernel mode , fill it and then user mode
> application has to read from it.
>
> I have created a named section object in kernel space with the name
> "\\device\\sharedmemory" using ZwCreateSection function.
>
>
> But the problem is when I use the function "CreateFileMapping", with
> "\\device\\sharedmemory" as its last argument, in user mode application
>
> , it fails to open the section object already created in the kernel
> mode.
>
>
> If I give different name than "\\device\\sharedmemory" in
> ZwCreateSection in kernel mode driver, then ZwCreateSection function
> fails.
>
>
> I am not able to figure out the problem .
>
>
> How to access the kernel mode memory from user mode.
>
>
> Please help.
>
>
> Thanking You
>



Re: Getting Kernel Shared section object name in Appln by Don

Don
Mon Sep 11 05:35:56 CDT 2006

Unless you are doing many MB/sec this approach is a terrible way to do
things. First, it is non-standard, second you have to come up with a way to
synchronize the user and kernel space code safely. Third you have to build
in a detection mechanism in case the application dies so you can clean up
things.

Consider using the inverted call mechanism, see
http://www.osronline.com/article.cfm?id=94 This is the common approach
Windows drivers, you use IOCTL's to send data from the user to the driver,
and you use one of more IOCTL's pended in the driver to notify and send data
to the user application.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply



"Chin" <chintin@gmail.com> wrote in message
news:1157966999.330406.102650@m73g2000cwd.googlegroups.com...
> Thanks, I ll have to look it other way, but do u have any suggestions
> as how to open the named objects created in kernel by createfilemapping
> .?
>
> Doron Holan [MS] wrote:
>> once you have a shared section, what are you going to do with it? use it
>> to
>> share data between your application and a driver? if so, there are
>> easier
>> (and more documented) ways of doing this.
>>
>> d
>>
>> --
>> Please do not send e-mail directly to this alias. this alias is for
>> newsgroup purposes only.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>> "Chin" <chintin@gmail.com> wrote in message
>> news:1157950136.857426.78040@p79g2000cwp.googlegroups.com...
>> > Hi ,
>> > I need to allocate memory in kernel mode , fill it and then user mode
>> > application has to read from it.
>> >
>> > I have created a named section object in kernel space with the name
>> > "\\device\\sharedmemory" using ZwCreateSection function.
>> >
>> >
>> > But the problem is when I use the function "CreateFileMapping", with
>> > "\\device\\sharedmemory" as its last argument, in user mode application
>> >
>> > , it fails to open the section object already created in the kernel
>> > mode.
>> >
>> >
>> > If I give different name than "\\device\\sharedmemory" in
>> > ZwCreateSection in kernel mode driver, then ZwCreateSection function
>> > fails.
>> >
>> >
>> > I am not able to figure out the problem .
>> >
>> >
>> > How to access the kernel mode memory from user mode.
>> >
>> >
>> > Please help.
>> >
>> >
>> > Thanking You
>> >
>



Re: Getting Kernel Shared section object name in Appln by Maxim

Maxim
Mon Sep 11 14:16:43 CDT 2006

> To use data buffer between application and driver you can either allocate
> buffer in the driver and map it to user space or allocate buffer in
> application and lock it in kernel space.

Is you use the first way - ensure that the buffer's allocation size is >
PAGE_SIZE, so the other pool blocks will not appear in user space.

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


Re: Getting Kernel Shared section object name in Appln by anshul

anshul
Mon Sep 11 22:45:43 CDT 2006

Hi,
I am also doing the same task of allocating the memory in kernel and using
that memory in my application.
The above task has been done by using section objects.

In application , your CreateFileMapping is failing! And that is true also.
It should fail as the memory object has already been created in the driver .

So instead use, OpenFileMapping directly without using CreateFileMapping.



"Chin" <chintin@gmail.com> wrote in message
news:1157950136.857426.78040@p79g2000cwp.googlegroups.com...
> Hi ,
> I need to allocate memory in kernel mode , fill it and then user mode
> application has to read from it.
>
> I have created a named section object in kernel space with the name
> "\\device\\sharedmemory" using ZwCreateSection function.
>
>
> But the problem is when I use the function "CreateFileMapping", with
> "\\device\\sharedmemory" as its last argument, in user mode application
>
> , it fails to open the section object already created in the kernel
> mode.
>
>
> If I give different name than "\\device\\sharedmemory" in
> ZwCreateSection in kernel mode driver, then ZwCreateSection function
> fails.
>
>
> I am not able to figure out the problem .
>
>
> How to access the kernel mode memory from user mode.
>
>
> Please help.
>
>
> Thanking You
>