Hi all,

I am newbie for driver programming.

I created a shared memory in driver program using
ExAllocatePoolWithTag,
the last parameter is the address a string "ADDR".

Then I tried to access that shared memory from one application using
OpenFileMapping with lpName "ADDR".

It failed, shows no access to that memory. Then I changed the
parameter in OpenFileMapping to a random bad name, I got the same
error.

That program can work with shared memory which created using
CreateFileMapping.

Any suggestion are highly welcome.

Re: Shared memory issue between driver and application by Maxim

Maxim
Tue Jun 22 10:28:02 CDT 2004

What you do will not work. Specifying the allocation tag as a parameter to
OpenFileMapping is the same as specifying the file name for a registry key :-)
if not worse.

A much better way is to:

- allocate the memory in the app
- pass it to the driver in an IOCTL
- pend this IOCTL till MJ_CLEANUP will arrive for this file.

The driver will have MmGetSystemAddressForMdlSafe(Irp->MdlAddress) to
access the area.

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


"JackSu" <su_yu@yahoo.com> wrote in message
news:8e35816c.0406220717.468e7f02@posting.google.com...
> Hi all,
>
> I am newbie for driver programming.
>
> I created a shared memory in driver program using
> ExAllocatePoolWithTag,
> the last parameter is the address a string "ADDR".
>
> Then I tried to access that shared memory from one application using
> OpenFileMapping with lpName "ADDR".
>
> It failed, shows no access to that memory. Then I changed the
> parameter in OpenFileMapping to a random bad name, I got the same
> error.
>
> That program can work with shared memory which created using
> CreateFileMapping.
>
> Any suggestion are highly welcome.



Re: Shared memory issue between driver and application by Don

Don
Tue Jun 22 10:28:54 CDT 2004

ExAllocatePoolWithTag has nothing to do with mapping memory to user space.
The tag is there so that you can monitor a drivers allocations and deletions
(and with ExFreePoolWithTag validate them).

What are you trying to achieve, application/driver communication with shared
memory has many problems and is very hard to get right. Explain what your
driver and app are supposed to do, and this group can probably suggest a
solution.

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

"JackSu" <su_yu@yahoo.com> wrote in message
news:8e35816c.0406220717.468e7f02@posting.google.com...
> Hi all,
>
> I am newbie for driver programming.
>
> I created a shared memory in driver program using
> ExAllocatePoolWithTag,
> the last parameter is the address a string "ADDR".
>
> Then I tried to access that shared memory from one application using
> OpenFileMapping with lpName "ADDR".
>
> It failed, shows no access to that memory. Then I changed the
> parameter in OpenFileMapping to a random bad name, I got the same
> error.
>
> That program can work with shared memory which created using
> CreateFileMapping.
>
> Any suggestion are highly welcome.



Re: Shared memory issue between driver and application by su_yu

su_yu
Tue Jun 22 18:09:29 CDT 2004

Thanks a lot. Could you please send me some sample code on what you
suggested?

I am not sure how to "pass it to the driver in an IOCTL" and "pend
this IOCTL till MJ_CLEANUP will arrive for this file."

Thanks in advance.

Jack
>

"Maxim S. Shatskih" <maxim@storagecraft.com> wrote in message news:<ePuUE0GWEHA.716@TK2MSFTNGP11.phx.gbl>...
> What you do will not work. Specifying the allocation tag as a parameter to
> OpenFileMapping is the same as specifying the file name for a registry key :-)
> if not worse.
>
> A much better way is to:
>
> - allocate the memory in the app
> - pass it to the driver in an IOCTL
> - pend this IOCTL till MJ_CLEANUP will arrive for this file.
>
> The driver will have MmGetSystemAddressForMdlSafe(Irp->MdlAddress) to
> access the area.
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com
>
>
> "JackSu" <su_yu@yahoo.com> wrote in message
> news:8e35816c.0406220717.468e7f02@posting.google.com...
> > Hi all,
> >
> > I am newbie for driver programming.
> >
> > I created a shared memory in driver program using
> > ExAllocatePoolWithTag,
> > the last parameter is the address a string "ADDR".
> >
> > Then I tried to access that shared memory from one application using
> > OpenFileMapping with lpName "ADDR".
> >
> > It failed, shows no access to that memory. Then I changed the
> > parameter in OpenFileMapping to a random bad name, I got the same
> > error.
> >
> > That program can work with shared memory which created using
> > CreateFileMapping.
> >
> > Any suggestion are highly welcome.