Is it possible for reflections for COM Exe or COM DLL?
-
Hello, Can we use reflections to invoke the exposed methods of certain interfaces of COM Object? Here we will be able to show all exposed methods of COM DLL or COM exe and and on run time, we can execute all of those methods, by passing parameters. This is already done for Win32DLL here but any idea about COM? Regards Muhammad Usman Khalil
-
Afraid I don't understand exactly what it is you are asking, can you clarify or show what you are trying?
Can we call COM exposed interface METHODS at runtime one by one. This can be achieved in case of WIN32 DLL's using reflections. But SAME job need to be done with COM Dll or COM EXE. We'll be able to view all exposed methods of that COM DLL or COM EXE on client(say on MFC GUI) and ony by one we need to call all of those methods by just clicking "invoke or Execute".(Remember I need to call unmanaged code, purely written in VC++ unmanaged code) . That would not be .NET assembly. e.g I had COM DLL ----------- it has mehods namely int Sum(int,x,int y); Client should show in its combo the methods signature i.e Sum(int x,int y) and when I click at invoke it should give me result say (2 OR any thing that would be sum of those x & y params). this is done here but this is strictly for Win32 DLL's not for COM DLL or COM EXE's Execute a function in any Win32 DLL - Reflection in Win32 DLL?[^]
-
I think you can get the information you need from OLEViewer, which is distributed with the Windows SDK, in the tools section.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
OLEView just facilitate to view information of interfaces, co-classes and other types and it might take these info's from TLB. I need to call any exposed methods of COM object at RUN TIME using reflections just we can do the same job in Win32 DLL's.
-
OLEView just facilitate to view information of interfaces, co-classes and other types and it might take these info's from TLB. I need to call any exposed methods of COM object at RUN TIME using reflections just we can do the same job in Win32 DLL's.
I don't think you can do this in COM or in WIN32 DLL as neither of them support reflection in the .NET sense. I know it is possible to figure out some aspects of functions from decorated function names, but if the names are undecorated (i.e. C style) then such information is not available.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
-
I don't think you can do this in COM or in WIN32 DLL as neither of them support reflection in the .NET sense. I know it is possible to figure out some aspects of functions from decorated function names, but if the names are undecorated (i.e. C style) then such information is not available.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
See here.. download this demo and give it any win32 dll. It'll allow you to execute its functions(which it'll extract and pull in its combo) by clicking "Execute" button. Execute a function in any Win32 DLL - Reflection in Win32 DLL?[^]
-
See here.. download this demo and give it any win32 dll. It'll allow you to execute its functions(which it'll extract and pull in its combo) by clicking "Execute" button. Execute a function in any Win32 DLL - Reflection in Win32 DLL?[^]
That may be true, but it is not reflection in the proper sense. Microsoft does not offer reflection in Win32 dll libraries, so anything you rely on may change in the future. .NET reflection is an official part of the .NET architecture and will be supported by Microsoft.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
-
That may be true, but it is not reflection in the proper sense. Microsoft does not offer reflection in Win32 dll libraries, so anything you rely on may change in the future. .NET reflection is an official part of the .NET architecture and will be supported by Microsoft.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
Yeah that's true. That's not exactly reflection underway.It's effort to make the result similar what reflection facilitates programmer. So I need to get same behavior which's being done in that (Executing function in Win32 DLL by clicking "Execute"). Can we load COM DLL or COM EXE dynamically(in case of DLL its LoadLibrary) and get its functions/methods (in DLL by GetProcAddress. One way which I sought out is to iterate over vtable which'll contain addresses of COM interface's virtual methods. But that technique only applicable with virtual functions(as they only go in vtable) . What about simple(non-virtual) methods of COM interfaces. Where we can get addresses of those methods(non-virtual).
-
Yeah that's true. That's not exactly reflection underway.It's effort to make the result similar what reflection facilitates programmer. So I need to get same behavior which's being done in that (Executing function in Win32 DLL by clicking "Execute"). Can we load COM DLL or COM EXE dynamically(in case of DLL its LoadLibrary) and get its functions/methods (in DLL by GetProcAddress. One way which I sought out is to iterate over vtable which'll contain addresses of COM interface's virtual methods. But that technique only applicable with virtual functions(as they only go in vtable) . What about simple(non-virtual) methods of COM interfaces. Where we can get addresses of those methods(non-virtual).
glitteringsound wrote:
Where we can get addresses of those methods(non-virtual).
Sorry, no idea; also I don't believe COM was ever designed with that in mind. My only suggestion is to try it and see what results you get.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
-
glitteringsound wrote:
Where we can get addresses of those methods(non-virtual).
Sorry, no idea; also I don't believe COM was ever designed with that in mind. My only suggestion is to try it and see what results you get.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
Any body else that can help in this regard? I think we need to lookup .data or .code sections of COM EXE or COM DLL then to lookup exaxct addresses of plain COM interfaces methods.
-
Any body else that can help in this regard? I think we need to lookup .data or .code sections of COM EXE or COM DLL then to lookup exaxct addresses of plain COM interfaces methods.
You can use the same Informations, OLEViewer uses for his visual representation of objects and interfaces. Is that what you are looking for ?
-
You can use the same Informations, OLEViewer uses for his visual representation of objects and interfaces. Is that what you are looking for ?
I Got the idea.!! As no any function(method) in interface which's implemented by COM object which's not virtual. All interface methods that implemented by COM component always pure virtaul, thus always go inside vtable. So we can easily traverse vtable and can get exact addresses of all of those. Now rest is calling those functions. It includes knowing about full signature and every thing it takes as parameter. This is the one which is still missing ..an idea.?
-
I Got the idea.!! As no any function(method) in interface which's implemented by COM object which's not virtual. All interface methods that implemented by COM component always pure virtaul, thus always go inside vtable. So we can easily traverse vtable and can get exact addresses of all of those. Now rest is calling those functions. It includes knowing about full signature and every thing it takes as parameter. This is the one which is still missing ..an idea.?
I thought of something like this: http://msdn.microsoft.com/en-us/magazine/bb985086.aspx[^]
-
I Got the idea.!! As no any function(method) in interface which's implemented by COM object which's not virtual. All interface methods that implemented by COM component always pure virtaul, thus always go inside vtable. So we can easily traverse vtable and can get exact addresses of all of those. Now rest is calling those functions. It includes knowing about full signature and every thing it takes as parameter. This is the one which is still missing ..an idea.?
Done all!! Only one thing is left.? 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.