开发者

Introspecting a DLL with python

开发者 https://www.devze.com 2022-12-09 14:47 出处:网络
I\'m currently tryi开发者_StackOverflow中文版ng to do some introspection on a DLL with python. I want to create automatically a graphical test interface based on a DLL.

I'm currently tryi开发者_StackOverflow中文版ng 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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消