Hi guys,

I wrote BDA driver. Everything works just fine. But now I need to comunicate
with it from user-level. I think that KS custom method mechanism will be
suitable for my needs because I just need to transfer data buffer from my
user-side application to this BDA driver.

So I do following in the app:

{
IKsControl* pIKsControl;

hr = CoCreateInstance(
CLSID_Proxy,
NULL,
CLSCTX_SERVER,
__uuidof(pIKsControl),
(LPVOID*)&pIKsControl);

//
// here hr is S_OK and pIKsControl is not NULL
//

KSMETHOD ksMethod =
{
KSMETHODSETID_SetGuid,
KSMETHOD_ITEM_Id,
KSMETHOD_TYPE_SEND
};

ULONG BytesReturned = 0;

hr = pIKsControl->KsMethod(
&ksMethod,
sizeof(ksMethod),
buffer, //buffer pointer
buffer_length, //buffer size
&BytesReturned);

//
// here hr is E_HANDLE; so some handle that is not valid
//
}

Of course, I implemented MethodSet in KSAUTOMATION_TABLE in the BDA
driver.

Please help to understand me where is the problem.

With best regards
---
Bye,
Sasha Bublyk

Re: BDA - using of KS custom method by Tim

Tim
Wed Aug 29 01:12:34 CDT 2007

"Sasha Bublyk" <sab@mastereye_DOT_kiev.ua> wrote:
>
>I wrote BDA driver. Everything works just fine. But now I need to comunicate
>with it from user-level. I think that KS custom method mechanism will be
>suitable for my needs because I just need to transfer data buffer from my
>user-side application to this BDA driver.
>
>So I do following in the app:
>
>{
> IKsControl* pIKsControl;
>
> hr = CoCreateInstance(
> CLSID_Proxy,
> NULL,
> CLSCTX_SERVER,
> __uuidof(pIKsControl),
> (LPVOID*)&pIKsControl);

No, this is not right. This creates a new instance of a generic proxy
object that is not related to your hardware. You need to connect to the
existing instance of your driver's proxy.

Are you doing this in the same app that is creating the graph? If so, you
just need to fetch the IBaseFilter object for your device, then use
QueryInterface to get the IKsControl interface from it, like:

CComQIPtr< IKsControl > pControl = pMyFilter;

If you are trying to talk to it from a different application, then it gets
a bit trickier. You can create a new instance of the filter using the
SetupDi interfaces and fetch the IKsControl from that, but you will need to
remember that it is a different instance than the one that's live.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: BDA - using of KS custom method by Sasha

Sasha
Wed Aug 29 05:05:32 CDT 2007

Hi Tim,

Thank you for the help.
I don't build the graph. Graph with my filter is built by another creature.
So I need to talk to the my filter from a different my application.
Do you think that second method will be optimal for me?

Thank you!
---
Bye,
Sasha Bublyk

>
> No, this is not right. This creates a new instance of a generic proxy
> object that is not related to your hardware. You need to connect to the
> existing instance of your driver's proxy.
>
> Are you doing this in the same app that is creating the graph? If so, you
> just need to fetch the IBaseFilter object for your device, then use
> QueryInterface to get the IKsControl interface from it, like:
>
> CComQIPtr< IKsControl > pControl = pMyFilter;
>
> If you are trying to talk to it from a different application, then it gets
> a bit trickier. You can create a new instance of the filter using the
> SetupDi interfaces and fetch the IKsControl from that, but you will need
> to
> remember that it is a different instance than the one that's live.
> --
> Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc.


Re: BDA - using of KS custom method by Tim

Tim
Thu Aug 30 21:05:59 PDT 2007

"Sasha Bublyk" <sab@mastereye_DOT_kiev.ua> wrote:
>
>I don't build the graph. Graph with my filter is built by another creature.
>So I need to talk to the my filter from a different my application.
>Do you think that second method will be optimal for me?

What kind of "communication" do you need to do? It might be easier, for
example, to use a ksproxy extension DLL. Such a DLL gets loaded every time
your driver is added to a graph, and because it is a user-mode component,
you have the flexibility to do something like a named pipe.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.