Kernel mode address to user mode

Is it possible to reference a kernel mode address in
an user mode application? For instance, if I create a
buffer in the kernel mode driver, then need to fill it
up from an user mode application, can I do it? I need
this in the following scenario: A win32 app requests
data from a device, and the device driver requests
data from another win32 app to fill the same buffer.
I understand that using buffered IO is an option. Is
there any other option available?

Thanks and regards
DK


Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

You can map the pages, using MmMapLockedPages(), specifying usermode as the
access. Beware of process context since it will map it into the process
context where you call the Mmxxx routine. If you are not in the process
context of the user process which will access the memory, this won’t work.
You can us the heavy handed routine KeStackAttachProcess() if you need.

Pete

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-166871-
xxxxx@lists.osr.com] On Behalf Of Dileep Kumar
Sent: Tuesday, February 10, 2004 10:00 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Kernel mode address to user mode

Is it possible to reference a kernel mode address in
an user mode application? For instance, if I create a
buffer in the kernel mode driver, then need to fill it
up from an user mode application, can I do it? I need
this in the following scenario: A win32 app requests
data from a device, and the device driver requests
data from another win32 app to fill the same buffer.
I understand that using buffered IO is an option. Is
there any other option available?

Thanks and regards
DK


Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@kerneldrivers.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can do it this way :

(application B allocates the buffer in usermode)

  1. application B waits on an user/kernelmode shared event (create event in
    usermode, send it to driver via IOCTL, obreferenceobject it to get the
    matching kernel event object from the handle)
  2. application A sends IOCTL to driver
  3. driver gets the request from A, and set the event to wake up application
    B
  4. application B fills the buffer and send IOCTL to the driver passing its
    address. Since driver is in B context now, it can access it without any
    problem.

Another approach yes, is to map the allocated kernel buffer, lock the pages
in memory and pass the virtual address to the usermode app in an IOCTL. But
beware of unlock the pages in your driverunload or you’ll get BSOD.

As far as KeAttach/DetachProcess,you’d need to know the EPROCESS so you must
be in process context.
The cleanest/safest solution is obviously the first one anyway…

Valerio

“Dileep Kumar” wrote in message news:xxxxx@ntfsd…
> Is it possible to reference a kernel mode address in
> an user mode application? For instance, if I create a
> buffer in the kernel mode driver, then need to fill it
> up from an user mode application, can I do it? I need
> this in the following scenario: A win32 app requests
> data from a device, and the device driver requests
> data from another win32 app to fill the same buffer.
> I understand that using buffered IO is an option. Is
> there any other option available?
>
> Thanks and regards
> DK
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Finance: Get your refund fast by filing online.
> http://taxes.yahoo.com/filing.html
>
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBQCmFdmGxr2U3nc5EEQKqxQCbBt7jOQXYvee6VPg4w+fjABQbP/UAnRyl
TL1/Ugcm+jgb0YRuNd6DR+Pv
=lV/P
-----END PGP SIGNATURE-----