hi all,
'am writing a Win2k Kernel driver.
I need to allocate a chunk of mem in kernel( my driver) & map it to user
space frquently…
The way I do it presently is I send a ioctl call(deviceiocontrol) to my
driver in which I call mmprobeandlockpages() followed by
mmmaplockedpages()
& before returning I call mmunlockpages()(NOT in IRP_MJ_CLEANUP) is that a
proper sequence first of all or do i need to call mmunlockpages()
compulsarily in IRP_MJ_CLEANUP ???
Moreover is ioctl a only way for doing this communication… or do we have
any explicit call (like mmap() call in LINUX) ???
Any additional information is welcome…
Kindly help me out…
Thanx,
SP.
> & before returning I call mmunlockpages()(NOT in IRP_MJ_CLEANUP) is that a
proper sequence first of all or do i need to call mmunlockpages()
compulsarily in IRP_MJ_CLEANUP ???
Yes. Otherwise, the malicious app or just your app in case of crash will BSOD.
Moreover is ioctl a only way for doing this communication… or do we have
any explicit call (like mmap() call in LINUX) ???
No, MapViewOfFile will map only filesystem files or \Device\PhysicalMemory (admin only), not any device memory.
To map device addresses to user, use either \Device\PhysicalMemory or MmMapLockedPages(…UserMode…). Some IOCTL must be invented
instead of mmap().
Max
hi ,
thanx…
second part of ur reply is fine…
could u kindly elaborate on first part…
I mean, what’s wrong if I call call mmunlockpages() immediately after I
get user virtual addr from mmmaplockedpages() why is it mandatory to wait
till i get IRP_MJ_CLEANUP…
thanx once again
SP.
This is because MmMapLockedPages does not increment the reference count on pages.
In this case, MmUnlockPages (mapped pages) will free them for reuse by MM, and the mapping will contain pages which are already used
for other purpose.
Max
----- Original Message -----
From: “Shailesh”
To: “NT Developers Interest List”
Sent: Tuesday, May 14, 2002 11:47 PM
Subject: [ntdev] Re: mapping kernel mem to user space => WITHOUT using Ioctl !!!
> hi ,
> thanx…
>
> second part of ur reply is fine…
>
> could u kindly elaborate on first part…
> I mean, what’s wrong if I call call mmunlockpages() immediately after I
> get user virtual addr from mmmaplockedpages() why is it mandatory to wait
> till i get IRP_MJ_CLEANUP…
>
> thanx once again
>
> SP.
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>
hi,
…ya that’s fine…but once i get a user virtual addr with
mmMaplockedpages() & later if the page is reused by MM, user should get a
page fault while trying to access the page, & page faults at user level
should i suppose not result in BSOD. so how should that matter ???
& how if i call mmunlockpages() in IRP_MJ_CLEANUP: => how is ref count
incremented till that point ???
really it’s not very clear…
moreover… if u feel i’am bugging u plz let me know some online doc… etc
which clearly explains this…
thanx a lot…
SP.