none
Unmanaged Code reflection how to do RRS feed

  • Question

  • Hi

    Supposing that I want to write a code to wrap up and unmanaged code. This unmanaged code is located in a DLL. If you use the PINVOKE dllimport method to get the methods inside that DLL. The issue is how to get the method signatures from that DLL. In the other word if you want to deal with this DLL at least you have to know the method names and the range of arguments for each method. Unfortunately there is not technique like the reflection that helps you explore inside an unregistred COM+ DLL. Is there any way to do that. Something some what  like the .Net reflector but for the unmanaged code


    The complexity resides in the simplicity Follow me at: http://smartssolutions.blogspot.com
    Tuesday, May 31, 2011 11:40 AM

Answers

  • Actually dependency walker will still give you the exports for a regular C dll no hex editor needed but you'd still have to guess the number of and type of parameters (which makes it pretty much a waste of time)
    • Marked as answer by MASNSN Wednesday, June 1, 2011 2:51 PM
    Tuesday, May 31, 2011 6:19 PM
  • I haven't look at it for ages, but does PE explorer help?
    • Marked as answer by MASNSN Wednesday, June 1, 2011 2:50 PM
    Tuesday, May 31, 2011 9:04 PM
  • PE Explorer will let you see the exported function signatures...it can be downloaded from here and it has a 30-day free trial.

    ShaneB

    • Marked as answer by MASNSN Wednesday, June 1, 2011 2:50 PM
    Wednesday, June 1, 2011 1:05 AM

All replies

  • Did you try the C++ add in for reflector http://www.sandpapersoftware.com/Main/Reflector.html
    Tuesday, May 31, 2011 11:58 AM
  • Hi

    This is for the C++/CLI the managed C++ and not for C++ which has been writen for within an unmanaged context like the code writen for the native Win 32 with Code blocs for example 

     


    The complexity resides in the simplicity Follow me at: http://smartssolutions.blogspot.com
    Tuesday, May 31, 2011 12:23 PM
  • You cannot reflect back unmanaged code
    Pratap --Mark the best replies as answers!
    Tuesday, May 31, 2011 1:36 PM
  • Usually the DLL ships with documentation and/or a header file that should have the signatures. If its a C++ dll you might be able to de-decorate the function names using dependency walker but there is no such thing as reflection for native code.
    Tuesday, May 31, 2011 2:54 PM
  • I agree with Ray M_...you need the signatures (either from the header files in the unmanaged DLL or the cpp files) in order to accurately do platform invoke calls.  DLL's exported with C-style names will contain the names of the functions exported, but won't contain their signatures (i.e. their parameter names/types and function return type.)

    If you don't have the header files...the only option is to guess.  You can get a list of exported functions in the DLL with a hex editor if you know where you're looking (I recommend Hexplorer.)  Then, it's just a matter of guessing how many parameters you need...and what types they are...and whether the function returns a value or returns void.  This can be a huge pain...I know...I've done it before.

    Good luck!


    Joe Coutcher - Software Engineer
    Tuesday, May 31, 2011 5:44 PM
  • Actually dependency walker will still give you the exports for a regular C dll no hex editor needed but you'd still have to guess the number of and type of parameters (which makes it pretty much a waste of time)
    • Marked as answer by MASNSN Wednesday, June 1, 2011 2:51 PM
    Tuesday, May 31, 2011 6:19 PM
  • I haven't look at it for ages, but does PE explorer help?
    • Marked as answer by MASNSN Wednesday, June 1, 2011 2:50 PM
    Tuesday, May 31, 2011 9:04 PM
  • PE Explorer will let you see the exported function signatures...it can be downloaded from here and it has a 30-day free trial.

    ShaneB

    • Marked as answer by MASNSN Wednesday, June 1, 2011 2:50 PM
    Wednesday, June 1, 2011 1:05 AM
  • At least I get the signature in case there is not chm file that explains the staff
    The complexity resides in the simplicity Follow me at: http://smartssolutions.blogspot.com
    Wednesday, June 1, 2011 2:45 PM
  • Hi I will take a look on  P E explorer

    The complexity resides in the simplicity Follow me at: http://smartssolutions.blogspot.com
    Wednesday, June 1, 2011 2:50 PM