From 60884fc3b33a152277a15568dcccd5abe99ac530 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 5 Dec 2005 12:01:26 +0100 Subject: [PATCH] winmm: driver unloading. - properly handle drivers unloading when no session instance of the driver has been created --- dlls/winmm/driver.c | 8 ++++++-- dlls/winmm/winemm.h | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dlls/winmm/driver.c b/dlls/winmm/driver.c index dabce422f31..717ba47eaa4 100644 --- a/dlls/winmm/driver.c +++ b/dlls/winmm/driver.c @@ -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; } diff --git a/dlls/winmm/winemm.h b/dlls/winmm/winemm.h index 47253590bbb..3295199662f 100644 --- a/dlls/winmm/winemm.h +++ b/dlls/winmm/winemm.h @@ -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