Re: WDM driver and services by Amit
Amit
Wed Oct 13 17:35:27 CDT 2004
"Max Paklin" wrote:
> >> > How would this be done ? Just implementing a pending IRP wont do as
> >> > there
> >> > are no IRP's, but SRB's and the WMD streaming driver would only
> >> > interact
> >> > with
> >> > the Stream Class driver.
> >
> > Oh, I do realize that every SRB will be associated with an underlying IRP.
> > I
> > was just saying the usual method wont work, but as you pointed out it
> > seems
> > Stream Class has a corresponding way to do it.
> >
> > Btw, is that the same between a stream class and avstream drivers ? I want
> > to take that into account now so that I dont have t worry about it later.
>
> Yes and no.
> AVStream operates with IRPs (mostly) so what you usually do with AVStream is
> you return STATUS_PENDING from your dispatch entry point and AVStream -
> supposedly - pends the IRP.
Interesting, which probably explains why the Get/SetHandler works only on
avstream and not stream class minidrivers as get/sethandlers expect an IRP,
while there stream class deals with SRB's.
> I've never done it myself, but according to the DDK it is supposed to work.
>
> There are a number of exception to this rule and one of those is that you
> can't return STATUS_PENDING from pin state transition callback. I don't know
> why and the DDK doesn't elaborate on that. Moreover state transition
> callback doesn't receive an IRP so there appears to be no way the state
> transition can be delayed unless you want to block in the dispatch entry
> point, which can be bad as you have to assume that you might be running in
> abitrary context.
>
>
>
> >> There are IRPs. They are wrapped by SRBs and that's what your minidriver
> >> deals with, however underneath is still good old IRP (it's even present
> >> as
> >> one of the fields in SRB, OriginalIrp or something like that).
> >
> > Oh ok, but we still shouldnt deal with irp's right in the minidriver?
>
> Normally you shouldn't. However there are case when you have to. One of
> those is minidriver receiving an IRP that class driver doesn't handle. In
> that cast the class driver hands it the minidriver wrapped into "unknown"
> SRB. For example, WMI IRPs would work that way unless you hook driver object
> dispatch table.
>
>
> > So what you are saying is basically do Async I/O using DeviceIocontrol and
> > send an Overlapped pointer that will contain the event ? and wait for the
> > Object..
> > and only when the driver finishes the SRB, the stream class(and I/O
> > manager)
> > would handle the rest of notifying back to the app to get out of the Wait
> > ?
>
> You can do synchronous I/O if you don't mind blocking.
> It's your call.
Well, all my service is going to do ir provide Video data to the driver
every now and then. So, until the driver doesnt say that it needs more data,
maybe the service doesnt have to do anything more..
so this is what I am thinking....
while(1) ///of course I am checking for the stop video data event too...
{
DeviceI/o( or a Set Property or a KsysyncDeviceControl)
if(err_pending)
data = WaitForMultipleObjects
if(data == MoreData Event)
resetevent
else
break;
}
this is some algorithm of what I am thinking of doing.....
so which goes back to my earlier question...that assuming I return Pending
from my minidriver for the custom property, and assuming at some time later,
I complete the SRB..would the stream class( and I/O manager) return correctly
to the service app to make things work as I have stated above ?
Thanks.
>
> > The reason I am asking this is because this is a service and not just a
> > regular app. So, I would have opened the pipe for listening. But maybe
> > thats
> > not required and just a DeviceIocontrol would suffice within a while loop
> > tat
> > keeps running.
>
> I don't see a difference between a service and an application in this
> context, but maybe I miss something.
> I'd create a dedicate thread a do a blocking call to a driver from that
> thread.
>
> -- Max.
>
>
>