C / Python ctypes shared object introspection libraries/techniques
I was looking for a way to list .text section defined symbols on a C shared object loaded on a python program using the ctypes wrapper. In other words, i am trying to get a list of defined functions on a CD开发者_运维技巧LL loaded object.
If there is no way to do this with ctypes or library ( or python binding ), another option is a python elf parsing library or a solution like http://halflifelibrary.com/wiki/Metamod-P.
Any way to do this ?
Adding to the list of methods that you are trying to use to get the list of functions that is exported by the dll.
There is a script at : http://projects.scipy.org/numpy/wiki/MicrosoftToolchainSupport that dumps the symbol tables of the dll, parses it to get the public table and output the table into a .def file. It also says that this may not work if the dll is stripped.
I am not sure if there are good ELF parsers out there in Python. Adding some that I have found.
- http://code.google.com/p/syn-code/source/browse/trunk/freezedis.py
FYI there is no way to get a list of defined methods on a shared object loaded using ctypes because there is no meta information on the object structure.
If you need a platform specific object parser maybe you should take a look at http://projects.scipy.org/numpy/wiki/MicrosoftToolchainSupport using the objdump routines to get defined function references on the text section.
My option do this is to write a small parser using a ELF parser library like Hachoir or the Pydevtools in order to introspect the object.
精彩评论