DLL Load Question: Please Help!

Sergey Efimoff risky at mail.ru
Tue Feb 1 10:46:50 CST 2005


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.




More information about the wine-devel mailing list