I want to make an IOCTL call between 2 avstream drivers that support
property sets.

I am using IoGetDeviceInterfaces to get the interfaces and then I do a
IoGetDeviceObjectPointer to get the device object.

Following that when I need to make the IOCTL, I use
IoBuildDeviceIoControlRequest to set the IRP and then I am trying to
use IoCallDriver but it returns back with an error.

Here is how I am setting the StackLocation...

What I need to send is 1>KSPROPERTY and 2>ULONG(which contains data)

pIrp = IoBuildDeviceIoControlRequest(
ulIoctl,
pFilter->pDevObject,
pData,
ulpData,
pcbData,
ulcbData,
TRUE,
NULL,
&IoStatusBlock);

//ulpdata points to a KSPROPERTY structure...pcbdata is size of
//KSPROPERTY... pcbdata points to a ULONG, ulcbdata is SIZE of ULONG.

if (pIrp != NULL)
{
PIO_STACK_LOCATION pNextStackLocation;

pNextStackLocation = IoGetNextIrpStackLocation(pIrp);
if (pNextStackLocation)
{
pNextStackLocation->FileObject = pFilter->pFiObject;
pNextStackLocation->MajorFunction = IRP_MJ_DEVICE_CONTROL;
pNextStackLocation->Parameters.DeviceIoControl.IoControlCode =
IOCTL_KS_PROPERTY;

IoStatusBlock.Status = STATUS_SUCCESS;

ntStatus = IoCallDriver( pFilter->pDevObject, pIrp);

Is there anything wrong in what I am doing ? Do I need to set
additional parameters in PIO_STACK_LOCATION ? as to what data needs to
go through ( like size of KSPROPERTY or ULONG) ?

Thanks.

Re: Making IOCTL calls between 2 avstream drivers. by Max

Max
Thu Sep 08 18:12:02 CDT 2005

Generally speaking it should work just fine.
What's the error code that you are getting?
In your call to IoBuildDeviceIoControlRequest what is ulIoctl? What is
pFilter->pDevObject?
How did you declare the support for the IOCTL is the driver that you are
calling?

-- Max.



<amparikh@gmail.com> wrote in message
news:1126114894.482912.157720@f14g2000cwb.googlegroups.com...
>I want to make an IOCTL call between 2 avstream drivers that support
> property sets.
>
> I am using IoGetDeviceInterfaces to get the interfaces and then I do a
> IoGetDeviceObjectPointer to get the device object.
>
> Following that when I need to make the IOCTL, I use
> IoBuildDeviceIoControlRequest to set the IRP and then I am trying to
> use IoCallDriver but it returns back with an error.
>
> Here is how I am setting the StackLocation...
>
> What I need to send is 1>KSPROPERTY and 2>ULONG(which contains data)
>
> pIrp = IoBuildDeviceIoControlRequest(
> ulIoctl,
> pFilter->pDevObject,
> pData,
> ulpData,
> pcbData,
> ulcbData,
> TRUE,
> NULL,
> &IoStatusBlock);
>
> //ulpdata points to a KSPROPERTY structure...pcbdata is size of
> //KSPROPERTY... pcbdata points to a ULONG, ulcbdata is SIZE of ULONG.
>
> if (pIrp != NULL)
> {
> PIO_STACK_LOCATION pNextStackLocation;
>
> pNextStackLocation = IoGetNextIrpStackLocation(pIrp);
> if (pNextStackLocation)
> {
> pNextStackLocation->FileObject = pFilter->pFiObject;
> pNextStackLocation->MajorFunction = IRP_MJ_DEVICE_CONTROL;
> pNextStackLocation->Parameters.DeviceIoControl.IoControlCode =
> IOCTL_KS_PROPERTY;
>
> IoStatusBlock.Status = STATUS_SUCCESS;
>
> ntStatus = IoCallDriver( pFilter->pDevObject, pIrp);
>
> Is there anything wrong in what I am doing ? Do I need to set
> additional parameters in PIO_STACK_LOCATION ? as to what data needs to
> go through ( like size of KSPROPERTY or ULONG) ?
>
> Thanks.
>



Re: Making IOCTL calls between 2 avstream drivers. by amparikh

amparikh
Thu Sep 08 19:27:22 CDT 2005

Generally speaking it should work just fine.
What's the error code that you are getting?

I am getting STATUS_INVALID_REQUEST.

In your call to IoBuildDeviceIoControlRequest what is ulIoctl? What is
pFilter->pDevObject?
>> ulIoctl is IOCTL_KS_PROPERTY and pDevObject is the device Object that I get after doing a OBReference on device object I get from IoGetDeviceObjectPointer.

How did you declare the support for the IOCTL is the driver that you
are
calling?
I am not quite sure what you are asking here, but it is one of the
standard BDA properties that the avtream driver is supporting
(KSPROPERTY_BDA_RF_TUNER_FREQUENCY).


Re: Making IOCTL calls between 2 avstream drivers. by Max

Max
Fri Sep 09 18:52:38 CDT 2005

KS devices don't really implement properties.
Properties are attached to either a pin or a filter, so I am guessing here
that you might need to stuff your IRP with the target file object.

When making call from the user land you would normally use a filter or one
of its pins as an adressee for the call. Filters and pins have file handles
associated with them.

Put a breakpoint on one of those property handlers of yours and see when the
call arrives from KS how the IRP is setup.

How to find a file handle from the kernel mode? Don't know. Armed with the
device object you sure can get KS device by using
KsGetDeviceFromDeviceObject. From that point it is possible to enumerate
filter factories, filters and pins. However I can't think of a way to get
existing file object from KS pin or filter.

If the second driver is written by you, it is possible to call it directly
by standardizing pin or filter extesion and devising some API around it.

You also might want to consider doing an inverted call to the user mode and
invoking your buddy driver from there.

-- Max.


<amparikh@gmail.com> wrote in message
news:1126225642.806184.254380@g43g2000cwa.googlegroups.com...
> Generally speaking it should work just fine.
> What's the error code that you are getting?
>
> I am getting STATUS_INVALID_REQUEST.
>
> In your call to IoBuildDeviceIoControlRequest what is ulIoctl? What is
> pFilter->pDevObject?
>>> ulIoctl is IOCTL_KS_PROPERTY and pDevObject is the device Object that I
>>> get after doing a OBReference on device object I get from
>>> IoGetDeviceObjectPointer.
>
> How did you declare the support for the IOCTL is the driver that you
> are
> calling?
> I am not quite sure what you are asking here, but it is one of the
> standard BDA properties that the avtream driver is supporting
> (KSPROPERTY_BDA_RF_TUNER_FREQUENCY).
>