I need to access a block of memory allocated in driver and passed that
memory into application for read/write. (for large data transfers). I
am using AllocPhysMem to allocate virtual and physical memory. But I
want to map this to user Space (i.e., application side). I used the
following steps to map memory which is allocated by driver to
application side.
=============================================================
(1) VirAddress = (LPVOID)AllocPhysMem(pAllocateNonPagedPool-
>ulNumOfBytes,
PAGE_READWRITE|PAGE_NOCACHE,
0,
0,
&PhyAddress.LowPart);
(2)virtAddrTmp = MmMapIoSpace(PhyAddress,pAllocateNonPagedPool-
>ulNumOfBytes,FALSE);
(3)PhysAddressToUsrSpace = VirtualAllocCopyEx(
(HANDLE)GetDirectCallerProcessId(),
GetCurrentProcess(),
virtAddrTmp,
pAllocateNonPagedPool->ulNumOfBytes,
PAGE_READWRITE);
pAllocateNonPagedPool->pBuffer = (VOID * POINTER_32)
PhysAddressToUsrSpace;
(4)//map the virt address to user space
VirtAddressToUsrSpace = VirtualAllocCopyEx(
(HANDLE)GetDirectCallerProcessId(),
GetCurrentProcess(),
(LPVOID)VirAddress,
pAllocateNonPagedPool->ulNumOfBytes,
PAGE_READWRITE);
===============================================================
Finally, I passed VirtAddressTo UsrSpace (virtual Memory) and
PhysAddressToUsrSpace ( Physical Memory) to User Space (for
Application read/write access).
AllocPhysMem,MmMapIoSpace,VirtualAllocCopyEx在wince6.0中的应用
最新推荐文章于 2012-07-15 20:46:19 发布