<div dir="ltr"><div>Hi,<br><br></div><div>It works, thank you ! Sorry, it was a silly mistake... I added "__declspec(dllexport)" in mylib_main.c and it was done !<br></div><div>I really appreciate your help, I spent an awful amount of time on it.<br>
</div><div><br></div><div>Best,<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Apr 6, 2013 at 5:42 AM, Charles Davis <span dir="ltr"><<a href="mailto:cdavis5x@gmail.com" target="_blank">cdavis5x@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Apr 5, 2013, at 10:34 AM, Maxime Sednaoui wrote:<br>
> Hi,<br>
><br>
> First, I already asked for the same thing at the forum where �I've been told to post here for my question<br>
> Link here : <a href="http://forum.winehq.org/viewtopic.php?f=8&t=18675" target="_blank">http://forum.winehq.org/viewtopic.php?f=8&t=18675</a><br>
><br>
> 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:<br>

> winegcc -mwindows -o <a href="http://mylib.dll.so" target="_blank">mylib.dll.so</a> mylib_main.c -I${WINE_ROOT}/include -shared mylib.spec<br>
> winebuild -w --def -o libmylib.def --export mylib.spec<br>
><br>
> Now I have <a href="http://mylib.dll.so" target="_blank">mylib.dll.so</a> and I want to override mylib.dll<br>
> 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.<br>

><br>
> Is this because of the way I build my library ? Or maybe I forget a step to link it properly ?<br>
</div>Actually, it's much simpler than that.<br>
<br>
Your Winelib DLL doesn't export a function called myfunc(), but the native DLL does. (Try running:<br>
<br>
�$ winedump -jexport mylib.dll<br>
<br>
to see what I mean.)<br>
<br>
Your test app LoadLibrary()'s mylib.dll, then GetProcAddress()'s myfunc() from it. (I know this because it doesn't directly call myfunc(). Run:<br>
<br>
�$ winedump -jimport myapp.exe<br>
<br>
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.)<br>

<br>
Chip<br>
<br>
</blockquote></div><br></div>