I have a Windows executable that load a library and I want to create a Winelib DLL that will overide the Windows DLL. It's been 2 days that I search and try but it won't work ! Please help me !
Basically I create mydll.c and mydll.spec to build the Winelib DLL with the command:
winegcc -m32 -shared -o mydll.dll mydll.c mydll.spec
Now I have mydll.dll.so and I want to override mydll.dll (both are at the same place) What should I do ? I try to rename mydll.dll but 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. I don't understand how to proceed.
How I load the library in my Windows executable
HINSTANCE DllHandle;
char str[255];
typedef int(__stdcall * tfp)(char * const);
DllHandle = LoadLibrary("mydll.dll");
tfp fp = (tfp)GetProcAddress(DllHandle, "myfunc");
fp(str);
FreeLibrary(DllHandle);
mydll.spec
@ stdcall myfunc(str)
mydll.c
#include <windef.h>
int WINAPI myfunc(char * str)
{
strcpy(str, "myfunc from the Winelib DLL");
return 0;
}
I was able to get this to work but had to make the following changes.
I was using wine5 on Ubuntu, where is seems the default install is 64bit. I had to rename wine's executable first as it was using the 32bit call by mistake and that meant it would not work with the 64bit dll.
install wine-tools (for winegcc)
Fix wine64 (as the exe seems to load wine32 and then error)
Makefile
Also, there is a mistake in your code, which I corrected. The lack of a __stdcall and the name of the DLL.