Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/user32/sysparams.c | 33 +++++++++++++++++++++++---------- dlls/user32/tests/sysparams.c | 8 ++++---- 2 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index d4462e589e8..79f938a3c20 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -590,6 +590,21 @@ static BOOL get_primary_adapter(WCHAR *name) return FALSE; }
+static BOOL is_valid_adapter_name(const WCHAR *name) +{ + long int adapter_idx; + WCHAR *end; + + if (strncmpiW(name, ADAPTER_PREFIX, ARRAY_SIZE(ADAPTER_PREFIX))) + return FALSE; + + adapter_idx = strtolW(name + ARRAY_SIZE(ADAPTER_PREFIX), &end, 10); + if (*end || adapter_idx < 1) + return FALSE; + + return TRUE; +} + /* get text metrics and/or "average" char width of the specified logfont * for the specified dc */ static void get_text_metr_size( HDC hdc, LOGFONTW *plf, TEXTMETRICW * ptm, UINT *psz) @@ -3307,8 +3322,7 @@ static BOOL is_detached_mode(const DEVMODEW *mode) LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND hwnd, DWORD flags, LPVOID lparam ) { - WCHAR primary_adapter[CCHDEVICENAME], *end; - long int display_idx; + WCHAR primary_adapter[CCHDEVICENAME]; BOOL def_mode = TRUE; DEVMODEW dm; LONG ret; @@ -3332,14 +3346,7 @@ LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND devname = primary_adapter; }
- if (strncmpiW(devname, ADAPTER_PREFIX, ARRAY_SIZE(ADAPTER_PREFIX))) - { - ERR("Invalid device name %s.\n", wine_dbgstr_w(devname)); - return DISP_CHANGE_BADPARAM; - } - - display_idx = strtolW(devname + ARRAY_SIZE(ADAPTER_PREFIX), &end, 10); - if (*end || display_idx < 1) + if (!is_valid_adapter_name(devname)) { ERR("Invalid device name %s.\n", wine_dbgstr_w(devname)); return DISP_CHANGE_BADPARAM; @@ -3466,6 +3473,12 @@ BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum, lpszDeviceName = primary_adapter; }
+ if (!is_valid_adapter_name(lpszDeviceName)) + { + ERR("Invalid device name %s.\n", wine_dbgstr_w(lpszDeviceName)); + return FALSE; + } + ret = USER_Driver->pEnumDisplaySettingsEx(lpszDeviceName, iModeNum, lpDevMode, dwFlags); if (ret) TRACE("device:%s mode index:%#x position:(%d,%d) resolution:%ux%u frequency:%uHz " diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c index 6750325a291..f71b73930f2 100644 --- a/dlls/user32/tests/sysparams.c +++ b/dlls/user32/tests/sysparams.c @@ -3154,18 +3154,18 @@ static void test_EnumDisplaySettings(void) dm.dmSize = sizeof(dm); SetLastError(0xdeadbeef); ret = EnumDisplaySettingsA("invalid", ENUM_CURRENT_SETTINGS, &dm); - todo_wine ok(!ret, "EnumDisplaySettingsA succeeded\n"); + ok(!ret, "EnumDisplaySettingsA succeeded\n"); ok(GetLastError() == 0xdeadbeef, "Expect error 0xdeadbeef, got %#x\n", GetLastError()); - todo_wine ok(dm.dmFields == 0, "Expect dmFields unchanged, got %#x\n", dm.dmFields); + ok(dm.dmFields == 0, "Expect dmFields unchanged, got %#x\n", dm.dmFields);
/* Monitor device names are invalid */ memset(&dm, 0, sizeof(dm)); dm.dmSize = sizeof(dm); SetLastError(0xdeadbeef); ret = EnumDisplaySettingsA("\\.\DISPLAY1\Monitor0", ENUM_CURRENT_SETTINGS, &dm); - todo_wine ok(!ret, "EnumDisplaySettingsA succeeded\n"); + ok(!ret, "EnumDisplaySettingsA succeeded\n"); ok(GetLastError() == 0xdeadbeef, "Expect error 0xdeadbeef, got %#x\n", GetLastError()); - todo_wine ok(dm.dmFields == 0, "Expect dmFields unchanged, got %#x\n", dm.dmFields); + ok(dm.dmFields == 0, "Expect dmFields unchanged, got %#x\n", dm.dmFields);
/* Test that passing NULL to device name parameter means to use the primary adapter */ memset(&dm, 0, sizeof(dm));
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=76041
Your paranoid android.
=== w8 (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w8adm (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809 (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_2scr (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_ar (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_he (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_ja (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_zh_CN (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== debiant (32 bit report) ===
user32: monitor: Timeout msg: Timeout resource: Timeout scroll: Timeout static: Timeout sysparams: Timeout
=== debiant (build log) ===
The task timed out
=== debiant (32 bit WoW report) ===
user32: monitor: Timeout msg: Timeout resource: Timeout scroll: Timeout static: Timeout
=== debiant (build log) ===
The task timed out
On 7/24/20 6:19 PM, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=76041
Your paranoid android.
=== w8 (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w8adm (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809 (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_2scr (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_ar (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_he (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_ja (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== w1064v1809_zh_CN (32 bit report) ===
user32: sysparams.c:2508: Test failed: Waiting for the WM_DISPLAYCHANGE message timed out sysparams.c:2519: Test failed: Set bpp 32, but WM_DISPLAYCHANGE reported bpp -1
=== debiant (32 bit report) ===
user32: monitor: Timeout msg: Timeout resource: Timeout scroll: Timeout static: Timeout sysparams: Timeout
=== debiant (build log) ===
The task timed out
=== debiant (32 bit WoW report) ===
user32: monitor: Timeout msg: Timeout resource: Timeout scroll: Timeout static: Timeout
=== debiant (build log) ===
The task timed out
Looks like that mysterious monitor timeout bug again, but this time it's nondeterministic. For example, a successful run is in https://testbot.winehq.org/JobDetails.pl?Key=76035