On Tue, Feb 17, 2009 at 3:56 PM, Dan Kegel dank@kegel.com wrote:
The above doesn't work ... LoadLibraryA fails (returns NULL).
Aha, you're right. libwine is shipped as an .so, not as a .dll.so.
But have a look at wine_dlopen and wine_dlsym, http://source.winehq.org/source/libs/wine/loader.c#L677 http://source.winehq.org/source/libs/wine/loader.c#L742 They really are very simple wrappers around Unix system calls. There's no reason you can't write your own wrappers in assembly inside your winegate, they would probably only be ten lines or so each. That would let you compile it as a real .dll instead of a winelib dll. It's possible this would be less of a maintenance hassle than shipping winegate as a winelib dll.
How do I get address of wine_dlopen/dlsym for the "assembly" part .DLL ? If I import it, how does PE loader know where to import from? I don't think this is possible ... except searching through memory, some Linux-only syscalls, etc.
The solution I have created is the cleanest possible way I think. If you decide to provide some GetProcAddress method to obtain any function location (or load library), let me know, we'll remove WINEGATE.DLL and change it to your way. Otherwise I think it's waste of time as you are not accepting that Win32 application should be able to load native Linux lib.
Martin