winmm: driver unloading.

- properly handle drivers unloading when no session instance of the
  driver has been created
This commit is contained in:
Eric Pouech 2005-12-05 12:01:26 +01:00 committed by Alexandre Julliard
parent 34db4856ae
commit 60884fc3b3
2 changed files with 11 additions and 4 deletions

View File

@ -291,6 +291,7 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2)
cause = "load1 failed";
goto exit;
}
lpDrv->dwFlags |= WINE_GDF_SESSION;
return ret;
}
@ -416,8 +417,11 @@ LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
{
LPWINE_DRIVER lpDrv0;
if (lpDrv->dwFlags & WINE_GDF_SESSION)
FIXME("Shouldn't happen (%p)\n", lpDrv);
/* if driver has an opened session instance, we have to close it too */
if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, &lpDrv0) == 1)
if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, &lpDrv0) == 1 &&
(lpDrv0->dwFlags & WINE_GDF_SESSION))
{
DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0L, 0L);
lpDrv0->d.d32.dwDriverID = 0;
@ -456,7 +460,7 @@ DWORD WINAPI GetDriverFlags(HDRVR hDrvr)
TRACE("(%p)\n", hDrvr);
if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
ret = WINE_GDF_EXIST | lpDrv->dwFlags;
ret = WINE_GDF_EXIST | (lpDrv->dwFlags & WINE_GDF_EXTERNAL_MASK);
}
return ret;
}

View File

@ -306,8 +306,11 @@ extern unsigned (*pFnLoadMMDrvFunc16)(LPCSTR,LPWINE_DRIVER, LPWINE_MM_DR
extern LRESULT (*pFnMmioCallback16)(DWORD,LPMMIOINFO,UINT,LPARAM,LPARAM);
extern void (WINAPI *pFnReleaseThunkLock)(DWORD*);
extern void (WINAPI *pFnRestoreThunkLock)(DWORD);
/* GetDriverFlags() returned bits is not documented (nor the call itself)
* Here are Wine only definitions of the bits
*/
#define WINE_GDF_EXIST 0x80000000
#define WINE_GDF_16BIT 0x10000000
#define WINE_GDF_EXIST 0x80000000
#define WINE_GDF_16BIT 0x10000000
#define WINE_GDF_EXTERNAL_MASK 0xF0000000
#define WINE_GDF_SESSION 0x00000001