From ae157bec34a132d34ed04005f02f9fdf4845af97 Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Tue, 11 Feb 2020 16:08:59 +0800 Subject: [PATCH] user32: Handle NULL device and not NULL mode parameters in ChangeDisplaySettingsExW(). This makes sure that user graphics drivers has a valid device name when a DEVMODE is specified. Signed-off-by: Zhiyi Zhang Signed-off-by: Alexandre Julliard --- dlls/user32/sysparams.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index e3919ad1b10..c5c98a7ea1c 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -3293,12 +3293,21 @@ static void trace_devmode(const DEVMODEW *devmode) LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND hwnd, DWORD flags, LPVOID lparam ) { + WCHAR primary_adapter[CCHDEVICENAME]; BOOL def_mode = TRUE; DEVMODEW dm; TRACE("%s %p %p %#x %p\n", debugstr_w(devname), devmode, hwnd, flags, lparam); TRACE("flags=%s\n", _CDS_flags(flags)); + if (!devname && devmode) + { + if (!get_primary_adapter(primary_adapter)) + return DISP_CHANGE_FAILED; + + devname = primary_adapter; + } + if (devmode) { trace_devmode(devmode);