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 ?
In attachment, a tar with the sources and binaries myapp.exe : the Windows executable mylib.dll : the Windows library mylib_main.c , mylib.spec : the sources to build the Winelib library
On Fri, Apr 5, 2013 at 6:34 PM, Maxime Sednaoui maximeseddev@gmail.comwrote:
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 ?
Hi,
I'm not an expert on this, but anyway: the docs say: "If you have problems then set the WINEDEBUG=+module environment variable before running wine to see what is actually happening."
So I would suggest to try that first. Second, it might be that your dll is loaded, but that it crashes inside? Have you got a trace of the crash? Or have you ran winedbg/wine with gdb to analyze the crash?
Regards,
Matijn
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
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 cdavis5x@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