Re: Help!!! Memory allocation!!!
- From: Danial.F <DanialF@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 18 Jun 2008 09:19:00 -0700
So, if I do the following things,
pSystem = MmAllocateContiguousMemory (...); //1. the memory must be Nonpaged?
pMdl = IoAllocateMdl(pSystem...);
MmBuildMdlForNonPagedPool(pMdl); or MmProbeAndLockPages(pMdl)???
pUser = MmMapLockedPages(pMdl, UserMode...);// Map to user space address
are they correct? (Some params are omitted.)
"Pavel Lebedinsky [MSFT]" wrote:
.Q1. In MSDN, it says that MmAllocateContiguousMemory first attemps to
allocate a continuous range of memory from Nonpaged pool, if it fails,
then
allocates from unused pages. So, here, if it fails allcating from Nonpaged
pool and then successfully allocates the continuous range of memory, is
this
continuous range of memory still nonpaged or not?
It is.
Q2. MmBuildMdlForNonPagedPool, this routine receives an MDL that specifies
a
virtual memory buffer in nonpaged pool, and updates it to describe the
underlying physical pages. And the MDL virtual address that is input must
be
within the nonpaged portion of system space. So, here, if
MmAllocateContiguousMemory fails to allocate the continuous memory in
nonpaged pool but successfully allocates from unused pages, can I still
call
MmBuildMdlForNonPagedPool to build my MDL?
Yes.
Q3. If a memory is allcated from nonpaged pool, do I still call
MmProbeAndLockPages
Non-paged memory is already locked, there is no need to explicitly
lock it. MmProbeAndLockPages will actually assert on checked builds
if you give it an MDL with MDL_SOURCE_IS_NONPAGED_POOL
flag set.
If I want the access rights to be read, write and modify, how should I do?
Set the third parameter as IoReadAccess | IoWriteAccess | IoModifyAccess
or
otherwise?
Specify IoWriteAccess.
- Follow-Ups:
- Re: Help!!! Memory allocation!!!
- From: Pavel Lebedinsky [MSFT]
- Re: Help!!! Memory allocation!!!
- References:
- Re: Help!!! Memory allocation!!!
- From: Pavel Lebedinsky [MSFT]
- Re: Help!!! Memory allocation!!!
- Prev by Date: Re: And another one, this time in Usbser.sys on XP
- Next by Date: Re: Help!!! Memory allocation!!!
- Previous by thread: Re: Help!!! Memory allocation!!!
- Next by thread: Re: Help!!! Memory allocation!!!
- Index(es):
Relevant Pages
|