ARTICLE AD BOX
I have a C++ DLL and using dumpbin tool to get one of the APIs names in it:
ordinal hint RVA name 56 3D 00005BB0 GetUserPassI have access to code header file and the I am in need to use a DLL function listed below (dumpbin shows me this API format - though the DLL is generated via C++):
USER_API USER::ResultCode DD_STDCALL GetUserPass();I am using the below code to call the API:
import ctypes from ctypes import wintypes, byref, c_uint32, c_int, c_int32 dll_path = r"C:\\Program Files (x86)\\Software\\UserComm.dll" user = ctypes.cdll.LoadLibrary(dll_path) ResultCode = c_uint32 user.GetUserPass.restype = ResultCode rc = user.GetUserPass() print("GetUserPass:", "Success" if rc == 0 else f"Error {rc}")I am receiving below error when I execute the above Python code:
GetUserPass: Error 3758100487When I take a comlete dumpbin of the C++ DLL only a few functions have name mangling while many others like GetUserPass does not. Can that be an issue to not to able to use C++ DLL API function name directly in Python without C interface? What are the ways we can resolve the issue
I am not able to ahieve succfull return code from the API - on success it should return 0.
How can I acheive the same and whats the issue is here my side?
When I use command line interface I get till below point:
>>> print(user.GetUserPass) <_FuncPtr object at 0x01CF6738> >>> dir(user.GetUserPass) ['__bool__', '__call__', '__class__', '__ctypes_from_outparam__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_b_base_', '_b_needsfree_', '_flags_', '_objects', '_restype_', 'argtypes', 'errcheck', 'restype'] >>>