USER32: Protect USER32 against early graphics driver unloading.
Dmitry Timoshkov
dmitry at baikal.ru
Sun Oct 17 07:05:14 CDT 2004
"Mike McCormack" <mike at codeweavers.com> wrote:
> ChangeLog:
> <dmitry at codeweavers.com>
> * Protect USER32 against early graphics driver unloading
Alexandre, please use this more complete patch instead.
--
Dmitry.
-------------- next part --------------
diff -u cvs/hq/wine/dlls/user/display.c wine/dlls/user/display.c
--- cvs/hq/wine/dlls/user/display.c 2003-09-09 15:36:27.000000000 +0900
+++ wine/dlls/user/display.c 2004-10-17 20:13:32.000000000 +0900
@@ -52,7 +52,7 @@ WORD WINAPI DISPLAY_Inquire(LPCURSORINFO
*/
VOID WINAPI DISPLAY_SetCursor( struct tagCURSORICONINFO *lpCursor )
{
- USER_Driver.pSetCursor(lpCursor);
+ if (USER_Driver.pSetCursor) USER_Driver.pSetCursor(lpCursor);
}
/***********************************************************************
@@ -60,7 +60,7 @@ VOID WINAPI DISPLAY_SetCursor( struct ta
*/
VOID WINAPI DISPLAY_MoveCursor( WORD wAbsX, WORD wAbsY )
{
- USER_Driver.pSetCursorPos(wAbsX, wAbsY);
+ if (USER_Driver.pSetCursorPos) USER_Driver.pSetCursorPos(wAbsX, wAbsY);
}
/***********************************************************************
diff -u cvs/hq/wine/dlls/user/message.c wine/dlls/user/message.c
--- cvs/hq/wine/dlls/user/message.c 2004-10-08 12:47:48.000000000 +0900
+++ wine/dlls/user/message.c 2004-10-17 20:26:15.000000000 +0900
@@ -1112,7 +1112,9 @@ static LRESULT handle_internal_message(
case WM_WINE_DESTROYWINDOW:
return WIN_DestroyWindow( hwnd );
case WM_WINE_SETWINDOWPOS:
- return USER_Driver.pSetWindowPos( (WINDOWPOS *)lparam );
+ if (USER_Driver.pSetWindowPos)
+ return USER_Driver.pSetWindowPos( (WINDOWPOS *)lparam );
+ return 0;
case WM_WINE_SHOWWINDOW:
return ShowWindow( hwnd, wparam );
case WM_WINE_SETPARENT:
@@ -2411,7 +2413,7 @@ BOOL WINAPI MessageBeep( UINT i )
{
BOOL active = TRUE;
SystemParametersInfoA( SPI_GETBEEP, 0, &active, FALSE );
- if (active) USER_Driver.pBeep();
+ if (active && USER_Driver.pBeep) USER_Driver.pBeep();
return TRUE;
}
diff -u cvs/hq/wine/dlls/user/user_main.c wine/dlls/user/user_main.c
--- cvs/hq/wine/dlls/user/user_main.c 2004-07-27 23:16:42.000000000 +0900
+++ wine/dlls/user/user_main.c 2004-10-17 20:13:32.000000000 +0900
@@ -237,6 +237,15 @@ static void thread_detach(void)
}
+/**********************************************************************
+ * process_detach
+ */
+static void process_detach(void)
+{
+ memset(&USER_Driver, 0, sizeof(USER_Driver));
+ FreeLibrary(graphics_driver);
+}
+
/***********************************************************************
* UserClientDllInitialize (USER32.@)
*
@@ -251,6 +260,9 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWO
user32_module = inst;
ret = process_attach();
break;
+ case DLL_PROCESS_DETACH:
+ process_detach();
+ break;
case DLL_THREAD_DETACH:
thread_detach();
break;
diff -u cvs/hq/wine/windows/cursoricon.c wine/windows/cursoricon.c
--- cvs/hq/wine/windows/cursoricon.c 2004-09-28 13:35:36.000000000 +0900
+++ wine/windows/cursoricon.c 2004-10-17 20:13:32.000000000 +0900
@@ -1479,7 +1479,7 @@ HCURSOR WINAPI SetCursor( HCURSOR hCurso
hOldCursor = queue->cursor;
queue->cursor = hCursor;
/* Change the cursor shape only if it is visible */
- if (queue->cursor_count >= 0)
+ if (queue->cursor_count >= 0 && USER_Driver.pSetCursor)
{
USER_Driver.pSetCursor( (CURSORICONINFO*)GlobalLock16(HCURSOR_16(hCursor)) );
GlobalUnlock16(HCURSOR_16(hCursor));
@@ -1498,7 +1498,7 @@ INT WINAPI ShowCursor( BOOL bShow )
if (bShow)
{
- if (++queue->cursor_count == 0) /* Show it */
+ if (++queue->cursor_count == 0 && USER_Driver.pSetCursor) /* Show it */
{
USER_Driver.pSetCursor((CURSORICONINFO*)GlobalLock16(HCURSOR_16(queue->cursor)));
GlobalUnlock16(HCURSOR_16(queue->cursor));
@@ -1506,7 +1506,7 @@ INT WINAPI ShowCursor( BOOL bShow )
}
else
{
- if (--queue->cursor_count == -1) /* Hide it */
+ if (--queue->cursor_count == -1 && USER_Driver.pSetCursor) /* Hide it */
USER_Driver.pSetCursor( NULL );
}
return queue->cursor_count;
diff -u cvs/hq/wine/windows/dce.c wine/windows/dce.c
--- cvs/hq/wine/windows/dce.c 2004-09-14 12:51:46.000000000 +0900
+++ wine/windows/dce.c 2004-10-17 20:17:02.000000000 +0900
@@ -521,7 +521,8 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgn
if (bUpdateVisRgn) SetHookFlags16( HDC_16(hdc), DCHF_INVALIDATEVISRGN ); /* force update */
- if (!USER_Driver.pGetDC( hwnd, hdc, hrgnClip, flags )) hdc = 0;
+ if (!USER_Driver.pGetDC || !USER_Driver.pGetDC( hwnd, hdc, hrgnClip, flags ))
+ hdc = 0;
TRACE("(%p,%p,0x%lx): returning %p\n", hwnd, hrgnClip, flags, hdc);
END:
@@ -619,7 +620,8 @@ BOOL16 WINAPI DCHook16( HDC16 hDC, WORD
/* Dirty bit has been cleared by caller, set it again so that
* pGetDC recomputes the visible region. */
SetHookFlags16( hDC, DCHF_INVALIDATEVISRGN );
- USER_Driver.pGetDC( dce->hwndCurrent, dce->hDC, dce->hClipRgn, dce->DCXflags );
+ if (USER_Driver.pGetDC)
+ USER_Driver.pGetDC( dce->hwndCurrent, dce->hDC, dce->hClipRgn, dce->DCXflags );
}
else /* non-fatal but shouldn't happen */
WARN("DC is not in use!\n");
diff -u cvs/hq/wine/windows/sysparams.c wine/windows/sysparams.c
--- cvs/hq/wine/windows/sysparams.c 2004-10-17 20:09:59.000000000 +0900
+++ wine/windows/sysparams.c 2004-10-17 20:19:03.000000000 +0900
@@ -875,7 +875,10 @@ BOOL WINAPI SystemParametersInfoW( UINT
case SPI_GETSCREENSAVEACTIVE: /* 16 */
if (!pvParam) return FALSE;
- *(BOOL *)pvParam = USER_Driver.pGetScreenSaveActive();
+ if (USER_Driver.pGetScreenSaveActive)
+ *(BOOL *)pvParam = USER_Driver.pGetScreenSaveActive();
+ else
+ *(BOOL *)pvParam = FALSE;
break;
case SPI_SETSCREENSAVEACTIVE: /* 17 */
@@ -883,7 +886,8 @@ BOOL WINAPI SystemParametersInfoW( UINT
WCHAR buf[5];
wsprintfW(buf, CSu, uiParam);
- USER_Driver.pSetScreenSaveActive( uiParam );
+ if (USER_Driver.pSetScreenSaveActive)
+ USER_Driver.pSetScreenSaveActive( uiParam );
/* saved value does not affect Wine */
SYSPARAMS_Save( SPI_SETSCREENSAVEACTIVE_REGKEY,
SPI_SETSCREENSAVEACTIVE_VALNAME,
diff -u cvs/hq/wine/windows/win.c wine/windows/win.c
--- cvs/hq/wine/windows/win.c 2004-09-23 20:12:00.000000000 +0900
+++ wine/windows/win.c 2004-10-17 20:22:50.000000000 +0900
@@ -649,7 +649,7 @@ LRESULT WIN_DestroyWindow( HWND hwnd )
wndPtr->hSysMenu = 0;
}
DCE_FreeWindowDCE( hwnd ); /* Always do this to catch orphaned DCs */
- USER_Driver.pDestroyWindow( hwnd );
+ if (USER_Driver.pDestroyWindow) USER_Driver.pDestroyWindow( hwnd );
WINPROC_FreeProc( wndPtr->winproc, WIN_PROC_WINDOW );
wndPtr->class = NULL;
wndPtr->dwMagic = 0; /* Mark it as invalid */
@@ -735,7 +735,7 @@ BOOL WIN_CreateDesktopWindow(void)
}
SERVER_END_REQ;
- if (!USER_Driver.pCreateWindow( hwndDesktop, &cs, FALSE ))
+ if (!USER_Driver.pCreateWindow || !USER_Driver.pCreateWindow( hwndDesktop, &cs, FALSE ))
{
WIN_ReleaseWndPtr( pWndDesktop );
return FALSE;
@@ -1168,7 +1168,7 @@ static HWND WIN_CreateWindowEx( CREATEST
else SetWindowLongPtrW( hwnd, GWLP_ID, (ULONG_PTR)cs->hMenu );
WIN_ReleaseWndPtr( wndPtr );
- if (!USER_Driver.pCreateWindow( hwnd, cs, unicode))
+ if (!USER_Driver.pCreateWindow || !USER_Driver.pCreateWindow( hwnd, cs, unicode))
{
WIN_DestroyWindow( hwnd );
return 0;
diff -u cvs/hq/wine/windows/winpos.c wine/windows/winpos.c
--- cvs/hq/wine/windows/winpos.c 2004-09-20 14:26:54.000000000 +0900
+++ wine/windows/winpos.c 2004-10-17 20:22:14.000000000 +0900
@@ -829,7 +829,11 @@ BOOL WINAPI ShowWindowAsync( HWND hwnd,
}
if ((full_handle = WIN_IsCurrentThread( hwnd )))
- return USER_Driver.pShowWindow( full_handle, cmd );
+ {
+ if (USER_Driver.pShowWindow)
+ return USER_Driver.pShowWindow( full_handle, cmd );
+ return FALSE;
+ }
return SendNotifyMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 );
}
@@ -1207,7 +1211,12 @@ BOOL WINAPI SetWindowPos( HWND hwnd, HWN
winpos.cx = cx;
winpos.cy = cy;
winpos.flags = flags;
- if (WIN_IsCurrentThread( hwnd )) return USER_Driver.pSetWindowPos( &winpos );
+ if (WIN_IsCurrentThread( hwnd ))
+ {
+ if (USER_Driver.pSetWindowPos)
+ return USER_Driver.pSetWindowPos( &winpos );
+ return FALSE;
+ }
return SendMessageW( winpos.hwnd, WM_WINE_SETWINDOWPOS, 0, (LPARAM)&winpos );
}
@@ -1337,7 +1346,7 @@ BOOL WINAPI EndDeferWindowPos( HDWP hdwp
if (!pDWP) return FALSE;
for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
{
- if (!(res = USER_Driver.pSetWindowPos( winpos ))) break;
+ if (!USER_Driver.pSetWindowPos || !(res = USER_Driver.pSetWindowPos( winpos ))) break;
}
USER_HEAP_FREE( hdwp );
return res;
More information about the wine-patches
mailing list