Hi, It works, thank you ! Sorry, it was a silly mistake... I added "__declspec(dllexport)" in mylib_main.c and it was done ! I really appreciate your help, I spent an awful amount of time on it.
Best, On Sat, Apr 6, 2013 at 5:42 AM, Charles Davis <cdavi...@gmail.com> wrote: > > On Apr 5, 2013, at 10:34 AM, Maxime Sednaoui wrote: > > Hi, > > > > First, I already asked for the same thing at the forum where I've been > told to post here for my question > > Link here : http://forum.winehq.org/viewtopic.php?f=8&t=18675 > > > > I have a Windows executable that load a really simple DLL (it is a test) > and I want to create a Winelib DLL that will override the Windows DLL. > Basically, I created mylib_main.c and mylib.spec to build the Winelib DLL > with the command: > > winegcc -mwindows -o mylib.dll.so mylib_main.c -I${WINE_ROOT}/include > -shared mylib.spec > > winebuild -w --def -o libmylib.def --export mylib.spec > > > > Now I have mylib.dll.so and I want to override mylib.dll > > What should I do ? I removed the Windows library but then I got a Page > Fault when the function is called. I also tried to configure the override > with winecfg or set environment variables like WINEDLLPATH or add a DllMain > in my library. I don't understand how to proceed. > > > > Is this because of the way I build my library ? Or maybe I forget a step > to link it properly ? > Actually, it's much simpler than that. > > Your Winelib DLL doesn't export a function called myfunc(), but the native > DLL does. (Try running: > > $ winedump -jexport mylib.dll > > to see what I mean.) > > Your test app LoadLibrary()'s mylib.dll, then GetProcAddress()'s myfunc() > from it. (I know this because it doesn't directly call myfunc(). Run: > > $ winedump -jimport myapp.exe > > to verify this.) When it does this with your Winelib DLL, GetProcAddress() > returns NULL and your program crashes--probably because it doesn't check > for NULL before calling the function. (Of course, the whole point of > GetProcAddress() is to be able to check if a function exists in a DLL > before calling it. If you don't check for NULL, then why bother with it in > the first place? But I digress.) > > Chip > >