tags:

views:

54

answers:

1

How to iterate (infact access) the vtable of COM coclass(that will implement the methods of its exposed interfaces).?

Only I need to access vtable where all addresses of exposed methods of its interfaces are stored.

e.g Say

Math is COM object and its exposed interface is "Operations" and "Sum" is the method of this interface.

I need the address of "Sum"

A: 

Sorry to answer with a question, but I have to ask "from where?"

If you mean, how can you iterate through the vtable from a COM client, I don't think you can. On the client side, all you have is a proxy that knows how to communicate (maybe cross-apartment or cross-process) with the COM server. You could maybe probe the vtable of that proxy, but it can never tell you the addresses of the functions inside the COM server.

Of course, if the server is actually running in a different process, the address of the functions might be of little use to you. Even if the server is in the same process, but in a different apartment, getting function addresses might be dangerous: you could call the functions directly, circumventing COM's interception, and break the server class's assumptions around calling thread, etc.

I guess that iterating the vtable is a means-to-an-end...? Maybe post what you're actually trying to do and I think COM probably has a way to do it.

Martin