1

I am learning how to interact Python3 with hardware using naive windows dll files. But using ctypes i'm able to find the dll file but, not able to find the exposed functionalities from the dll.

I searched in google, stackoverflow, everywhere and unable to find the solution for my problem.

For Example:

import ctypes
data = ctypes.CDLL("WWanAPI.dll")

when i tried dir(data) functionality i got the following response: ['_FuncPtr', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_func_flags_', '_func_restype_', '_handle', '_name']

Any insights will be helpful to find all the functionalities of a dll.

shiva
  • 5,083
  • 5
  • 23
  • 42

1 Answers1

1

The ctypes module provides no such functionality, because there are no functions provided by Windows for iterating the contents of a DLL.

What you want is to inspect the contents of the DLL. It's just a file, and it's in the "portable executable" (PE format), therefore you want mechanisms that can read files in that format.

If you just need a command-line tool, look at dumpbin.

A good answer: https://stackoverflow.com/a/24732280/963195 and various good answers here: Is there a way to find all the functions exposed by a dll

... and here is a module in Python for it:

https://github.com/erocarrera/pefile

Andrew E
  • 7,697
  • 3
  • 42
  • 38