Fixed a possible NULL-pointer access in DWMAPI wrapper code when DWM is not available.

This commit is contained in:
LoRd_MuldeR 2013-11-24 22:40:39 +01:00
parent 3d5b9541ed
commit 0bc1157906
3 changed files with 36 additions and 28 deletions

View File

@ -23,7 +23,6 @@
<file>images/Logo_GNU.png</file> <file>images/Logo_GNU.png</file>
<file>images/Logo_Software.png</file> <file>images/Logo_Software.png</file>
<file>images/Qt.svg</file> <file>images/Qt.svg</file>
<file>images/Splash.png</file>
<file>images/Sound.png</file> <file>images/Sound.png</file>
<file>images/Starting.png</file> <file>images/Starting.png</file>
<file>images/Thumb.png</file> <file>images/Thumb.png</file>

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 9 #define VER_LAMEXP_MINOR_LO 9
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 8 #define VER_LAMEXP_PATCH 8
#define VER_LAMEXP_BUILD 1470 #define VER_LAMEXP_BUILD 1472
#define VER_LAMEXP_CONFG 1348 #define VER_LAMEXP_CONFG 1348
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -173,10 +173,10 @@ g_lamexp_themes_enabled;
static struct static struct
{ {
bool bInitialized; bool bInitialized;
QLibrary *dwmapi_dll;
HRESULT (__stdcall *dwmIsCompositionEnabled)(BOOL *bEnabled); HRESULT (__stdcall *dwmIsCompositionEnabled)(BOOL *bEnabled);
HRESULT (__stdcall *dwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset); HRESULT (__stdcall *dwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset);
HRESULT (__stdcall *dwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind); HRESULT (__stdcall *dwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind);
QLibrary *dwmapi_dll;
QReadWriteLock lock; QReadWriteLock lock;
} }
g_lamexp_dwmapi; g_lamexp_dwmapi;
@ -1858,14 +1858,14 @@ bool lamexp_open_media_file(const QString &mediaFilePath)
return false; return false;
} }
static bool lamexp_init_dwmapi(void) static void lamexp_init_dwmapi(void)
{ {
QReadLocker writeLock(&g_lamexp_dwmapi.lock); QReadLocker writeLock(&g_lamexp_dwmapi.lock);
//Not initialized yet? //Not initialized yet?
if(g_lamexp_dwmapi.bInitialized) if(g_lamexp_dwmapi.bInitialized)
{ {
return (g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL); return;
} }
//Reset function pointers //Reset function pointers
@ -1893,7 +1893,6 @@ static bool lamexp_init_dwmapi(void)
} }
g_lamexp_dwmapi.bInitialized = true; g_lamexp_dwmapi.bInitialized = true;
return (g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL);
} }
/* /*
@ -1907,20 +1906,25 @@ bool lamexp_sheet_of_glass(QWidget *window)
while(!g_lamexp_dwmapi.bInitialized) while(!g_lamexp_dwmapi.bInitialized)
{ {
readLock.unlock(); readLock.unlock();
if(!lamexp_init_dwmapi()) return false; lamexp_init_dwmapi();
readLock.relock(); readLock.relock();
} }
//Check if composition is enabled BOOL bCompositionEnabled = FALSE;
BOOL bEnabled = FALSE;
if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bEnabled)) //Required functions available?
if((g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL) && (g_lamexp_dwmapi.dwmExtendFrameIntoClientArea != NULL) && (g_lamexp_dwmapi.dwmEnableBlurBehindWindow != NULL))
{ {
qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr); //Check if composition is currently enabled
return false; if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bCompositionEnabled))
{
qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr);
return false;
}
} }
//Composition enabled and required functions available? //All functions available *and* composition enabled?
if((!bEnabled) || (g_lamexp_dwmapi.dwmExtendFrameIntoClientArea == NULL) || (g_lamexp_dwmapi.dwmEnableBlurBehindWindow == NULL)) if(!bCompositionEnabled)
{ {
return false; return false;
} }
@ -1963,20 +1967,25 @@ bool lamexp_sheet_of_glass_update(QWidget *window)
while(!g_lamexp_dwmapi.bInitialized) while(!g_lamexp_dwmapi.bInitialized)
{ {
readLock.unlock(); readLock.unlock();
if(!lamexp_init_dwmapi()) return false; lamexp_init_dwmapi();
readLock.relock(); readLock.relock();
} }
//Check if composition is enabled BOOL bCompositionEnabled = FALSE;
BOOL bEnabled = FALSE;
if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bEnabled)) //Required functions available?
if((g_lamexp_dwmapi.dwmIsCompositionEnabled != NULL) && (g_lamexp_dwmapi.dwmEnableBlurBehindWindow != NULL))
{ {
qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr); //Check if composition is currently enabled
return false; if(HRESULT hr = g_lamexp_dwmapi.dwmIsCompositionEnabled(&bCompositionEnabled))
{
qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr);
return false;
}
} }
//Composition enabled and required functions available? //All functions available *and* composition enabled?
if((!bEnabled) || (g_lamexp_dwmapi.dwmEnableBlurBehindWindow == NULL)) if(!bCompositionEnabled)
{ {
return false; return false;
} }