<rant>
Well... a couple weeks ago Windows 10 decided that I just had to install an update in the middle of the workday, rebooted my computer, installed the update, and rebooted again to a blue screen. It corrupted my hard drive. -_- After downloading farting around with the recovery tools for half a day, it became clear that I was going to have to backup, format, and reinstall. The Windows disk was listed first in the list for the other tools, so I reformatted disk 0 and started the installer... without checking which disk that actually was. So now I had two non-working OSes on my work computer. -_- I'm still so unreasonably mad about the whole experience, that I don't care about "practicality" so much anymore.
</rant>
So anyway. My only link to Windows right now is that the expensive bio sensor interface only has a Windows .dll for it's interface. It connects over UDP, and the whole API is 20 functions, with the most exotic data type being double[]. So I started reading and found out about libwine and winegcc. I'm hoping I can create a .so that wraps the .dll using libwine, but I've run into some snags.
The first thing I tried was to grab SDL2.dll and used winegcc to LoadLibray() and GetProcAddress() from it to do some logging and open a window. Good so far. Next I tried building the wrapped code into a .so using winegcc -shared. From regular Linux code I can use dlopen() to load the wrapper library, but it crashes with a segmentation fault when the wrapper library tries to call LoadLibrary() to load the wrapped Windows dll. Drat! Stepping into the call with GDB, LoadLibrary() calls LoadLibraryA(), which I found in the Wine source code to be a simple tail call:
Code: Select all
HMODULE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR libname){
return LoadLibraryExA(libname, 0, 0);
}
Code: Select all
0x00007ffff7e20148 in LoadLibraryA () from ./wrap-win.dll.so
(gdb) disassemble
Dump of assembler code for function LoadLibraryA:
=> 0x00007ffff7e20148 <+0>: jmpq *0x304a(%rip) # 0x7ffff7e23198
End of assembler dump.
(gdb) si
0x000000000000019e in ?? ()
(gdb)
Code: Select all
(gdb) p/x *(void**)($rip + 0x304a)
$4 = 0x19e000000000000
(gdb) p LoadLibraryExA
$5 = {<text variable, no debug info>} 0x7ffff759dda0 <LoadLibraryExA>