Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/user32/sysparams.c | 16 +++++++++++++++- dlls/user32/tests/monitor.c | 6 +++--- 2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 14d3778a535..d4462e589e8 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -3307,7 +3307,8 @@ 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]; + WCHAR primary_adapter[CCHDEVICENAME], *end; + long int display_idx; BOOL def_mode = TRUE; DEVMODEW dm; LONG ret; @@ -3331,6 +3332,19 @@ 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) + { + ERR("Invalid device name %s.\n", wine_dbgstr_w(devname)); + return DISP_CHANGE_BADPARAM; + } + if (devmode) { trace_devmode(devmode); diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index fe763e46b48..badbfdaacf3 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -369,13 +369,13 @@ static void test_ChangeDisplaySettingsEx(void) ok(res, "EnumDisplaySettingsA failed, error %#x\n", GetLastError());
res = ChangeDisplaySettingsExA("invalid", &dm, NULL, CDS_TEST, NULL); - todo_wine ok(res == DISP_CHANGE_BADPARAM, "ChangeDisplaySettingsA returned unexpected %d\n", res); + ok(res == DISP_CHANGE_BADPARAM, "ChangeDisplaySettingsA returned unexpected %d\n", res);
res = ChangeDisplaySettingsExA("\\.\DISPLAY0", &dm, NULL, CDS_TEST, NULL); - todo_wine ok(res == DISP_CHANGE_BADPARAM, "ChangeDisplaySettingsA returned unexpected %d\n", res); + ok(res == DISP_CHANGE_BADPARAM, "ChangeDisplaySettingsA returned unexpected %d\n", res);
res = ChangeDisplaySettingsExA("\\.\DISPLAY1\Monitor0", &dm, NULL, CDS_TEST, NULL); - todo_wine ok(res == DISP_CHANGE_BADPARAM, "ChangeDisplaySettingsA returned unexpected %d\n", res); + ok(res == DISP_CHANGE_BADPARAM, "ChangeDisplaySettingsA returned unexpected %d\n", res);
/* Test dmDriverExtra */ 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=75833
Your paranoid android.
=== debiant (32 bit Chinese:China report) ===
user32: clipboard.c:760: Test failed: 0: gle 5 clipboard.c:765: Test failed: 0.0: got 0000 instead of 0001 clipboard.c:805: Test failed: 0: gle 1418 clipboard.c:815: Test failed: 0: count 4 clipboard.c:818: Test failed: 0: gle 1418 clipboard.c:833: Test failed: 0: gle 5 clipboard.c:838: Test failed: 0.0: got 0000 instead of 0001 clipboard.c:868: Test failed: 0: gle 1418