user32: Fix ChangeDisplaySettingsExW() minimum size check.
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7d94e9d0c3
commit
b5603287b7
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue