Shared memory between kernel driver and multiple processes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi all,

I would like to allocate memory from a kernel driver (not necessarily
at driver load time) and arbitrarily map the memory to client
application processes. The memory must be readable and writable from
all processes that it's mapped to as well being accessible within the
kernel driver.

I have an idea about possible solutions but would like to understand
better what's best practice / possible etc.

- Solution 1: for kernel driver:
AllocPhysMem() gives a CPU relative physical address + Kernel CPU
virtual
VirtualAllocEx/VirtualCopyEx reserves arbitrary space in client process
and maps the physical address range to it.

-> This solution seems workable but relies on physically contiguous
memory - issues beyond boot time.

- Solution 2: for kernel driver:
HeapCreate()/HeapAlloc() create a kernel heap and allocate kernel CPU
virtual addresses from it
Use VirtualAllocCopyEx() to re-map memory to processes.

-> This solution doesn't depend on physically contiguous memory but I
doubt it's valid for VirtualAllocCopyEx to operate on kernel heap
allocations?

- Solution 3: File Mapping:
CreateFileMapping() / MapViewOfFile - kernel driver manages
allocations in a File mapping
User application processes can access kernel allocations in the file
mapping and have read/write access
-> Doesn't rely on physically contiguous memory although is not an
'orthogonal' solution compared to the way this is achieved in other
OSs (e.g. Linux). To give some background, WinCE is one of many OS
supported in a generic Driver Porting Software framework.

Any Feedback or advice is welcome

Thanks,
Olivier

.



Relevant Pages

  • Re: A factoring algorithm
    ... >> is in the L1 cache by using performance monitoring counters, ... Just set them up to count memory ... > The WDMSR instruction can only be executed in the kernel as far as I ... You need a kernel driver. ...
    (sci.crypt)
  • Re: Shared memory between kernel driver and multiple processes
    ... I would like to allocate memory from a kernel driver (not necessarily ... Use VirtualAllocCopyEx() to re-map memory to processes. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Shared memory between kernel driver and multiple processes
    ... VirtualAllocCopyEx() doesn't have to be used with physical ... memory addresses. ... I would like to allocate memory from a kernel driver (not necessarily ...
    (microsoft.public.windowsce.platbuilder)
  • Re: [RFC 4/4] firewire: add mem1394
    ... 1394 is evil. ... we can still suck all its memory out over 1394 with no ... of adding another kernel driver for it though. ...
    (Linux-Kernel)