Fix Steam chat unable to select files.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
v2: Use bitmask of known values to check invalid options.
dlls/comdlg32/itemdlg.c | 10 ++++++++++
dlls/comdlg32/tests/itemdlg.c | 19 +++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c
index c8eff3438d..5f4c593ed7 100644
--- a/dlls/comdlg32/itemdlg.c
+++ b/dlls/comdlg32/itemdlg.c
@@ -2505,6 +2505,16 @@ static HRESULT WINAPI IFileDialog2_fnSetOptions(IFileDialog2 *iface, FILEOPENDIA
FileDialogImpl *This = impl_from_IFileDialog2(iface);
TRACE("%p (0x%x)\n", This, fos);
+ if (fos & ~(FOS_OVERWRITEPROMPT | FOS_STRICTFILETYPES | FOS_NOCHANGEDIR | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM
+ | FOS_ALLNONSTORAGEITEMS | FOS_NOVALIDATE | FOS_ALLOWMULTISELECT | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST
+ | FOS_CREATEPROMPT | FOS_SHAREAWARE | FOS_NOREADONLYRETURN | FOS_NOTESTFILECREATE | FOS_HIDEMRUPLACES
+ | FOS_HIDEPINNEDPLACES | FOS_NODEREFERENCELINKS | FOS_DONTADDTORECENT | FOS_FORCESHOWHIDDEN
+ | FOS_DEFAULTNOMINIMODE | FOS_FORCEPREVIEWPANEON | FOS_SUPPORTSTREAMABLEITEMS))
+ {
+ WARN("FILEOPENDIALOGOPTIONS 0x%08x contains unknown enums\n", fos);
+ return E_INVALIDARG;
+ }
+
if( !(This->options & FOS_PICKFOLDERS) && (fos & FOS_PICKFOLDERS) )
{
WCHAR buf[30];
diff --git a/dlls/comdlg32/tests/itemdlg.c b/dlls/comdlg32/tests/itemdlg.c
index d3be8c8d29..6b63063e29 100644
--- a/dlls/comdlg32/tests/itemdlg.c
+++ b/dlls/comdlg32/tests/itemdlg.c
@@ -536,6 +536,8 @@ static void test_basics(void)
const WCHAR fname2[] = {'f','n','a','m','e','2', 0};
const WCHAR fspec2[] = {'*','.','e','x','e',0};
COMDLG_FILTERSPEC filterspec[2] = {{fname1, fspec1}, {fname2, fspec2}};
+ const DWORD invalid_fos[] = {0x1, 0x10, 0x400, 0x80000, 0x400000, 0x800000, 0x1000000, 0x4000000, 0x8000000};
+ INT i;
/* This should work on every platform with IFileDialog */
SHGetDesktopFolder(&psfdesktop);
@@ -586,6 +588,23 @@ static void test_basics(void)
ok(fdoptions == (FOS_OVERWRITEPROMPT | FOS_NOREADONLYRETURN | FOS_PATHMUSTEXIST | FOS_NOCHANGEDIR),
"Unexpected default options: 0x%08x\n", fdoptions);
+ /* Check SetOptions invalid options handling */
+ for (i = 0; i < ARRAY_SIZE(invalid_fos); i++)
+ {
+ hr = IFileOpenDialog_SetOptions(pfod, invalid_fos[i]);
+ ok(hr == E_INVALIDARG, "got 0x%08x.\n", hr);
+ hr = IFileOpenDialog_GetOptions(pfod, &fdoptions);
+ ok(hr == S_OK, "got 0x%08x.\n", hr);
+ ok(fdoptions == (FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_NOCHANGEDIR), "got %08x\n", fdoptions);
+
+ hr = IFileSaveDialog_SetOptions(pfsd, invalid_fos[i]);
+ ok(hr == E_INVALIDARG, "got 0x%08x.\n", hr);
+ hr = IFileSaveDialog_GetOptions(pfsd, &fdoptions);
+ ok(hr == S_OK, "got 0x%08x.\n", hr);
+ ok(fdoptions == (FOS_OVERWRITEPROMPT | FOS_NOREADONLYRETURN | FOS_PATHMUSTEXIST | FOS_NOCHANGEDIR),
+ "got %08x\n", fdoptions);
+ }
+
/* GetResult */
hr = IFileOpenDialog_GetResult(pfod, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x.\n", hr);
--
2.18.0