I’m trying to share memory between applications for memory allocated in my driver.
I allocate and map the buffer using these steps(roughly):
MmAllocateContiguousMemory
MmGetPhysicalAddress
IoAllocateMdl
MmBuildMdlForNonPagedPool
PAGE_ALIGN(MmMapLockedPagesSpecifyCache(devCtx->AddOnMdl, UserMode, MmNonCached, NULL, FALSE, NormalPagePriority))) + MmGetMdlByteOffset(devCtx->AddOnMdl)));
It works great but I’d like to be able to open another handle to the driver and access the same memory if possible. I tried using the virtual address I use in the first host application but that fails. I assume the second application doesn’t see the virtual address the same way. Is there a way to share this memory across the applications? The values used to set up the driver/host shared region are all saved in the devctx so I can’t tell where the sharing ends in a new application. I don’t see what I could use to connect my new application to this same memory.
> I’m trying to share memory between applications for memory allocated in my driver. > > I allocate and map the buffer using these steps(roughly): > MmAllocateContiguousMemory > MmGetPhysicalAddress > IoAllocateMdl > MmBuildMdlForNonPagedPool > PAGE_ALIGN(MmMapLockedPagesSpecifyCache(devCtx->AddOnMdl, UserMode, MmNonCached, NULL, FALSE, NormalPagePriority))) + MmGetMdlByteOffset(devCtx->AddOnMdl))); > > It works great but I’d like to be able to open another handle to the driver and access the same memory if possible. I tried using the virtual address I use in the first host application but that fails. I assume the second application doesn’t see the virtual address the same way. Is there a way to share this memory across the applications? The values used to set up the driver/host shared region are all saved in the devctx so I can’t tell where the sharing ends in a new application. I don’t see what I could use to connect my new application to this same memory.
These pages are already locked, so all you need to do is call MmMapLockedPagesSpecifyCache again.
You also shouldn’t need MmGetPhysicalAddress in the list of steps below.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Wednesday, March 21, 2012 4:03 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] MmAllocateContiguousMemory sharing
You should be able to lock the pages again for the new process.
> I’m trying to share memory between applications for memory allocated in my driver. > > I allocate and map the buffer using these steps(roughly): > MmAllocateContiguousMemory > MmGetPhysicalAddress > IoAllocateMdl > MmBuildMdlForNonPagedPool > PAGE_ALIGN(MmMapLockedPagesSpecifyCache(devCtx->AddOnMdl, UserMode, > MmNonCached, NULL, FALSE, NormalPagePriority))) + > MmGetMdlByteOffset(devCtx->AddOnMdl))); > > It works great but I’d like to be able to open another handle to the driver and access the same memory if possible. I tried using the virtual address I use in the first host application but that fails. I assume the second application doesn’t see the virtual address the same way. Is there a way to share this memory across the applications? The values used to set up the driver/host shared region are all saved in the devctx so I can’t tell where the sharing ends in a new application. I don’t see what I could use to connect my new application to this same memory.