From 6cf62841ad2cae4308735ccb7aee805f9cfc5df8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 23 Aug 2011 03:57:24 +0000 Subject: [PATCH] [PNPMGR] - Fix IoReportDetectedDevice to use the caller's driver object svn path=/trunk/; revision=53392 --- reactos/ntoskrnl/include/internal/io.h | 1 + reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 2 +- reactos/ntoskrnl/io/pnpmgr/pnpreport.c | 22 +++++++++++----------- reactos/ntoskrnl/io/pnpmgr/pnproot.c | 3 ++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index cbcf466b00c..c4ca69da136 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -1022,6 +1022,7 @@ PnpRootDriverEntry( NTSTATUS PnpRootCreateDevice( IN PUNICODE_STRING ServiceName, + IN OPTIONAL PDRIVER_OBJECT DriverObject, OUT PDEVICE_OBJECT *PhysicalDeviceObject, OUT OPTIONAL PUNICODE_STRING FullInstancePath ); diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 807451a90dc..fe9019a3c2b 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -690,7 +690,7 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode, RtlAppendUnicodeStringToString(&FullServiceName, &LegacyPrefix); RtlAppendUnicodeStringToString(&FullServiceName, ServiceName1); - Status = PnpRootCreateDevice(&FullServiceName, &PhysicalDeviceObject, &Node->InstancePath); + Status = PnpRootCreateDevice(&FullServiceName, NULL, &PhysicalDeviceObject, &Node->InstancePath); if (!NT_SUCCESS(Status)) { DPRINT1("PnpRootCreateDevice() failed with status 0x%08X\n", Status); diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpreport.c b/reactos/ntoskrnl/io/pnpmgr/pnpreport.c index d63a7018ba6..91b5c07a10a 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpreport.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpreport.c @@ -202,12 +202,12 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject, if (DeviceObject && *DeviceObject) { Pdo = *DeviceObject; - DeviceNode = IopGetDeviceNode(*DeviceObject); } else { /* Create the PDO */ Status = PnpRootCreateDevice(&ServiceName, + DriverObject, &Pdo, NULL); if (!NT_SUCCESS(Status)) @@ -215,18 +215,18 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject, DPRINT("PnpRootCreateDevice() failed (Status 0x%08lx)\n", Status); return Status; } + } - /* Create the device node for the new PDO */ - Status = IopCreateDeviceNode(IopRootDeviceNode, - Pdo, - NULL, - &DeviceNode); + /* Create the device node for the new PDO */ + Status = IopCreateDeviceNode(IopRootDeviceNode, + Pdo, + NULL, + &DeviceNode); - if (!NT_SUCCESS(Status)) - { - DPRINT("IopCreateDeviceNode() failed (Status 0x%08lx)\n", Status); - return Status; - } + if (!NT_SUCCESS(Status)) + { + DPRINT("IopCreateDeviceNode() failed (Status 0x%08lx)\n", Status); + return Status; } /* We don't call AddDevice for devices reported this way */ diff --git a/reactos/ntoskrnl/io/pnpmgr/pnproot.c b/reactos/ntoskrnl/io/pnpmgr/pnproot.c index c4a3ed764ea..2393a2a7301 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnproot.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnproot.c @@ -130,6 +130,7 @@ LocateChildDevice( NTSTATUS PnpRootCreateDevice( IN PUNICODE_STRING ServiceName, + IN OPTIONAL PDRIVER_OBJECT DriverObject, OUT PDEVICE_OBJECT *PhysicalDeviceObject, OUT OPTIONAL PUNICODE_STRING FullInstancePath) { @@ -271,7 +272,7 @@ tryagain: /* Initialize a device object */ Status = IoCreateDevice( - PnpRootDeviceObject->DriverObject, + DriverObject ? DriverObject : PnpRootDeviceObject->DriverObject, sizeof(PNPROOT_PDO_DEVICE_EXTENSION), NULL, FILE_DEVICE_CONTROLLER,