Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/user32/misc.c | 28 ++++++++++++++++++++++++++++ dlls/user32/tests/monitor.c | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/misc.c b/dlls/user32/misc.c index 1a45e1c882..256a26c71b 100644 --- a/dlls/user32/misc.c +++ b/dlls/user32/misc.c @@ -276,12 +276,40 @@ BOOL WINAPI EnumDisplayDevicesA( LPCSTR lpDevice, DWORD i, LPDISPLAY_DEVICEA lpD return TRUE; }
+static BOOL is_display_device(LPCWSTR name) +{ + static const WCHAR display_deviceW[] = {'\','\','.','\','D','I','S','P','L','A','Y'}; + const WCHAR *p = name; + + if (strncmpiW(name, display_deviceW, ARRAY_SIZE(display_deviceW))) + return FALSE; + + p += ARRAY_SIZE(display_deviceW); + + if (!isdigitW(*p++)) + return FALSE; + + for (; *p; p++) + { + if (!isdigitW(*p)) + return FALSE; + } + + return TRUE; +} + /*********************************************************************** * EnumDisplayDevicesW (USER32.@) */ BOOL WINAPI EnumDisplayDevicesW( LPCWSTR lpDevice, DWORD i, LPDISPLAY_DEVICEW lpDisplayDevice, DWORD dwFlags ) { + if (lpDevice && !is_display_device(lpDevice)) + { + WARN("Wrong adapter name: %s\n", wine_dbgstr_w(lpDevice)); + return FALSE; + } + return USER_Driver->pEnumDisplayDevicesW(lpDevice, i, lpDisplayDevice, dwFlags); }
diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index 8bf284a5e1..733220a426 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -235,7 +235,7 @@ static void test_enumdisplaydevices(void) /* Doesn't accept \.\DISPLAY */ dd.cb = sizeof(dd); ret = pEnumDisplayDevicesA("\\.\DISPLAY", 0, &dd, 0); - todo_wine ok(!ret, "Expect failure\n"); + ok(!ret, "Expect failure\n");
/* Enumeration */ for (flag_index = 0; flag_index < ARRAY_SIZE(flags); flag_index++)