2

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.

2
  • Starting point Commented Nov 13, 2019 at 14:39
  • 1
    This isn't how you do it. You don't get this information from the DLL file. You use the library documentation and header file. Commented Nov 13, 2019 at 15:28

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Hi @Andrew E by using github.com/erocarrera/pefile can i get description of the functions too.
Ask yourself this: does the PE format contain descriptions of the functions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.