Discussion:
Hook COM Methods
(too old to reply)
Günter Prossliner
2010-06-17 13:36:32 UTC
Permalink
Hello NG!

Maybe it's a little bit OT, but not many newsgroups have survifed the
"Evolution of the Online Communitiy". I have not seen a single C++ or COM
Newsgroup this days...


My question is: Does anybody know how to hook Method called on an instance
of a COM interface?


Thanks!
GP
John Doe
2010-06-25 11:18:29 UTC
Permalink
My question is: Does anybody know how to hook Method called on an instance of
a COM interface?
Perhaps this would work...

Create a new custom COM object with exactly the same interfaces, CLSIDs, IIDs,
etc... as the original one, which you are about to hook.
Register that new one by running regsvr32.

Now, inside your COM, manually load the original DLL and create the original
object by calling DllGetClassObject().

Actually this way you created a custom wrapper around the original COM.

I don't know if it works, but I think it should...


Hope it helps...
Günter Prossliner
2010-06-28 08:52:44 UTC
Permalink
Hello John!
Post by John Doe
Create a new custom COM object with exactly the same interfaces,
CLSIDs, IIDs, etc... as the original one, which you are about to hook.
Register that new one by running regsvr32.
Now, inside your COM, manually load the original DLL and create the
original object by calling DllGetClassObject().
Actually this way you created a custom wrapper around the original COM.
Thank you! I'll give it a try!

The only Problem I see so far is that I'll make permanent modifications to
the registry. I would like to modify only the target process, not other
processes consuming the same COM Server, and I don't want to leave the
registry in an invalid state when my process terminates without cleanup.

But if the manual registration works, I think I can try without regsvr32 on
my dll by hooking the Registry-API.


Thank you again!
GP
Leo Davidson
2010-06-28 09:40:14 UTC
Permalink
Post by Günter Prossliner
Does anybody know how to hook Method called on an instance
of a COM interface?
I have not used it but this may be of interest:

http://www.nektra.com/products/com-spy-console

It seems to use a library which you can call from your own code as
well as providing a UI for COM tracing. (I think there is a free
version and a commercial version. Haven't looked into the differences;
I only just stumbled on it while looking for something else.)

There's also this, which looks good as a tracer for COM and Win32:

http://jacquelin.potier.free.fr/winapioverride32/

(I haven't used that either; only just discovered that too. Looks
good, at least if you don't need to trace 64-bit processes.)

There's also an old "ComSpy" (a name used by several other things,
some not involving COM, so watch out when you Google :) ) tool with
source, though the most common site for it seems to no longer exist:

http://staff.develop.com/jasonw/comspy/

I think I have a copy of it somewhere although I have to admit I could
never get it to work. :)

I'm sure there was something else, called "Universal Delegate" or
something similar, but I'm having trouble finding it now. (Perhaps it
was part of the technique ComSpy used rather than a separate tool?)
I'm sure there was at least one other old COM tracing tool (which I
also tried and could never get to work).

Hopefully those two newer tools work more easily than the older ones
(which I'm sure worked in the past but weren't kept up-to-date).
Günter Prossliner
2010-06-30 07:35:29 UTC
Permalink
Hello Leo!
Post by Günter Prossliner
Does anybody know how to hook Method called on an instance
of a COM interface?
...

Thank you very much for the amount of information you've provided!!!

I'll try them and will see if some are valuable for my problem!



GP

Continue reading on narkive:
Loading...