Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- v2: SUBSYS_ should have 8 digits following. Supersede 158956~158958
dlls/user32/driver.c | 44 +++++++++++++++++++++++++++---------- dlls/user32/tests/monitor.c | 10 ++++----- 2 files changed, 38 insertions(+), 16 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index 483d5552bf..355248d3cc 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -361,25 +361,47 @@ static BOOL CDECL nulldrv_EnumDisplayDevicesW( LPCWSTR lpDevice, DWORD i, LPDISP static const WCHAR primary_device_string[] = {'X','1','1',' ','W','i','n','d','o','w','i','n','g',' ', 'S','y','s','t','e','m',0}; static const WCHAR primary_device_deviceid[] = {'P','C','I','\','V','E','N','_','0','0','0','0','&', - 'D','E','V','_','0','0','0','0',0}; + 'D','E','V','_','0','0','0','0','&', + 'S','U','B','S','Y','S','_','0','0','0','0','0','0','0','0','&', + 'R','E','V','_','0','0',0}; + static const WCHAR primary_monitor_name[] = {'\','\','.','\','D','I','S','P','L','A','Y','1','\', + 'M','o','n','i','t','o','r','0',0}; + static const WCHAR nonpnp_monitor_string[] = {'G','e','n','e','r','i','c',' ','N','o','n','-','P','n','P',' ', + 'M','o','n','i','t','o','r',0};
FIXME("(%s,%d,%p,0x%08x), stub!\n", debugstr_w(lpDevice), i, lpDisplayDevice, dwFlags);
if (i) return FALSE;
- memcpy(lpDisplayDevice->DeviceName, primary_device_name, sizeof(primary_device_name)); - memcpy(lpDisplayDevice->DeviceString, primary_device_string, sizeof(primary_device_string)); + if (!lpDevice) + { + memcpy(lpDisplayDevice->DeviceName, primary_device_name, sizeof(primary_device_name)); + memcpy(lpDisplayDevice->DeviceString, primary_device_string, sizeof(primary_device_string)); + + lpDisplayDevice->StateFlags = + DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE; + + if (lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(lpDisplayDevice->DeviceID)) + memcpy(lpDisplayDevice->DeviceID, primary_device_deviceid, sizeof(primary_device_deviceid)); + if (lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(lpDisplayDevice->DeviceKey)) + lpDisplayDevice->DeviceKey[0] = 0; + } + else + { + if (strcmpiW(lpDevice, primary_device_name)) + return FALSE;
- lpDisplayDevice->StateFlags = - DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | - DISPLAY_DEVICE_PRIMARY_DEVICE | - DISPLAY_DEVICE_VGA_COMPATIBLE; + memcpy(lpDisplayDevice->DeviceName, primary_monitor_name, sizeof (primary_monitor_name)); + memcpy(lpDisplayDevice->DeviceString, nonpnp_monitor_string, sizeof(nonpnp_monitor_string));
- if(lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(lpDisplayDevice->DeviceID)) - memcpy(lpDisplayDevice->DeviceID, primary_device_deviceid, sizeof(primary_device_deviceid)); - if(lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(lpDisplayDevice->DeviceKey)) - lpDisplayDevice->DeviceKey[0] = 0; + lpDisplayDevice->StateFlags = DISPLAY_DEVICE_ACTIVE | DISPLAY_DEVICE_ATTACHED; + + if (lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(lpDisplayDevice->DeviceID)) + lpDisplayDevice->DeviceID[0] = 0; + if (lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(lpDisplayDevice->DeviceKey)) + lpDisplayDevice->DeviceKey[0] = 0; + }
return TRUE; } diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index 733220a426..33c7e24128 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -146,13 +146,13 @@ static void test_enumdisplaydevices_adapter(int index, const DISPLAY_DEVICEA *de * by changing the data and rerun EnumDisplayDevices. But it's difficult to find corresponding PCI device on * userland. So here we check the expected format instead. */ if (flags & EDD_GET_DEVICE_INTERFACE_NAME) - todo_wine ok(strlen(device->DeviceID) == 0 || /* vista+ */ + ok(strlen(device->DeviceID) == 0 || /* vista+ */ sscanf(device->DeviceID, "PCI\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X", &vendor_id, &device_id, &subsys_id, &revision_id) == 4, /* XP/2003 ignores EDD_GET_DEVICE_INTERFACE_NAME */ "#%d: got %s\n", index, device->DeviceID); else { - todo_wine ok(broken(strlen(device->DeviceID) == 0) || /* XP on Testbot returns an empty string, whereas real machine doesn't */ + ok(broken(strlen(device->DeviceID) == 0) || /* XP on Testbot returns an empty string, whereas real machine doesn't */ sscanf(device->DeviceID, "PCI\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X", &vendor_id, &device_id, &subsys_id, &revision_id) == 4, "#%d: wrong DeviceID %s\n", index, device->DeviceID); } @@ -173,14 +173,14 @@ static void test_enumdisplaydevices_monitor(int adapter_index, int monitor_index /* DeviceName */ lstrcpyA(monitor_name, adapter_name); sprintf(monitor_name + strlen(monitor_name), "\Monitor%d", monitor_index); - todo_wine ok(!strcmp(monitor_name, device->DeviceName), "#%d: expect %s, got %s\n", monitor_index, monitor_name, device->DeviceName); + ok(!strcmp(monitor_name, device->DeviceName), "#%d: expect %s, got %s\n", monitor_index, monitor_name, device->DeviceName);
/* DeviceString */ ok(strlen(device->DeviceString) > 0, "#%d: expect DeviceString not empty\n", monitor_index);
/* StateFlags */ if (adapter_index == 0 && monitor_index == 0) - todo_wine ok(device->StateFlags & DISPLAY_DEVICE_ATTACHED, "#%d expect to have a primary monitor attached\n", monitor_index); + ok(device->StateFlags & DISPLAY_DEVICE_ATTACHED, "#%d expect to have a primary monitor attached\n", monitor_index); else ok(device->StateFlags <= (DISPLAY_DEVICE_ATTACHED | DISPLAY_DEVICE_ACTIVE), "#%d wrong state %#x\n", monitor_index, device->StateFlags); @@ -191,7 +191,7 @@ static void test_enumdisplaydevices_monitor(int adapter_index, int monitor_index { /* HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\Default_Monitor\4&2abfaa30&0&UID0 GUID_DEVINTERFACE_MONITOR * ^ ^ ^ * Expect format \?\DISPLAY#Default_Monitor#4&2abfaa30&0&UID0#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7} */ - todo_wine ok(strlen(device->DeviceID) == 0 || /* vista ~ win7 */ + ok(strlen(device->DeviceID) == 0 || /* vista ~ win7 */ sscanf(device->DeviceID, "\\?\DISPLAY#Default_Monitor#%[^#]#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}", buffer) == 1 || /* win8+ */ (!lstrcmpiA(buffer, device_id_prefix) && sscanf(device->DeviceID + sizeof(device_id_prefix) - 1, "%04d", &number) == 1), /* XP/2003 ignores EDD_GET_DEVICE_INTERFACE_NAME */