I am working with a .dll that contains a single call which returns an array of function pointers. GetMyApi() returns a pointer to a struct, which is an array of function pointers. The functions themselves have different individual inputs and outputs. What I have tried so far:
[C code that I can't easily alter] C:
typedef struct My_Api_V2
{
int (__cdecl *IsValidInt)(int i);
int (__cdecl *InvalidInt)();
int (__cdecl *IsValidSize)(size_t i);
} my_Api_V2;
const my_Api_V2* GetMyApi(int version); // This function is accessed from DLL
Python effort:
from ctypes import *
my_dll = cdll.LoadLibrary(path_to_my_dll)
my_api = my_dll.GetMyApi
my_api.argtypes[c_int] #version number
my_api.restypes = c_void_p
firstfuncptr = my_api(2)
firstfunc = prototype(firstfuncptr)
firstfunc.argtypes[c_int]
firstfunc.restypes = c_int
test = firstfunc(23)
At this point, I am just trying to get the first function of the function list returned to work. Any help pointing me in better direction is appreciated.
from Python ctypes to return an array of function pointers
No comments:
Post a Comment