Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Is it possible for reflections for COM Exe or COM DLL?

Is it possible for reflections for COM Exe or COM DLL?

Scheduled Pinned Locked Moved COM
comquestion
15 Posts 4 Posters 28 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G glitteringsound

    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

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #3

    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

    G 1 Reply Last reply
    0
    • J Jonathan Davies

      Afraid I don't understand exactly what it is you are asking, can you clarify or show what you are trying?

      G Offline
      G Offline
      glitteringsound
      wrote on last edited by
      #4

      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?[^]

      1 Reply Last reply
      0
      • L Lost User

        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

        G Offline
        G Offline
        glitteringsound
        wrote on last edited by
        #5

        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.

        L 1 Reply Last reply
        0
        • G glitteringsound

          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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          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

          G 1 Reply Last reply
          0
          • L Lost User

            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

            G Offline
            G Offline
            glitteringsound
            wrote on last edited by
            #7

            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?[^]

            L 1 Reply Last reply
            0
            • G glitteringsound

              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?[^]

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #8

              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

              G 1 Reply Last reply
              0
              • L Lost User

                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

                G Offline
                G Offline
                glitteringsound
                wrote on last edited by
                #9

                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).

                L 1 Reply Last reply
                0
                • G glitteringsound

                  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).

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #10

                  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

                  G 1 Reply Last reply
                  0
                  • L Lost User

                    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

                    G Offline
                    G Offline
                    glitteringsound
                    wrote on last edited by
                    #11

                    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.

                    J 1 Reply Last reply
                    0
                    • G glitteringsound

                      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.

                      J Offline
                      J Offline
                      Jurgen Jung
                      wrote on last edited by
                      #12

                      You can use the same Informations, OLEViewer uses for his visual representation of objects and interfaces. Is that what you are looking for ?

                      G 1 Reply Last reply
                      0
                      • J Jurgen Jung

                        You can use the same Informations, OLEViewer uses for his visual representation of objects and interfaces. Is that what you are looking for ?

                        G Offline
                        G Offline
                        glitteringsound
                        wrote on last edited by
                        #13

                        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.?

                        J G 2 Replies Last reply
                        0
                        • G glitteringsound

                          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.?

                          J Offline
                          J Offline
                          Jurgen Jung
                          wrote on last edited by
                          #14

                          I thought of something like this: http://msdn.microsoft.com/en-us/magazine/bb985086.aspx[^]

                          1 Reply Last reply
                          0
                          • G glitteringsound

                            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.?

                            G Offline
                            G Offline
                            glitteringsound
                            wrote on last edited by
                            #15

                            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.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups