[PATCH 0/1] MR11244: wbemprox: Use device instance id for pnpdevice_id in get_display_adapters().
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/wbemprox/builtin.c | 24 +++++++++++++++--------- dlls/wbemprox/tests/query.c | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 9e1036cdc26..e073c7a7895 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -4681,15 +4681,23 @@ static struct display_adapter *get_display_adapters( UINT *count ) while(SetupDiEnumDeviceInfo( devs, idx_devinfo++, &dev_info )) { - WCHAR *driver, *hw_ids; + WCHAR *driver, *instance_id; UINT key_len; WCHAR *key_path; HKEY key_instance; + DWORD size; - if (!(driver = get_string_devprop( devs, &dev_info, &DEVPKEY_Device_Driver ))) continue; - if (!(hw_ids = get_string_devprop( devs, &dev_info, &DEVPKEY_Device_HardwareIds ))) + SetupDiGetDeviceInstanceIdW( devs, &dev_info, NULL, 0, &size ); + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) continue; + if (!(instance_id = malloc( size * sizeof(*instance_id) ))) continue; + if (!SetupDiGetDeviceInstanceIdW( devs, &dev_info, instance_id, size, NULL )) { - free( driver ); + free( instance_id ); + continue; + } + if (!(driver = get_string_devprop( devs, &dev_info, &DEVPKEY_Device_Driver ))) + { + free( instance_id ); continue; } @@ -4697,7 +4705,7 @@ static struct display_adapter *get_display_adapters( UINT *count ) if (!(key_path = calloc( sizeof(WCHAR), key_len ))) { free( driver ); - free( hw_ids ); + free( instance_id ); continue; } @@ -4706,7 +4714,7 @@ static struct display_adapter *get_display_adapters( UINT *count ) if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, key_path, 0, KEY_QUERY_VALUE, &key_instance )) { - free( hw_ids ); + free( instance_id ); free( key_path ); continue; } @@ -4716,9 +4724,7 @@ static struct display_adapter *get_display_adapters( UINT *count ) ret[i].driver_date = get_reg_value( key_instance, L"DriverDate" ); ret[i].driver_desc = get_reg_value( key_instance, L"DriverDesc" ); ret[i].driver_version = get_reg_value( key_instance, L"DriverVersion" ); - /* DEVPKEY_Device_HardwareIds is actually an array of null-terminated - strings, so consumers will only see the first one. */ - ret[i].pnpdevice_id = hw_ids; + ret[i].pnpdevice_id = instance_id; ret[i].dac_type = get_reg_value( key_instance, L"HardwareInformation.DacType" ); ret[i].memory_size = get_reg_value_dword( key_instance, L"HardwareInformation.MemorySize" ); if (++i >= nb_allocated) diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index 62532f841ad..0b3db5662e4 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -1972,6 +1972,7 @@ static void test_Win32_VideoController( IWbemServices *services ) check_property( obj, L"DriverDate", VT_BSTR, CIM_DATETIME ); check_property( obj, L"DriverVersion", VT_BSTR, CIM_STRING ); check_property_nullable( obj, L"InstalledDisplayDrivers", VT_BSTR, CIM_STRING ); + check_property( obj, L"PNPDeviceID", VT_BSTR, CIM_STRING ); check_property( obj, L"Status", VT_BSTR, CIM_STRING ); IWbemClassObject_Release( obj ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11244
That helps Borderlands GOTY Enhanced which otherwise doesn't start and complains about initialization error. That regressed with wbemprox change when setupapi started being used instead of dxgi. Previously the string for PnP device id for videocontroller was "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\\0&DEADBEEF&0&DEAD" (which matches Windows format), now that results in HW id which doesn't have instance id after the last '\\'. I checked on Windows that the string matches device instance id. While our instance id (part after the last "\\" doesn't exactly match Windows PCI id (that looks like "PCI\\VEN_1002&DEV_73DF&SUBSYS_16C21043&REV_C3\\6&1BE0D0F&0&00000009" on Windows and ""PCI\\VEN_8086&DEV_A788&SUBSYS_00000000&REV_00\\00000001" on Wine, I think it is best to have the match between device instance id from setupapi / cfgmgr32 and wbemprox, and fix instance id there if necessary (while so far the game is happy this way and it is probably not entirely stable across device types on Windows). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11244#note_144053
This merge request was approved by Hans Leidekker. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11244
participants (3)
-
Hans Leidekker (@hans) -
Paul Gofman -
Paul Gofman (@gofman)