Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MmMapLockedPages with UserMode pointer #2

49 views
Skip to first unread message

Gunter

unread,
Apr 20, 2009, 6:50:01 PM4/20/09
to
Hi everybody,

sorry for opening yet another thread on user mode / kernel mode memory
management, I posted some related questions earlier, thanks to Pavel
Lebedinsky, Maxim S. Shatskih and Tim Roberts for answering most questions,
but one has remained unanswered.
In

NTKERNELAPI PVOID
MmMapLockedPagesSpecifyCache(
IN PMDL MemoryDescriptorList,
IN KPROCESSOR_MODE AccessMode,
IN MEMORY_CACHING_TYPE CacheType,
IN PVOID BaseAddress,
IN ULONG BugCheckOnFailure,
IN MM_PAGE_PRIORITY Priority
);

what is the purpose of the IN PVOID BaseAddress parameter?

The docs say:

BaseAddress
If AccessMode = UserMode, this parameter specifies the starting user
address to map the MDL to, or NULL to allow the system to choose the starting
address.

What is the intended use of this parameter? When would I supply this
parameter, how would I obtain it, and how would I pass it to the kernel?
Or is there some unwritten law that anything else but NULL is illegal?

I tried to supply a base address in different ways while using
AccessMode = UserMode, but the kernel threw an exception all the time.

Any help?
Thx a lot

Don Burn

unread,
Apr 20, 2009, 7:08:11 PM4/20/09
to
Use NULL and the system will return the address to you that it choose. The
address is like MapViewOfFile where you can optionally specify a given
address which is known to be safe. Take a look at
http://www.osronline.com/article.cfm?article=39 for a good article on how to
do what you are looking for.


--
Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply


"Gunter" <Gun...@discussions.microsoft.com> wrote in message
news:E16DC18F-C6D4-4E03...@microsoft.com...

> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4023 (20090420) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4023 (20090420) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


Gunter

unread,
Apr 21, 2009, 6:06:19 PM4/21/09
to

Don,

thanks very much for your answer. I have read through the article you
pointed me to.
Unfortunately, the example discussed there also uses NULL as BaseAddress,
so it actually doesn't answer my question.

(Allow me to mention that I know how to use MmMapLockedPagesSpecifyCache
with a system-provided base address, my current driver works that way, but
this not want I want to do, for different reasons).

So, allow me to ask you (or anybody else in the driver community): can
someone point me to an article/example/source code where the parameter
BaseAddress in MmMapLockedPagesSpecifyCache is *not NULL*?

Thanks very much

Tim Roberts

unread,
Apr 23, 2009, 1:40:30 AM4/23/09
to
Gunter <Gun...@discussions.microsoft.com> wrote:
>
>So, allow me to ask you (or anybody else in the driver community): can
>someone point me to an article/example/source code where the parameter
>BaseAddress in MmMapLockedPagesSpecifyCache is *not NULL*?

Does it really take an example for you to understand what this is supposed
to do? Consider, for example, a poorly designed interface DLL that needs
to have the device mapped in to the same address in multiple processes.
That's a case where you might use this.

You also might have a chunk of address space that a user-mode process
allocated (but didn't commit) by VirtualAlloc. That would be another case.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

0 new messages