Basically I'm wondering if there is a way using Wine (libwine maybe?) to make a wrapper .so for a windows .dll. Something where I load the .dll, load a few function pointers from it, and use Wine like an FFI. It seems like Wine must have to do this internally, constantly calling back and forth from the System V ABI and the Windows one.
Specifically I have an interface library for an expensive scientific data logging device that communicates over UDP and not directly to the HW. The API itself is only about 20 functions long using simple types (ints, doubles, double[]) so making a wrapper .so by hand wouldn't be all that much work if it is indeed possible.
edit: I made some partial progress, but not a solution. I did some reading and found out about winegcc. I knew libSDL had a fairly straight forward log function, so I got a windows .dll of it and did the following:
HINSTANCE sdl = LoadLibrary("SDL2.dll");
assert(sdl);
typedef void logf(const char* fmt, ...);
logf *log = (logf*)GetProcAddress(sdl, "SDL_Log");
assert(log);
log("Hello");
It sort of works! It prints out "INFO: ??{" to the console, so the function pointer is being retrieved correctly and since it prints anything at all the dll must be calling back into libwine correctly. I was kind of hoping that GetProcAddress() would return a magic trampoline that converts the ABI for me, but maybe that's not the case? If I call the log function using inline assembly to pass the parameters using the MS ABI, it still does the same thing, so I'm not really sure what to try next.