Hi Don
I simply pass (an array of) user mode pointers in using METHOD_BUFFERED.
Once a (user mode) pointer is in my driver I allocate an MDL to describe it,
do a
MmProbeAndLockPages(pMdl, KernelMode, IoModifyAccess);
to fix it in memory, obtain a kernel mode pointer with
MmGetSystemAddressForMdlSafe(pMdl, HighPagePriority);
and store all these pointers in the device extension.
Then real time interrupt callbacks write data to the buffer(s) pointed to,
ad infinitum (or until I tell the driver to stop).
I’m still getting my head around IRPs but I’d assume that all are complete
at the time this is running, as all my calls are non-overlapped, simply
passing in control values, pointers etc.
I assume that when the user process terminates for any reason, XP notifies
the driver that it’s handle is (being) closed. If I can unlock the memory in
time I’d be okay, but I’m not sure how to do that at the moment…
Thanks for any comments
Mike
----- Original Message -----
From: Don Burn
Newsgroups: ntdev
To: Windows System Software Devs Interest List
Sent: Tuesday, May 30, 2006 4:55 PM
Subject: Re:[ntdev] driver writing back to user space
How are you getting the pointers into memory in the first place? If you are
using a bunch of IRP’s to pass in buffers with something like
METHOD_OUT_DIRECT you will recieve a cancel for the IRP before the process
fully cleans up, and you can cleanup your usage of the buffers.
Note: this is one of the reasons for avoiding tricks like events, since the
handling of process termination is much harder.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
“Mike Kemp” wrote in message news:xxxxx@ntdev…
> Hi from a new member / new to device drivers.
>
> I’m implementing a driver that writes real time data back to my
> application buffers as fast as possible. It’s working okay, using
> necessary probe and lock to fix the buffers in RAM and to write to them.
>
> I’m worried if it is / can be made safe against the user process
> terminating abnormally - if it goes away before it can stop the driver I’m
> going to get a bug check DRIVER_LEFT_LOCKED_PAGES_IN_PROCESS. Fine if
> everything runs properly and nothing shuts down my user mode app before I
> can switch off the driver, but is there any way of guaranteeing this?
>
> There are a couple of reasons including performance issues why I don’t
> want to move the buffers wholly into the kernel and rely on signalling
> events for the app to read the data - but I suppose it would be a plan B
> if all else fails.
>
> If an experienced driver writer can tell me to stop and go to plan B
> immediately I’d appreciate the tip!
>
> Thanks in advance
>
> Mike
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer