How does function name resolution work in CTYPES?

I work with the Windows API, whose function names begin with an underscore in a 32-bit dll (e.g. _FunctionName), but not in a 64-bit version (e.g. FunctionName).

I use code like this to load and call 64-bit versions of functions:

dll = windll.LoadLibrary('library.dll')
dll['FunctionName']()

However, I find that I can also use the same code to call 32-bit functions, even if they start with an underscore. I can even call the name of the function something other than an underscore, and it will still be resolved. If I completely change the name, it will not be resolved as expected.

I would like to avoid using different methods of calling functions on 64-bit and 32-bit platforms, and this seems to work. However, I cannot find documentation for this behavior. Can anyone confirm this behavior or provide him with documentation?

+4
source share

Source: https://habr.com/ru/post/1607833/


All Articles