Hi,
I have windows binary-only, third-party .DLL library without any source files. I would like to use it in my unix-based project, which is compiled with usual GNU C compiler. Wine documentation says Wine is able to load external .DLLs, but does not explain how to implement such ability in userland program using Wine API. I've discovered LoadLibrary() and GetProcAddr() functions compiled into built-in DLL (kernel32.dll.so), so in order to load my DLL I use the function LoadLibrary("somelib.dll"), linking my project with -lwine and -lkernel32.
The problem is that when my application calls LoadLibrary(), it causes Bus Error. Back tracing using gdb shows that the crash appears under such sequence:
in main() in LoadLibraryA() at module.c:745 in LoadLibraryExA() at module.c:706 in FILE_name_AtoW() at file.c:198 in ?? () from kernel32.dll.so
The function call at file.c:198 is RtlInitAnsiString() and (as I understand) is unreferenced in kernel32 and uses ntdll.dll.so.
What things should I do before calling LoadLibrary()?
By the way: If I call RtlInitAnsiString() directly from main(), linking my project with ntdll.dll.so, it is called correctly, works and returns some result.
I tried to define -lntdll within LDFLAGS, in this case compile finishes cleanly, but the Bus Error still appears.
Also I tried to find any examples showing how to load external .DLL. I've found no examples.
Note: there is no ability to obtain library sources.
Bye.
On February 1, 2005 08:46 am, Sergey Efimoff wrote:
Hi,
I have windows binary-only, third-party .DLL library without any source files. I would like to use it in my unix-based project, which is compiled with usual GNU C compiler. Wine documentation says Wine is able to load external .DLLs, but does not explain how to implement such ability in userland
(Unless things have changed without me noticing) You are going to have to investigate WineLib. You can't simply link Wine into an existing unix executable, Because of some low level stuff Wine has to be the main process.
Bye.
On Feb 1, 2005, at 9:04 PM, Bill Medland wrote:
I have windows binary-only, third-party .DLL library without any source files. I would like to use it in my unix-based project, which is compiled with usual GNU C compiler. Wine documentation says Wine is able to load external .DLLs, but does not explain how to implement such ability in userland
(Unless things have changed without me noticing) You are going to have to investigate WineLib. You can't simply link Wine into an existing unix executable, Because of some low level stuff Wine has to be the main process.
Unfortunately, I cannot use Wine as a main process (did you mean the stuff which is now made by preloader?). My project is a complex multi-threaded application, and the DLL mentioned above is to be only the small part of it. If I had to use this DLL in a simple application, I would certainly used Wine as the main process.
So, is it unreal to use windows DLL as a child instance? By any means?
Bye.
On February 1, 2005 11:53 am, Sergey Efimoff wrote:
On Feb 1, 2005, at 9:04 PM, Bill Medland wrote:
I have windows binary-only, third-party .DLL library without any source files. I would like to use it in my unix-based project, which is compiled with usual GNU C compiler. Wine documentation says Wine is able to load external .DLLs, but does not explain how to implement such ability in userland
(Unless things have changed without me noticing) You are going to have to investigate WineLib. You can't simply link Wine into an existing unix executable, Because of some low level stuff Wine has to be the main process.
Unfortunately, I cannot use Wine as a main process (did you mean the stuff which is now made by preloader?). My project is a complex multi-threaded application, and the DLL mentioned above is to be only the small part of it. If I had to use this DLL in a simple application, I would certainly used Wine as the main process.
So, is it unreal to use windows DLL as a child instance? By any means?
Bye.
I believe so.
One option you might want to consider is placing the Windows DLL in a server process of some sort and using tcp/ip or some other IPC to talk between the two processes. Then one process can be unix and one wine.
On Tue, 01 Feb 2005 22:53:39 +0300, Sergey Efimoff wrote:
Unfortunately, I cannot use Wine as a main process (did you mean the stuff which is now made by preloader?). My project is a complex multi-threaded application, and the DLL mentioned above is to be only the small part of it.
Why does that matter? The main reason people want to avoid their app depending on Wine is for dependency reasons, but even that is solvable.
What making a Winelib app means is basically
CC=winegcc CXX=wineg++ ./configure
OK, so it's a bit more work than that, but really it's not a huge deal. At the end you get a shell script instead of a binary and when run your app will start up and act just like a normal UNIX app, except that you can now call Win32 APIs like LoadLibrary.
The main problem is that now your program requires Wine to be present in order to start. So it's not optional. If you don't like that, just put your program code into a library, libfoobar-app then have two little stub programs that load it: one that doesn't use Wine and one that does. Then the user can pick the right one for their situation.
thanks -mike