Pergunta

Atualmente estou tentando fazer alguma introspecção em uma DLL com python. Eu quero criar automaticamente uma interface gráfica de teste com base em uma DLL.

Eu posso carregar o meu DLL em python muito facilmente e eu chamo algumas funções. O principal problema é que eu chamo de "dir" no objeto sem chamar qualquer método, eu tenho no resultado

>>> 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']

e quando eu manualmente chamar uma função (como "Read_Version") eu tenho como resultado da função dir

>>> 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']

Parece que o trabalho introspecção apenas em função de já chamou e isso não é realmente "útil";).

Você tem uma outra idéia para buscar funções que estão em uma DLL? (Em python é claro)

Eu estou usando Python 2.6 no Windows.

Foi útil?

Solução

Tanto quanto eu sei, não há nenhuma maneira fácil de fazer isso. Você tem que usar alguma ferramenta externa (por exemplo link /dump /exports) ou usar um analisador PE / DLL (por exemplo pefile ).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top