Commit b5603287 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

user32: Fix ChangeDisplaySettingsExW() minimum size check.

parent 7d94e9d0
......@@ -3285,18 +3285,14 @@ LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND
{
trace_devmode(devmode);
/* This is the minimal dmSize that XP accepts */
if (devmode->dmSize < FIELD_OFFSET(DEVMODEW, dmFields))
return DISP_CHANGE_FAILED;
if (devmode->dmSize < FIELD_OFFSET(DEVMODEW, dmICMMethod))
return DISP_CHANGE_BADMODE;
if (devmode->dmSize >= FIELD_OFFSET(DEVMODEW, dmFields) + sizeof(devmode->dmFields))
{
if (((devmode->dmFields & DM_BITSPERPEL) && devmode->dmBitsPerPel) ||
((devmode->dmFields & DM_PELSWIDTH) && devmode->dmPelsWidth) ||
((devmode->dmFields & DM_PELSHEIGHT) && devmode->dmPelsHeight) ||
((devmode->dmFields & DM_DISPLAYFREQUENCY) && devmode->dmDisplayFrequency))
if (((devmode->dmFields & DM_BITSPERPEL) && devmode->dmBitsPerPel) ||
((devmode->dmFields & DM_PELSWIDTH) && devmode->dmPelsWidth) ||
((devmode->dmFields & DM_PELSHEIGHT) && devmode->dmPelsHeight) ||
((devmode->dmFields & DM_DISPLAYFREQUENCY) && devmode->dmDisplayFrequency))
def_mode = FALSE;
}
}
if (def_mode)
......
......@@ -401,11 +401,11 @@ static void test_ChangeDisplaySettingsEx(void)
dmW.dmSize = FIELD_OFFSET(DEVMODEW, dmICMMethod) - 1;
res = ChangeDisplaySettingsW(&dmW, CDS_TEST);
todo_wine ok(res == DISP_CHANGE_BADMODE, "ChangeDisplaySettingsW returned %d, expect DISP_CHANGE_BADMODE\n", res);
ok(res == DISP_CHANGE_BADMODE, "ChangeDisplaySettingsW returned %d, expect DISP_CHANGE_BADMODE\n", res);
dmW.dmSize = FIELD_OFFSET(DEVMODEW, dmICMMethod) - 1;
res = ChangeDisplaySettingsExW(NULL, &dmW, NULL, CDS_TEST, NULL);
todo_wine ok(res == DISP_CHANGE_BADMODE, "ChangeDisplaySettingsExW returned %d, expect DISP_CHANGE_BADMODE\n", res);
ok(res == DISP_CHANGE_BADMODE, "ChangeDisplaySettingsExW returned %d, expect DISP_CHANGE_BADMODE\n", res);
dmW.dmSize = FIELD_OFFSET(DEVMODEW, dmICMMethod);
res = ChangeDisplaySettingsW(&dmW, CDS_TEST);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment