Hi, today i wanted to create a test for CreateCompatibleDC so i created a exe with this content [1] just to find out it crashes wine inside XRenderFindDisplay [2]
The reason is that the CreateCompatibleDC call in gdi executes LoadLibrary winex11.drv which in turn also loads user32.dll, because winex11.drv links to it. Then in DllMain user32 registers some builtin classes which causes it to call into winex11. But at this point DllMain of winex11 had no chance to execute and XRenderQueryExtension gets passed a NULL pointer which makes it unhappy.
Unfortunately i have no idea how to properly solve this problem :-( * Use UserClientDllInitialize for initializing user32 stuff as the comment above DllMain mentions it? * I tried linking gdi32 to user32(windows seems to do that) and inserted a dummy IsCharAlphaA('c'); to make sure it is *really* linked :-) And it does not crash anymore, but i don't know if i break any assumptions with that. Also i think it is preferable to defer loading the driver until it is really needed. If you have a better idea of how to fix this please tell me.
Greetings Peter
1: simplified version, compile with winegcc foo.c -lgdi32 #include <windows.h> int main(int argc, char ** argv){ CreateCompatibleDC(NULL); }
2: see attachment