From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Needed for Lenovo Ready for Assistant. --- dlls/windows.devices.usb/usbdevice.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/dlls/windows.devices.usb/usbdevice.c b/dlls/windows.devices.usb/usbdevice.c index a43dda26d80..19f03ff547a 100644 --- a/dlls/windows.devices.usb/usbdevice.c +++ b/dlls/windows.devices.usb/usbdevice.c @@ -133,8 +133,31 @@ static HRESULT WINAPI usbdevice_statics_GetDeviceSelectorGuidOnly( IUsbDeviceSta static HRESULT WINAPI usbdevice_statics_GetDeviceSelectorVidPidOnly( IUsbDeviceStatics *iface, UINT32 vendor, UINT32 product, HSTRING *value ) { - FIXME( "iface %p, vendor %d, product %d, value %p stub!\n", iface, vendor, product, value ); - return E_NOTIMPL; + static const WCHAR *prefix = L"System.Devices.InterfaceClassGuid:="{DEE824EF-729B-4A0E-9C14-B7117D33A817}"" + L" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True" + L" AND System.DeviceInterface.WinUsb.UsbVendorId:="; + static const WCHAR *suffix = L" AND System.DeviceInterface.WinUsb.UsbProductId:="; + WCHAR *buffer; + int length; + HRESULT hr; + + TRACE( "iface %p, vendor %d, product %d, value %p.\n", iface, vendor, product, value ); + + if (!value) return E_INVALIDARG; + + length = _snwprintf( NULL, 0, L"%ls%d%ls%d", prefix, (INT32)vendor, suffix, (INT32)product ); + if (length < 0) return E_FAIL; + + buffer = (WCHAR *)malloc( (length + 1) * sizeof(WCHAR) ); + if (!buffer) return E_OUTOFMEMORY; + + _snwprintf( buffer, length + 1, L"%ls%d%ls%d", prefix, (INT32)vendor, suffix, (INT32)product ); + if (FAILED( hr = WindowsCreateString( buffer, length, value ) )) goto done; + + TRACE( "Returning value = %s\n", debugstr_hstring(*value) ); +done: + free( buffer ); + return hr; }
static HRESULT WINAPI usbdevice_statics_GetDeviceClassSelector( IUsbDeviceStatics *iface, IUsbDeviceClass *class, HSTRING *value )