From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/ntoskrnl.exe/tests/driver_pnp.c | 37 +++++++++++++++++++++++++ dlls/ntoskrnl.exe/tests/ntoskrnl.c | 41 ++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+)
diff --git a/dlls/ntoskrnl.exe/tests/driver_pnp.c b/dlls/ntoskrnl.exe/tests/driver_pnp.c index 1a0717656c5..c33a8d6a082 100644 --- a/dlls/ntoskrnl.exe/tests/driver_pnp.c +++ b/dlls/ntoskrnl.exe/tests/driver_pnp.c @@ -265,6 +265,38 @@ static NTSTATUS query_id(struct device *device, IRP *irp, BUS_QUERY_ID_TYPE type return STATUS_SUCCESS; }
+static NTSTATUS query_text(struct device *device, IRP *irp, DEVICE_TEXT_TYPE type, LCID locale) +{ + static const WCHAR device_text2[] = L"WineTestDeviceLocation"; + static const WCHAR device_text[] = L"WineTestDevice"; + WCHAR *text = NULL; + + irp->IoStatus.Information = 0; + switch (type) + { + case DeviceTextDescription: + todo_wine ok(locale, "Expected locale to be set.\n"); + if (!(text = ExAllocatePool(PagedPool, sizeof(device_text)))) + return STATUS_NO_MEMORY; + wcscpy(text, device_text); + break; + + case DeviceTextLocationInformation: + todo_wine ok(locale, "Expected locale to be set.\n"); + if (!(text = ExAllocatePool(PagedPool, sizeof(device_text2)))) + return STATUS_NO_MEMORY; + wcscpy(text, device_text2); + break; + + default: + ok(0, "Unexpected device text type %#x.\n", type); + return irp->IoStatus.Status; + } + + irp->IoStatus.Information = (ULONG_PTR)text; + return STATUS_SUCCESS; +} + static NTSTATUS pdo_pnp(DEVICE_OBJECT *device_obj, IRP *irp) { IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); @@ -422,6 +454,11 @@ static NTSTATUS pdo_pnp(DEVICE_OBJECT *device_obj, IRP *irp) cancel_remove_device_count++; ret = STATUS_SUCCESS; break; + + case IRP_MN_QUERY_DEVICE_TEXT: + ret = query_text(device, irp, stack->Parameters.QueryDeviceText.DeviceTextType, + stack->Parameters.QueryDeviceText.LocaleId); + break; }
irp->IoStatus.Status = ret; diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 6d3914c8c0b..63b7f13d6b4 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -1640,6 +1640,9 @@ static void test_pnp_devices(void) static const char expect_hardware_id[] = "winetest_hardware\0winetest_hardware_1\0"; static const WCHAR expect_hardware_id_w[] = L"winetest_hardware\0winetest_hardware_1\0"; static const char expect_compat_id[] = "winetest_compat\0winetest_compat_1\0"; + static const char expect_device_location[] = "WineTestDeviceLocation"; + static const WCHAR expect_device_location_w[] = L"WineTestDeviceLocation"; + static const WCHAR expect_device_bus_desc_w[] = L"WineTestDevice"; static const WCHAR expect_compat_id_w[] = L"winetest_compat\0winetest_compat_1\0"; static const WCHAR expect_container_id_w[] = L"{12345678-1234-1234-1234-123456789123}"; static const char foobar[] = "foobar"; @@ -1926,6 +1929,16 @@ static void test_pnp_devices(void) ok(!strcmp(buffer, "\Device\winetest_pnp_1"), "got PDO name %s\n", debugstr_a(buffer)); }
+ ret = SetupDiGetDeviceRegistryPropertyA(set, &device, SPDRP_LOCATION_INFORMATION, &type, (BYTE *)buffer, + sizeof(buffer), &size); + todo_wine ok(ret, "Got error %#lx.\n", GetLastError()); + if (ret) + { + ok(type == REG_SZ, "Got type %lu.\n", type); + ok(size == sizeof(expect_device_location), "Got size %lu.\n", size); + ok(!strcmp(buffer, expect_device_location), "Got location information %s.\n", debugstr_a(buffer)); + } + prop_type = DEVPROP_TYPE_EMPTY; size = 0; memset(buffer_w, 0, sizeof(buffer_w)); @@ -1956,6 +1969,34 @@ static void test_pnp_devices(void) ok(IsEqualGUID(&buffer_guid, &expect_container_id_guid), "got container ID %s != %s\n", debugstr_guid(&buffer_guid), debugstr_guid(&expect_container_id_guid));
+ /* DEVPKEY_Device_BusReportedDeviceDesc. */ + prop_type = DEVPROP_TYPE_EMPTY; + size = 0; + 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)); + } + + /* DEVPKEY_Device_LocationInfo. */ + prop_type = DEVPROP_TYPE_EMPTY; + size = 0; + memset(buffer_w, 0, sizeof(buffer_w)); + ret = SetupDiGetDevicePropertyW(set, &device, &DEVPKEY_Device_LocationInfo, &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_location_w), "Got size %lu.\n", size); + ok(!wcscmp(buffer_w, expect_device_location_w), "Got device location info %s.\n", debugstr_w(buffer_w)); + } + ret = SetupDiEnumDeviceInterfaces(set, NULL, &child_class, 0, &iface); ok(ret, "failed to get interface, error %#lx\n", GetLastError()); ok(IsEqualGUID(&iface.InterfaceClassGuid, &child_class),
From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@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;
This merge request was approved by Elizabeth Figura.
This is causing a bunch of fixmes on startup:
``` 00b8:fixme:hid:pdo_pnp_dispatch Unhandled function 0000000c 00b8:fixme:hid:pdo_pnp_dispatch Unhandled function 0000000c 00b8:fixme:hid:pdo_pnp Unhandled minor function 0xc. 00b8:fixme:hid:pdo_pnp Unhandled minor function 0xc. 00b8:fixme:winebth:radio_pdo_pnp Unhandled minor function IRP_MN_QUERY_DEVICE_TEXT. 00b8:fixme:winebth:remote_device_pdo_pnp Unhandled minor function 0xc. 00b8:fixme:winebth:remote_device_pdo_pnp Unhandled minor function 0xc. 00b8:fixme:winebth:remote_device_pdo_pnp Unhandled minor function 0xc. ```
On Wed Aug 20 10:13:34 2025 +0000, Alexandre Julliard wrote:
This is causing a bunch of fixmes on startup:
00b8:fixme:hid:pdo_pnp_dispatch Unhandled function 0000000c 00b8:fixme:hid:pdo_pnp_dispatch Unhandled function 0000000c 00b8:fixme:hid:pdo_pnp Unhandled minor function 0xc. 00b8:fixme:hid:pdo_pnp Unhandled minor function 0xc. 00b8:fixme:winebth:radio_pdo_pnp Unhandled minor function IRP_MN_QUERY_DEVICE_TEXT. 00b8:fixme:winebth:remote_device_pdo_pnp Unhandled minor function 0xc. 00b8:fixme:winebth:remote_device_pdo_pnp Unhandled minor function 0xc. 00b8:fixme:winebth:remote_device_pdo_pnp Unhandled minor function 0xc.
That's expected, I planned to split up MRs between this implementation here and implementing the handling of `IRP_MN_QUERY_DEVICE_TEXT` in the other modules (in particular, winebus.sys.)
If you'd prefer I include commits for implementing those bits in this MR as well, I can do that. :)
On Wed Aug 20 10:13:58 2025 +0000, Connor McAdams wrote:
That's expected, I planned to split up MRs between this implementation here and implementing the handling of `IRP_MN_QUERY_DEVICE_TEXT` in the other modules (in particular, winebus.sys.) If you'd prefer I include commits for implementing those bits in this MR as well, I can do that. :)
That depends on the size of the changes, but if it's reasonable then please do.