I use the MmMapIoSpace - Method from MSDN Art.Q189327 to map physical
memory (PC Card) into the address space of an application.
Works fine, the application can access the memory.
But as soon as the application terminates, I am looking at a nice blue
screen...
This is how I map the memory:
pMyMDL = IoAllocateMdl(
MySystemVirtualAddress,
MyMemorySize,
FALSE,
FALSE,
NULL
);
if (pMyMDL) {
MmBuildMdlForNonPagedPool(pMyMDL);
pUser = (PVOID) (((ULONG)PAGE_ALIGN(MmMapLockedPages(pMyMDL,
UserMode)))
+ MmGetMdlByteOffset(pMyMDL));
}
And this is how I try to unmap:
MmUnlockPages(pExt->pMdl);
IoFreeMdl(pExt->pMdl );
There is no difference if I do the unmapping or not.
Some ideas what I am missing?
I hope I'm only to dumb to read the documentation :-)
hopefully,
T.Wagner
Please make sure you are unmapping (MmUnmapIoSpace) the address in the
same process context in which you mapped. Also make sure your MDL is
not corrupted.
-Eliyas
Sent via Deja.com http://www.deja.com/
Before you buy.
>Please make sure you are unmapping (MmUnmapIoSpace) the address in the
>same process context in which you mapped. Also make sure your MDL is
>not corrupted.
No, that is not required. MmUnMapIoSpace deconstructs only the
system-space addresses and can be done in any thread or process context.
The REAL problem is that he's using MmUnlockPages when what he really
wants is MmUnmapLockedPages. (These pages don't have to be "unlocked"
because they were never "locked".)
The MmUnlock... DOES have to be done in the context of the requesting
process. Perhaps that's what you were thinking of.
(I answered this earlier today, in the parallel thread in
microsoft.public.win32.programmer.kernel . I sure wish people would keep
the driver questions to this newsgroup, or at the very least, learn to
crosspost instead of multipost!)
--- Jamie Hanrahan, Kernel Mode Systems, San Diego CA
Windows NT/2000 driver consulting and training
http://www.kernel-mode.com/
Please post replies, followups, questions, etc., in news, not via e-mail.