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?
Q3. If a memory is allcated from nonpaged pool, do I still call
MmProbeAndLockPages and then call MmMapLockedPages to map a system space VA
to user space VA? or directly call MmMapLockedPages to map?
Q4.
In MSND, it says
VOID
MmProbeAndLockPages(
IN OUT PMDL MemoryDescriptorList,
IN KPROCESSOR_MODE AccessMode,
IN LOCK_OPERATION Operation
);
Operation
Specifies the type of operation for which the caller wants the access rights
probed and the pages locked, one of IoReadAccess, IoWriteAccess, or
IoModifyAccess.
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?
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.
I recommend testing this driver after "verifier.exe /standard /driver
mydriver.sys" on Windows Vista. Verifier will check all of these rules for
these API calls and will complain in case they are incorrect/wasteful.
http://msdn.microsoft.com/en-us/library/ms792871.aspx has information about
this.
Dan
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Pavel Lebedinsky [MSFT]" <pa...@online.microsoft.com> wrote in message
news:uaYoSIG0...@TK2MSFTNGP05.phx.gbl...
are they correct? (Some params are omitted.)
Yes this should work. You don't need MmProbeAndLockPages here,
MmBuildMdlForNonPagedPool should be enough.
Note that MmAllocateContiguousMemory call can be very expensive,
and may not work at all for larger sizes (more than a few pages) once
physical memory gets fragmented. Do you really need this memory
to be physically contiguous?
"Danial.F" <Dan...@discussions.microsoft.com> wrote in message
news:9D9C6B13-EDAC-4863...@microsoft.com...