https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d380e9777c8c64cbb6eadb...
commit d380e9777c8c64cbb6eadb55442dd7e18f9a8ad4 Author: Hervé Poussineau hpoussin@reactos.org AuthorDate: Mon Dec 13 23:25:20 2021 +0100 Commit: Hervé Poussineau hpoussin@reactos.org CommitDate: Thu Dec 16 16:14:21 2021 +0100
[NTOS:PNP] Set DeviceReported=1 in Instance key and Control key of legacy devices at report time
CORE-17874 --- ntoskrnl/io/pnpmgr/pnpreport.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/io/pnpmgr/pnpreport.c b/ntoskrnl/io/pnpmgr/pnpreport.c index 3357925ec65..9f6f06688bd 100644 --- a/ntoskrnl/io/pnpmgr/pnpreport.c +++ b/ntoskrnl/io/pnpmgr/pnpreport.c @@ -155,15 +155,19 @@ IoReportDetectedDevice( _In_ BOOLEAN ResourceAssigned, _Inout_ PDEVICE_OBJECT *DeviceObject) { + UNICODE_STRING Control = RTL_CONSTANT_STRING(L"Control"); + UNICODE_STRING DeviceReportedName = RTL_CONSTANT_STRING(L"DeviceReported"); + OBJECT_ATTRIBUTES ObjectAttributes; PDEVICE_NODE DeviceNode; PDEVICE_OBJECT Pdo; NTSTATUS Status; - HANDLE InstanceKey; + HANDLE InstanceKey, ControlKey; UNICODE_STRING ValueName, ServiceLongName, ServiceName; WCHAR HardwareId[256]; PWCHAR IfString; ULONG IdLength; ULONG LegacyValue; + ULONG DeviceReported = 1;
DPRINT("IoReportDetectedDevice (DeviceObject %p, *DeviceObject %p)\n", DeviceObject, DeviceObject ? *DeviceObject : NULL); @@ -266,6 +270,39 @@ IoReportDetectedDevice( { DPRINT("Failed to write the Legacy value: 0x%x\n", Status); } + Status = ZwSetValueKey(InstanceKey, &DeviceReportedName, 0, REG_DWORD, &DeviceReported, sizeof(DeviceReported)); + if (!NT_SUCCESS(Status)) + { + DPRINT("Failed to write the DeviceReported value: 0x%x\n", Status); + } + + /* Set DeviceReported=1 in Control subkey */ + InitializeObjectAttributes(&ObjectAttributes, + &Control, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + InstanceKey, + NULL); + Status = ZwCreateKey(&ControlKey, + KEY_SET_VALUE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + if (NT_SUCCESS(Status)) + { + Status = ZwSetValueKey(ControlKey, + &DeviceReportedName, + 0, + REG_DWORD, + &DeviceReported, + sizeof(DeviceReported)); + ZwClose(ControlKey); + } + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to set ReportedDevice=1 for device %wZ (status 0x%08lx)\n", &instancePath, Status); + }
/* Add DETECTEDInterfaceType\DriverName */ IdLength = 0;