Re: Cross Process Callbacks



If you have the help of a wrapper API in the application space, you can use
synchronization objects, like events, to handle notification of a 'callback'
that it's time to run. Getting data to it is still a problem, but you could
handle that with a point-to-point message queue, shared memory
(memory-mapped file, without the file), etc. The wrapper API, when the
application calls a function, CallMeBackWithData( Callback fcn, DWORD
extraparams ), say, would launch a thread:

thread()
{
event = CreateEvent()

DeviceIoControl( driver, set up callback, event )

WaitForSingleObject( event )

// call the application's specified call-back function, grabbing data
sent by the driver from whereever it belongs
}

Paul T.

"Silver" <thesilverring@hot> wrote in message
news:uBJRZ3QrGHA.2052@xxxxxxxxxxxxxxxxxxxxxxx
Hi all,
I want to make a callback from a driver in the context of device.exe to an
application in userland. Actually, that's a lie, I want to do it
differently but I am getting pushback for other reasons.

My scenario is like this:

Application -> registers callback via stream driver IOCTL
Driver -> allocates buffers and handles reading data from device

..
..


Driver -> Data arrives at driver and is put in a buffer in created in
device.exe context.
Driver -> Driver makes callback to userland application with the data
mapped to application user space.

Application -> processes data and returns

Driver -> handles buffer cleanup and continues in device.exe context


The first problem is mapping the data buffer, MapPtrToProcess is
deprecated and MapCallerPtr would not work as it is not a PSL call and I
want to avoid a buffer copy. The best way I could come up with was
ReadProcessMemory, this is a trusted API though so I may have problems
there too.

Next, how do I make a function call in the context of a different process
space? I could use a thread in the application space that simply waits for
an event and do it that way (like an IST) but I am racking my brains to
figure out another way - does anybody have any ideas?

BTW: This is under CE5.0, to be used on WM5.



Geoff
--


.



Relevant Pages

  • [PATCH 1/5] call i2c_probe from i2c core
    ... If you want to write a `sensors' driver, ... Whenever a new adapter is inserted, or for all adapters if the driver is ... the callback attach_adapteris called. ... -contains -1 for a probed detection, 0 for a forced detection, or a positive ...
    (Linux-Kernel)
  • Re: Delay inside a worker thread
    ... Create invisible windows and use PostMessage to communicate between the threads ... >>hardware interupt which is signalled to your callback function in real ... >>by the device driver, you should simply have to call an API with an On Off ... >>the operation has completed with a callback. ...
    (microsoft.public.vc.mfc)
  • Re: Thread in driver
    ... And the driver is able to do the callback ... whenever there is an interrupt. ... This kind of solution will work only if your callback is inside ... If you need to implement such a mechanism, use a named event and set ...
    (microsoft.public.windowsce.platbuilder)
  • Re: VFW Streaming Transfer under WME
    ... list, fill them with capture data, and complete by the callback. ... > user-mode only Video Capture Driver. ... so suppose client will supply the buffer ... > times, then my driver fill the buffer and callback, and this repeat. ...
    (microsoft.public.development.device.drivers)
  • Cross Process Callbacks
    ... I want to make a callback from a driver in the context of device.exe to an application in userland. ... Driver -> Data arrives at driver and is put in a buffer in created in device.exe context. ...
    (microsoft.public.windowsce.platbuilder)