Protect USER32 against early graphics driver unloading.

This commit is contained in:
Dmitry Timoshkov 2004-10-18 21:25:26 +00:00 committed by Alexandre Julliard
parent 134560e9e5
commit 5736111c83
8 changed files with 46 additions and 17 deletions

View File

@ -52,7 +52,7 @@ WORD WINAPI DISPLAY_Inquire(LPCURSORINFO16 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 tagCURSORICONINFO *lpCursor )
*/
VOID WINAPI DISPLAY_MoveCursor( WORD wAbsX, WORD wAbsY )
{
USER_Driver.pSetCursorPos(wAbsX, wAbsY);
if (USER_Driver.pSetCursorPos) USER_Driver.pSetCursorPos(wAbsX, wAbsY);
}
/***********************************************************************

View File

@ -1112,7 +1112,9 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR
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;
}

View File

@ -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, DWORD reason, LPVOID reserved )
user32_module = inst;
ret = process_attach();
break;
case DLL_PROCESS_DETACH:
process_detach();
break;
case DLL_THREAD_DETACH:
thread_detach();
break;

View File

@ -1479,7 +1479,7 @@ HCURSOR WINAPI SetCursor( HCURSOR hCursor /* [in] Handle of cursor to show */ )
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;

View File

@ -521,7 +521,8 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
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 code, DWORD data, LPARAM lParam )
/* 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");

View File

@ -875,7 +875,10 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
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 uiAction, UINT uiParam,
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,

View File

@ -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( CREATESTRUCTA *cs, ATOM classAtom,
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;

View File

@ -829,7 +829,11 @@ BOOL WINAPI ShowWindowAsync( HWND hwnd, INT cmd )
}
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, HWND hwndInsertAfter,
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;