tags:

views:

86

answers:

1

Hi. I'm currently trying to do some introspection on a DLL with python. I want to create automatically a graphical test interface based on a DLL.

I can load my DLL in python quite easily and I call some functions. The main problem is if I call "dir" on the object without calling any method, I've got in result

>>> dir(myLib)
['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__',
'__format__', '__getattr__', '__getattribute__', '__getitem__', '__hash__', '__i
nit__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__s
etattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_func_fl
ags_', '_func_restype_', '_handle', '_name']

and when I call manually a function (like "Read_Version") I have as result of the dir function

>>> dir(myLib)
['Read_Version', '_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__',
'__format__', '__getattr__', '__getattribute__', '__getitem__', '__hash__', '__i
nit__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__s
etattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_func_fl
ags_', '_func_restype_', '_handle', '_name']

It seems that introspection work only on function I have already called and this is not really "usefull" ;).

Have you got an other idea to fetch functions which are in a DLL ? (in python of course)

I'm using python 2.6 under Windows.

+1  A: 

As far as I know, there is no easy way to do this. You have to use some external tool (e.g. link /dump /exports) or use a PE/DLL parser (e.g. pefile).

Lukáš Lalinský
Thanks for your help. I'll try to investigate on this way
X-Blaster