Sharing memory mappings across processes at a fixed address

Hi,

I’m looking for an elegant way to share a memory region that has been
allocated in kernel-mode across processes at a fixed (the same) address in
each process. As an illustration, say that I’ve allocated a memory region
in kernel-mode that holds some arbitrary information that is a single page
in size. I want that memory region to be mapped into the address space of
each process at address 0x20000000 (as an example) as copy-on-write. This
would allow me to share that memory region (and thus reduce memory
consumption across processes) for that single page, but in the event that
the process were to update it, copy-on-write would occur. The time at which
this memory region is mapped into the process’ address space is not relevant
to this particular point in the discussion.

So, to summarize, I would basically like to emulate shared memory against a
kernel-mode allocated memory region. It seems like my best choice would be
to use a pagefile-backed section and use ZwMapViewOfSection to map it into
the address space of the process with PAGE_WRITECOPY. I’m mainly curious to
see what everyone’s opinion is on whether or not the pagefile-backed section
mapping is a good idea, or, whether or not there is a better idea. My
reason for doing this is that I have a relatively large memory region (over
16 pages) that needs to be mapped into the address space of each process at
a specific address. If I were not to share these mappings, memory
consumption would be much too huge (16 * n pages where n is the number of
processes). Sharing them with copy-on-write greatly reduces the memory
consumption.

Matt

PS: Don’t worry about the fact that the memory region may already be
occupied in the process prior to attempting to map the region. This is not
a point for concern in this particular portion of the discussion.