Category : ctypes

I’m trying to wrap an API, that has a lot of functions where it returns a status (no issue there), but the actual output is a structure pointer array. I’m having trouble getting a useful structure back. All of the documentation I’ve found so far handles returns instead of pointer outputs. This is what everything ..

Read more

I am working with a library written in C that has a function which returns a handle (to an object I expect). I have tried a number of different ctypes for this handle, but each time I try to use the handle in the next function I get a Seg Fault. What is the correct ..

Read more

I am trying to make sense of the ctypes/callback documentation: https://docs.python.org/3/library/ctypes.html#callback-functions My c code defines a LogFunction as: typedef void (*LogFunction)(int logLevel, const char* loggerName, const char* logMessage); So my naive attempt (following the documentation) has been to expose the API using: LOGFUNC = CFUNCTYPE(None, c_int, c_char_p, c_char_p) acme_listener_configure = _lib.acme_listener_configure acme_listener_configure.restype = None acme_listener_configure.argtypes ..

Read more

so I have a multithreading python program that on one thread there is a messagebox: loopMessageBox = ctypes.windll.user32.MessageBoxW(0, message, "GH Automation", 0x40000) if ctypes.windll.user32.MessageBoxW(0, message, "GH Automation", 0x40000) == 1: self.loop_Message_Box(message) and on another thread: ctypes.windll.user32.SendMessageW(loopMessageBox, 0x0010, 0, 0) with loopMessageBox being global variable. However the 2nd thread never clear out loopMessagebox unless I avoid ..

Read more

I have a function whose argument is a char pointer which is used as a buffer to store some byte message: struct test { unsigned char *buffer; uint32_t bufferSize; uint32_t bufferEnd; }; void test_func(struct test *self, uint16_t messageId, unsigned char *buffer, uint32_t bufferSize) { self->buffer = buffer; self->bufferSize = bufferSize; self->bufferEnd = 0; if (self->bufferSize ..

Read more