From: Connor McAdams <cmcadams(a)codeweavers.com> Signed-off-by: Connor McAdams <cmcadams(a)codeweavers.com> --- dlls/ntoskrnl.exe/pnp.c | 35 ++++++++++++++++++++++++++++++ dlls/ntoskrnl.exe/tests/ntoskrnl.c | 11 ++++------ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/dlls/ntoskrnl.exe/pnp.c b/dlls/ntoskrnl.exe/pnp.c index 86067a35692..1824fb28cab 100644 --- a/dlls/ntoskrnl.exe/pnp.c +++ b/dlls/ntoskrnl.exe/pnp.c @@ -33,6 +33,7 @@ #include "initguid.h" DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); +#include "devpkey.h" WINE_DEFAULT_DEBUG_CHANNEL(plugplay); @@ -95,6 +96,32 @@ static NTSTATUS get_device_id( DEVICE_OBJECT *device, BUS_QUERY_ID_TYPE type, WC return irp_status.Status; } +static NTSTATUS get_device_text( DEVICE_OBJECT *device, DEVICE_TEXT_TYPE type, WCHAR **text ) +{ + IO_STACK_LOCATION *irpsp; + IO_STATUS_BLOCK irp_status; + KEVENT event; + IRP *irp; + + device = IoGetAttachedDevice( device ); + + KeInitializeEvent( &event, NotificationEvent, FALSE ); + if (!(irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, device, NULL, 0, NULL, &event, &irp_status ))) + return STATUS_NO_MEMORY; + + irpsp = IoGetNextIrpStackLocation( irp ); + irpsp->MinorFunction = IRP_MN_QUERY_DEVICE_TEXT; + irpsp->Parameters.QueryDeviceText.DeviceTextType = type; + irpsp->Parameters.QueryDeviceText.LocaleId = 0; + + irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + if (IoCallDriver( device, irp ) == STATUS_PENDING) + KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); + + *text = (WCHAR *)irp_status.Information; + return irp_status.Status; +} + static NTSTATUS send_pnp_irp( DEVICE_OBJECT *device, UCHAR minor ) { IO_STACK_LOCATION *irpsp; @@ -362,6 +389,14 @@ static void enumerate_new_device( DEVICE_OBJECT *device, HDEVINFO set ) ExFreePool( id ); } + if (!get_device_text(device, DeviceTextDescription, &id) && id) + { + if (!SetupDiSetDevicePropertyW( set, &sp_device, &DEVPKEY_Device_BusReportedDeviceDesc, DEVPROP_TYPE_STRING, + (BYTE *)id, (lstrlenW( id ) + 1) * sizeof(WCHAR), 0 )) + WARN("Failed to set bus reported device desc property.\n"); + ExFreePool( id ); + } + if (need_driver && !install_device_driver( device, set, &sp_device ) && !caps.RawDeviceOK) { ERR("Unable to install a function driver for device %s.\n", debugstr_w(device_instance_id)); diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 63b7f13d6b4..87f41895511 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -1975,13 +1975,10 @@ static void test_pnp_devices(void) memset(buffer_w, 0, sizeof(buffer_w)); ret = SetupDiGetDevicePropertyW(set, &device, &DEVPKEY_Device_BusReportedDeviceDesc, &prop_type, (BYTE *)buffer_w, sizeof(buffer_w), &size, 0); - todo_wine ok(ret, "Got error %#lx.\n", GetLastError()); - if (ret) - { - ok(prop_type == DEVPROP_TYPE_STRING, "got type %#lx\n", prop_type); - ok(size == sizeof(expect_device_bus_desc_w), "Got size %lu.\n", size); - ok(!wcscmp(buffer_w, expect_device_bus_desc_w), "Got device bus desc %s.\n", debugstr_w(buffer_w)); - } + ok(ret, "Got error %#lx.\n", GetLastError()); + ok(prop_type == DEVPROP_TYPE_STRING, "got type %#lx\n", prop_type); + ok(size == sizeof(expect_device_bus_desc_w), "Got size %lu.\n", size); + ok(!wcscmp(buffer_w, expect_device_bus_desc_w), "Got device bus desc %s.\n", debugstr_w(buffer_w)); /* DEVPKEY_Device_LocationInfo. */ prop_type = DEVPROP_TYPE_EMPTY; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8770