Previously there was a shmemMap member inside the DEVICE_CONTEXT which effectively restricted the mapping to a single process only. I've moved that pointer (that holds the virtual address of the mapping in the usermode process) to a new FILE_CONTEXT struct. For each CreateFile call in usermode, a WDFFILEOBJECT is created in the kernel. The WDFDEVICEEvtDeviceFileCreate callback then allocates the file context in the file object.
When a usermode application requests a map via ioctl, we extract the file object (and then file context) from the WDFREQUEST. Instead of updating the shmemMap member in the device context (this was before this pull request), now we update that address in the file context, which is unique to each handle to the driver.
With these changes, one or more applications can map the same memory into their virtual address space. One application could even map the region twice, but only from two driver handles (two calls to CreateFile).
Previously there was a
shmemMap
member inside theDEVICE_CONTEXT
which effectively restricted the mapping to a single process only. I've moved that pointer (that holds the virtual address of the mapping in the usermode process) to a newFILE_CONTEXT
struct. For eachCreateFile
call in usermode, aWDFFILEOBJECT
is created in the kernel. TheWDFDEVICE
EvtDeviceFileCreate
callback then allocates the file context in the file object.When a usermode application requests a map via ioctl, we extract the file object (and then file context) from the
WDFREQUEST
. Instead of updating theshmemMap
member in the device context (this was before this pull request), now we update that address in the file context, which is unique to each handle to the driver.With these changes, one or more applications can map the same memory into their virtual address space. One application could even map the region twice, but only from two driver handles (two calls to
CreateFile
).