Merge pull request #315 from maharmstone/master (works around Wine Staging bug 199)

Various Windows apps (like Max Payne 2) seem to contain a broken eax.dll library,
which is affected by various use-after-free bugs. To work around such issues EAX
support can be globally disabled in winecfg. Moreover a winediag message is added
to inform the user about possible issues related to EAX.
This commit is contained in:
Sebastian Lackner 2015-04-05 20:11:34 +02:00
commit 8b06b71275
4 changed files with 256 additions and 1 deletions

1
debian/changelog vendored
View File

@ -1,5 +1,6 @@
wine-staging (1.7.41) UNRELEASED; urgency=low
* Disable DXVA2 controls in winecfg when support is not compiled in.
* Added patch to enable/disable EAX support via winecfg.
* Partially remove advapi32-Revert_DACL patches.
-- Sebastian Lackner <sebastian@fds-team.de> Sun, 05 Apr 2015 03:11:58 +0200

View File

@ -0,0 +1,169 @@
From 937d52434c44a50628f5b96b4e08a8e24f6df62b Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 5 Apr 2015 19:13:18 +0200
Subject: dsound: Allow disabling of EAX support in the registry.
Based on a patch by Mark Harmstone.
---
dlls/dsound/buffer.c | 16 ++++++----------
dlls/dsound/dsound_main.c | 10 ++++++++--
dlls/dsound/dsound_private.h | 2 ++
dlls/dsound/eax.c | 28 ++++++++++++++++++++++++++++
4 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index 3641e32..ca6a5b5 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -35,6 +35,7 @@
#include "dsconf.h"
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
+WINE_DECLARE_DEBUG_CHANNEL(winediag);
/*******************************************************************************
* IDirectSoundNotify
@@ -1331,16 +1332,11 @@ static HRESULT WINAPI IKsPropertySetImpl_QuerySupport(IKsPropertySet *iface, REF
TRACE("(%p,%s,%d,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
- if (IsEqualGUID(&DSPROPSETID_EAX_ReverbProperties, guidPropSet)) {
- if (dwPropID <= DSPROPERTY_EAX_DAMPING) {
- *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
- return S_OK;
- }
- } else if (IsEqualGUID(&DSPROPSETID_EAXBUFFER_ReverbProperties, guidPropSet)) {
- if (dwPropID <= DSPROPERTY_EAXBUFFER_REVERBMIX) {
- *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
- return S_OK;
- }
+ if (EAX_QuerySupport(guidPropSet, dwPropID, pTypeSupport)) {
+ static int once;
+ if (!once++)
+ FIXME_(winediag)("EAX sound effects are enabled - try to disable it if your app crashes unexpectedly\n");
+ return S_OK;
}
return E_PROP_ID_UNSUPPORTED;
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c
index 1f512a4..4b45528 100644
--- a/dlls/dsound/dsound_main.c
+++ b/dlls/dsound/dsound_main.c
@@ -95,8 +95,12 @@ WCHAR wine_vxd_drv[] = { 'w','i','n','e','m','m','.','v','x','d', 0 };
int ds_hel_buflen = 32768 * 2;
int ds_snd_queue_max = 10;
int ds_hq_buffers_max = 4;
+BOOL ds_eax_enabled = TRUE;
static HINSTANCE instance;
+#define IS_OPTION_TRUE(ch) \
+ ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
+
/*
* Get a config key from either the app-specific or the default config
*/
@@ -109,7 +113,6 @@ static inline DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
return ERROR_FILE_NOT_FOUND;
}
-
/*
* Setup the dsound options.
*/
@@ -150,16 +153,19 @@ void setup_dsound_options(void)
if (!get_config_key( hkey, appkey, "SndQueueMax", buffer, MAX_PATH ))
ds_snd_queue_max = atoi(buffer);
-
if (!get_config_key( hkey, appkey, "HQBuffersMax", buffer, MAX_PATH ))
ds_hq_buffers_max = atoi(buffer);
+ if (!get_config_key( hkey, appkey, "EAXEnabled", buffer, MAX_PATH ))
+ ds_eax_enabled = IS_OPTION_TRUE( buffer[0] );
+
if (appkey) RegCloseKey( appkey );
if (hkey) RegCloseKey( hkey );
TRACE("ds_hel_buflen = %d\n", ds_hel_buflen);
TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max);
TRACE("ds_hq_buffers_max = %d\n", ds_hq_buffers_max);
+ TRACE("ds_eax_enabled = %u\n", ds_eax_enabled);
}
static const char * get_device_id(LPCGUID pGuid)
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index a9987d0..5c21d1f 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -38,6 +38,7 @@
extern int ds_hel_buflen DECLSPEC_HIDDEN;
extern int ds_snd_queue_max DECLSPEC_HIDDEN;
extern int ds_hq_buffers_max DECLSPEC_HIDDEN;
+extern BOOL ds_eax_enabled DECLSPEC_HIDDEN;
/*****************************************************************************
* Predeclare the interface implementation structures
@@ -234,6 +235,7 @@ LONG capped_refcount_dec(LONG *ref) DECLSPEC_HIDDEN;
HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
/* eax.c */
+BOOL WINAPI EAX_QuerySupport(REFGUID guidPropSet, ULONG dwPropID, ULONG *pTypeSupport) DECLSPEC_HIDDEN;
HRESULT WINAPI EAX_Get(IDirectSoundBufferImpl *buf, REFGUID guidPropSet,
ULONG dwPropID, void *pInstanceData, ULONG cbInstanceData, void *pPropData,
ULONG cbPropData, ULONG *pcbReturned) DECLSPEC_HIDDEN;
diff --git a/dlls/dsound/eax.c b/dlls/dsound/eax.c
index 4e98812..c9d5b6c 100644
--- a/dlls/dsound/eax.c
+++ b/dlls/dsound/eax.c
@@ -809,6 +809,28 @@ void free_eax_buffer(IDirectSoundBufferImpl *dsb)
HeapFree(GetProcessHeap(), 0, dsb->eax.SampleBuffer);
}
+BOOL WINAPI EAX_QuerySupport(REFGUID guidPropSet, ULONG dwPropID, ULONG *pTypeSupport)
+{
+ TRACE("(%s,%d,%p)\n", debugstr_guid(guidPropSet), dwPropID, pTypeSupport);
+
+ if (!ds_eax_enabled)
+ return FALSE;
+
+ if (IsEqualGUID(&DSPROPSETID_EAX_ReverbProperties, guidPropSet)) {
+ if (dwPropID <= DSPROPERTY_EAX_DAMPING) {
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
+ return TRUE;
+ }
+ } else if (IsEqualGUID(&DSPROPSETID_EAXBUFFER_ReverbProperties, guidPropSet)) {
+ if (dwPropID <= DSPROPERTY_EAXBUFFER_REVERBMIX) {
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
HRESULT WINAPI EAX_Get(IDirectSoundBufferImpl *buf, REFGUID guidPropSet,
ULONG dwPropID, void *pInstanceData, ULONG cbInstanceData, void *pPropData,
ULONG cbPropData, ULONG *pcbReturned)
@@ -816,6 +838,9 @@ HRESULT WINAPI EAX_Get(IDirectSoundBufferImpl *buf, REFGUID guidPropSet,
TRACE("(buf=%p,guidPropSet=%s,dwPropID=%d,pInstanceData=%p,cbInstanceData=%d,pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
buf, debugstr_guid(guidPropSet), dwPropID, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned);
+ if (!ds_eax_enabled)
+ return E_PROP_ID_UNSUPPORTED;
+
*pcbReturned = 0;
if (IsEqualGUID(&DSPROPSETID_EAX_ReverbProperties, guidPropSet)) {
@@ -922,6 +947,9 @@ HRESULT WINAPI EAX_Set(IDirectSoundBufferImpl *buf, REFGUID guidPropSet,
TRACE("(%p,%s,%d,%p,%d,%p,%d)\n",
buf, debugstr_guid(guidPropSet), dwPropID, pInstanceData, cbInstanceData, pPropData, cbPropData);
+ if (!ds_eax_enabled)
+ return E_PROP_ID_UNSUPPORTED;
+
if (IsEqualGUID(&DSPROPSETID_EAX_ReverbProperties, guidPropSet)) {
buf->device->eax.using_eax = TRUE;
--
2.3.5

View File

@ -1910,7 +1910,7 @@ fi
# |
# | Modified files:
# | * dlls/dsound/Makefile.in, dlls/dsound/buffer.c, dlls/dsound/dsound.c, dlls/dsound/dsound_eax.h,
# | dlls/dsound/dsound_private.h, dlls/dsound/eax.c, dlls/dsound/mixer.c
# | dlls/dsound/dsound_main.c, dlls/dsound/dsound_private.h, dlls/dsound/eax.c, dlls/dsound/mixer.c
# |
if test "$enable_dsound_EAX" -eq 1; then
patch_apply dsound-EAX/0001-dsound-Apply-filters-before-sound-is-multiplied-to-s.patch
@ -1931,6 +1931,7 @@ if test "$enable_dsound_EAX" -eq 1; then
patch_apply dsound-EAX/0016-dsound-Implement-EAX-late-reverb.patch
patch_apply dsound-EAX/0017-dsound-Implement-EAX-late-all-pass-filter.patch
patch_apply dsound-EAX/0018-dsound-Various-improvements-to-EAX-support.patch
patch_apply dsound-EAX/0019-dsound-Allow-disabling-of-EAX-support-in-the-registr.patch
(
echo '+ { "Sebastian Lackner", "dsound: Apply filters before sound is multiplied to speakers.", 1 },';
echo '+ { "Mark Harmstone", "dsound: Add EAX v1 constants and structs.", 1 },';
@ -1950,6 +1951,7 @@ if test "$enable_dsound_EAX" -eq 1; then
echo '+ { "Mark Harmstone", "dsound: Implement EAX late reverb.", 1 },';
echo '+ { "Mark Harmstone", "dsound: Implement EAX late all-pass filter.", 1 },';
echo '+ { "Sebastian Lackner", "dsound: Various improvements to EAX support.", 1 },';
echo '+ { "Sebastian Lackner", "dsound: Allow disabling of EAX support in the registry.", 1 },';
) >> "$patchlist"
fi
@ -2478,9 +2480,11 @@ fi
if test "$enable_winecfg_Staging" -eq 1; then
patch_apply winecfg-Staging/0001-winecfg-Add-staging-tab-for-CSMT.patch
patch_apply winecfg-Staging/0002-winecfg-Add-checkbox-to-enable-disable-vaapi-GPU-dec.patch
patch_apply winecfg-Staging/0003-winecfg-Add-checkbox-to-enable-disable-EAX-support.patch
(
echo '+ { "Michael Müller", "winecfg: Add staging tab for CSMT.", 1 },';
echo '+ { "Sebastian Lackner", "winecfg: Add checkbox to enable/disable vaapi GPU decoder.", 1 },';
echo '+ { "Mark Harmstone", "winecfg: Add checkbox to enable/disable EAX support.", 1 },';
) >> "$patchlist"
fi

View File

@ -0,0 +1,81 @@
From b31377088e643b14e75df6bd302299d35587998e Mon Sep 17 00:00:00 2001
From: Mark Harmstone <mark@harmstone.com>
Date: Sun, 5 Apr 2015 14:16:11 +0100
Subject: winecfg: Add checkbox to enable/disable EAX support.
---
programs/winecfg/resource.h | 1 +
programs/winecfg/staging.c | 21 +++++++++++++++++++++
programs/winecfg/winecfg.rc | 1 +
3 files changed, 23 insertions(+)
diff --git a/programs/winecfg/resource.h b/programs/winecfg/resource.h
index 4b21d16..a78d9af 100644
--- a/programs/winecfg/resource.h
+++ b/programs/winecfg/resource.h
@@ -213,6 +213,7 @@
/* Staging tab */
#define IDC_ENABLE_CSMT 9001
#define IDC_ENABLE_VAAPI 9002
+#define IDC_ENABLE_EAX 9003
/* About tab */
#define IDC_ABT_OWNER 8432
diff --git a/programs/winecfg/staging.c b/programs/winecfg/staging.c
index 40b6642..ee09855 100644
--- a/programs/winecfg/staging.c
+++ b/programs/winecfg/staging.c
@@ -71,10 +71,27 @@ static void vaapi_set(BOOL status)
#endif
}
+/*
+ * EAX
+ */
+static BOOL eax_get(void)
+{
+ BOOL ret;
+ char *value = get_reg_key(config_key, keypath("DirectSound"), "EAXEnabled", "Y");
+ ret = IS_OPTION_TRUE(*value);
+ HeapFree(GetProcessHeap(), 0, value);
+ return ret;
+}
+static void eax_set(BOOL status)
+{
+ set_reg_key(config_key, keypath("DirectSound"), "EAXEnabled", status ? "Y" : "N");
+}
+
static void load_staging_settings(HWND dialog)
{
CheckDlgButton(dialog, IDC_ENABLE_CSMT, csmt_get() ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(dialog, IDC_ENABLE_VAAPI, vaapi_get() ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(dialog, IDC_ENABLE_EAX, eax_get() ? BST_CHECKED : BST_UNCHECKED);
#ifndef HAVE_VAAPI
disable(IDC_ENABLE_VAAPI);
@@ -112,6 +129,10 @@ INT_PTR CALLBACK StagingDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
vaapi_set(IsDlgButtonChecked(hDlg, IDC_ENABLE_VAAPI) == BST_CHECKED);
SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
return TRUE;
+ case IDC_ENABLE_EAX:
+ eax_set(IsDlgButtonChecked(hDlg, IDC_ENABLE_EAX) == BST_CHECKED);
+ SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
}
break;
}
diff --git a/programs/winecfg/winecfg.rc b/programs/winecfg/winecfg.rc
index 171672d..0f1af19 100644
--- a/programs/winecfg/winecfg.rc
+++ b/programs/winecfg/winecfg.rc
@@ -315,6 +315,7 @@ BEGIN
LTEXT "The following settings are experimental and may break stuff!\nMake sure to reset them again in case of a problem.",IDC_STATIC,16,16,230,16
CONTROL "Enable &CSMT for better graphic performance",IDC_ENABLE_CSMT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,40,230,8
CONTROL "Enable &VAAPI as backend for DXVA2 GPU decoding",IDC_ENABLE_VAAPI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,55,230,8
+ CONTROL "Enable Environmental Audio E&xtensions (EAX)",IDC_ENABLE_EAX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,70,230,8
END
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
--
2.3.5