Commit 5736111c authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Protect USER32 against early graphics driver unloading.

parent 134560e9
...@@ -52,7 +52,7 @@ WORD WINAPI DISPLAY_Inquire(LPCURSORINFO16 lpCursorInfo) ...@@ -52,7 +52,7 @@ WORD WINAPI DISPLAY_Inquire(LPCURSORINFO16 lpCursorInfo)
*/ */
VOID WINAPI DISPLAY_SetCursor( struct tagCURSORICONINFO *lpCursor ) 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 tagCURSORICONINFO *lpCursor ) ...@@ -60,7 +60,7 @@ VOID WINAPI DISPLAY_SetCursor( struct tagCURSORICONINFO *lpCursor )
*/ */
VOID WINAPI DISPLAY_MoveCursor( WORD wAbsX, WORD wAbsY ) VOID WINAPI DISPLAY_MoveCursor( WORD wAbsX, WORD wAbsY )
{ {
USER_Driver.pSetCursorPos(wAbsX, wAbsY); if (USER_Driver.pSetCursorPos) USER_Driver.pSetCursorPos(wAbsX, wAbsY);
} }
/*********************************************************************** /***********************************************************************
......
...@@ -1112,7 +1112,9 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR ...@@ -1112,7 +1112,9 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR
case WM_WINE_DESTROYWINDOW: case WM_WINE_DESTROYWINDOW:
return WIN_DestroyWindow( hwnd ); return WIN_DestroyWindow( hwnd );
case WM_WINE_SETWINDOWPOS: 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: case WM_WINE_SHOWWINDOW:
return ShowWindow( hwnd, wparam ); return ShowWindow( hwnd, wparam );
case WM_WINE_SETPARENT: case WM_WINE_SETPARENT:
...@@ -2411,7 +2413,7 @@ BOOL WINAPI MessageBeep( UINT i ) ...@@ -2411,7 +2413,7 @@ BOOL WINAPI MessageBeep( UINT i )
{ {
BOOL active = TRUE; BOOL active = TRUE;
SystemParametersInfoA( SPI_GETBEEP, 0, &active, FALSE ); SystemParametersInfoA( SPI_GETBEEP, 0, &active, FALSE );
if (active) USER_Driver.pBeep(); if (active && USER_Driver.pBeep) USER_Driver.pBeep();
return TRUE; return TRUE;
} }
......
...@@ -237,6 +237,15 @@ static void thread_detach(void) ...@@ -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.@) * UserClientDllInitialize (USER32.@)
* *
...@@ -251,6 +260,9 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) ...@@ -251,6 +260,9 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
user32_module = inst; user32_module = inst;
ret = process_attach(); ret = process_attach();
break; break;
case DLL_PROCESS_DETACH:
process_detach();
break;
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
thread_detach(); thread_detach();
break; break;
......
...@@ -1479,7 +1479,7 @@ HCURSOR WINAPI SetCursor( HCURSOR hCursor /* [in] Handle of cursor to show */ ) ...@@ -1479,7 +1479,7 @@ HCURSOR WINAPI SetCursor( HCURSOR hCursor /* [in] Handle of cursor to show */ )
hOldCursor = queue->cursor; hOldCursor = queue->cursor;
queue->cursor = hCursor; queue->cursor = hCursor;
/* Change the cursor shape only if it is visible */ /* 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)) ); USER_Driver.pSetCursor( (CURSORICONINFO*)GlobalLock16(HCURSOR_16(hCursor)) );
GlobalUnlock16(HCURSOR_16(hCursor)); GlobalUnlock16(HCURSOR_16(hCursor));
...@@ -1498,7 +1498,7 @@ INT WINAPI ShowCursor( BOOL bShow ) ...@@ -1498,7 +1498,7 @@ INT WINAPI ShowCursor( BOOL bShow )
if (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))); USER_Driver.pSetCursor((CURSORICONINFO*)GlobalLock16(HCURSOR_16(queue->cursor)));
GlobalUnlock16(HCURSOR_16(queue->cursor)); GlobalUnlock16(HCURSOR_16(queue->cursor));
...@@ -1506,7 +1506,7 @@ INT WINAPI ShowCursor( BOOL bShow ) ...@@ -1506,7 +1506,7 @@ INT WINAPI ShowCursor( BOOL bShow )
} }
else else
{ {
if (--queue->cursor_count == -1) /* Hide it */ if (--queue->cursor_count == -1 && USER_Driver.pSetCursor) /* Hide it */
USER_Driver.pSetCursor( NULL ); USER_Driver.pSetCursor( NULL );
} }
return queue->cursor_count; return queue->cursor_count;
......
...@@ -521,7 +521,8 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) ...@@ -521,7 +521,8 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
if (bUpdateVisRgn) SetHookFlags16( HDC_16(hdc), DCHF_INVALIDATEVISRGN ); /* force update */ 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); TRACE("(%p,%p,0x%lx): returning %p\n", hwnd, hrgnClip, flags, hdc);
END: END:
...@@ -619,7 +620,8 @@ BOOL16 WINAPI DCHook16( HDC16 hDC, WORD code, DWORD data, LPARAM lParam ) ...@@ -619,7 +620,8 @@ BOOL16 WINAPI DCHook16( HDC16 hDC, WORD code, DWORD data, LPARAM lParam )
/* Dirty bit has been cleared by caller, set it again so that /* Dirty bit has been cleared by caller, set it again so that
* pGetDC recomputes the visible region. */ * pGetDC recomputes the visible region. */
SetHookFlags16( hDC, DCHF_INVALIDATEVISRGN ); 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 */ else /* non-fatal but shouldn't happen */
WARN("DC is not in use!\n"); WARN("DC is not in use!\n");
......
...@@ -875,7 +875,10 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam, ...@@ -875,7 +875,10 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
case SPI_GETSCREENSAVEACTIVE: /* 16 */ case SPI_GETSCREENSAVEACTIVE: /* 16 */
if (!pvParam) return FALSE; if (!pvParam) return FALSE;
*(BOOL *)pvParam = USER_Driver.pGetScreenSaveActive(); if (USER_Driver.pGetScreenSaveActive)
*(BOOL *)pvParam = USER_Driver.pGetScreenSaveActive();
else
*(BOOL *)pvParam = FALSE;
break; break;
case SPI_SETSCREENSAVEACTIVE: /* 17 */ case SPI_SETSCREENSAVEACTIVE: /* 17 */
...@@ -883,7 +886,8 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam, ...@@ -883,7 +886,8 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
WCHAR buf[5]; WCHAR buf[5];
wsprintfW(buf, CSu, uiParam); wsprintfW(buf, CSu, uiParam);
USER_Driver.pSetScreenSaveActive( uiParam ); if (USER_Driver.pSetScreenSaveActive)
USER_Driver.pSetScreenSaveActive( uiParam );
/* saved value does not affect Wine */ /* saved value does not affect Wine */
SYSPARAMS_Save( SPI_SETSCREENSAVEACTIVE_REGKEY, SYSPARAMS_Save( SPI_SETSCREENSAVEACTIVE_REGKEY,
SPI_SETSCREENSAVEACTIVE_VALNAME, SPI_SETSCREENSAVEACTIVE_VALNAME,
......
...@@ -649,7 +649,7 @@ LRESULT WIN_DestroyWindow( HWND hwnd ) ...@@ -649,7 +649,7 @@ LRESULT WIN_DestroyWindow( HWND hwnd )
wndPtr->hSysMenu = 0; wndPtr->hSysMenu = 0;
} }
DCE_FreeWindowDCE( hwnd ); /* Always do this to catch orphaned DCs */ 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 ); WINPROC_FreeProc( wndPtr->winproc, WIN_PROC_WINDOW );
wndPtr->class = NULL; wndPtr->class = NULL;
wndPtr->dwMagic = 0; /* Mark it as invalid */ wndPtr->dwMagic = 0; /* Mark it as invalid */
...@@ -735,7 +735,7 @@ BOOL WIN_CreateDesktopWindow(void) ...@@ -735,7 +735,7 @@ BOOL WIN_CreateDesktopWindow(void)
} }
SERVER_END_REQ; SERVER_END_REQ;
if (!USER_Driver.pCreateWindow( hwndDesktop, &cs, FALSE )) if (!USER_Driver.pCreateWindow || !USER_Driver.pCreateWindow( hwndDesktop, &cs, FALSE ))
{ {
WIN_ReleaseWndPtr( pWndDesktop ); WIN_ReleaseWndPtr( pWndDesktop );
return FALSE; return FALSE;
...@@ -1168,7 +1168,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom, ...@@ -1168,7 +1168,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
else SetWindowLongPtrW( hwnd, GWLP_ID, (ULONG_PTR)cs->hMenu ); else SetWindowLongPtrW( hwnd, GWLP_ID, (ULONG_PTR)cs->hMenu );
WIN_ReleaseWndPtr( wndPtr ); WIN_ReleaseWndPtr( wndPtr );
if (!USER_Driver.pCreateWindow( hwnd, cs, unicode)) if (!USER_Driver.pCreateWindow || !USER_Driver.pCreateWindow( hwnd, cs, unicode))
{ {
WIN_DestroyWindow( hwnd ); WIN_DestroyWindow( hwnd );
return 0; return 0;
......
...@@ -829,7 +829,11 @@ BOOL WINAPI ShowWindowAsync( HWND hwnd, INT cmd ) ...@@ -829,7 +829,11 @@ BOOL WINAPI ShowWindowAsync( HWND hwnd, INT cmd )
} }
if ((full_handle = WIN_IsCurrentThread( 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 ); return SendNotifyMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 );
} }
...@@ -1207,7 +1211,12 @@ BOOL WINAPI SetWindowPos( HWND hwnd, HWND hwndInsertAfter, ...@@ -1207,7 +1211,12 @@ BOOL WINAPI SetWindowPos( HWND hwnd, HWND hwndInsertAfter,
winpos.cx = cx; winpos.cx = cx;
winpos.cy = cy; winpos.cy = cy;
winpos.flags = flags; 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 ); return SendMessageW( winpos.hwnd, WM_WINE_SETWINDOWPOS, 0, (LPARAM)&winpos );
} }
...@@ -1337,7 +1346,7 @@ BOOL WINAPI EndDeferWindowPos( HDWP hdwp ) ...@@ -1337,7 +1346,7 @@ BOOL WINAPI EndDeferWindowPos( HDWP hdwp )
if (!pDWP) return FALSE; if (!pDWP) return FALSE;
for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++) 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 ); USER_HEAP_FREE( hdwp );
return res; return res;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment