Vista SP1 - Sharing memory between usermode and kernelmode

Before you get an answer on this, you are going to have to explain why you
want to open all the security holes and other problems of sharing memory
between kernel and user space. If you check the archives of this group you
will see lots of discussions on this, and in most cases the use of a shared
section cannot be justified.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

wrote in message news:xxxxx@ntdev…
> Hi guys,
>
> Im writting a module that share a section between kernelmode and usermode.
> The method I use is using ZwCreateSection to create a named section then
> ZwMapViewOfSection (path to section object is
> \BaseNamedObjects\name_of_section, set to ObjectAttributes->ObjectName) in
> kernel mode. In usermode, I use CreateFileMapping with the name of
> aforementioned section to get handle and use the handle to map view the
> section into usermode view.
>
> The method works smoothly with Windows 2000, XP and 2003 but not Vista
> SP1.
>
> In Vista SP1, ZwCreateSection & ZwMapViewOfSection calls result is
> STATUS_SUCCESS, CreateFileMapping is also successful in creating the
> section with the same name while OpenFileMapping return
> ERROR_FILE_NOT_FOUND. I thought that there’s chance that CreateFileMapping
> return section handle of a section different to section that created by
> ZwCreateSection may be due to Vista internal changes, but I couldnt find
> any other section with a same name in the object directory, so the section
> must be unique.
>
>
> The problem arises when I read/write data into shared section. The
> kernelmode code can freely read/write to shared section and so does the
> usermode module. But, it seems they read/write into two different
> sections. The kernelmode write “A” in to section through the mapped view,
> but usermode cannot see this change and vice versa.
>
> I know there’s method which lock pages and map usermode virtual memory
> into kernel mode memory region but I want to discuss about the
> ZwCreateSection/CreateFileMapping method in Vista SP1 to know whether
> there’s any modification to make it work or not.
>
> Any idea is appreciated.
>
>