From fcc7d2acc7c6da26761ffcf5ac9e8c79db4fb2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 20 Mar 2005 12:15:33 +0000 Subject: [PATCH] Implement IoReportDetectedDevice svn path=/trunk/; revision=14215 --- reactos/ntoskrnl/io/pnpreport.c | 48 +++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpreport.c b/reactos/ntoskrnl/io/pnpreport.c index a9ea1d98ff7..0e02c385598 100644 --- a/reactos/ntoskrnl/io/pnpreport.c +++ b/reactos/ntoskrnl/io/pnpreport.c @@ -10,14 +10,14 @@ /* INCLUDES ******************************************************************/ -//#define NDEBUG +#define NDEBUG #include #include /* FUNCTIONS *****************************************************************/ /* - * @unimplemented + * @implemented */ NTSTATUS STDCALL @@ -32,24 +32,38 @@ IoReportDetectedDevice( IN OUT PDEVICE_OBJECT *DeviceObject) { PDEVICE_NODE DeviceNode; - NTSTATUS Status; + PDEVICE_OBJECT Pdo; + NTSTATUS Status = STATUS_SUCCESS; - DPRINT("IoReportDetectedDevice called (partly implemented)\n"); - /* Use IopRootDeviceNode for now */ - Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode); - if (!NT_SUCCESS(Status)) + DPRINT("IoReportDetectedDevice (DeviceObject %p, *DeviceObject %p)\n", + DeviceObject, DeviceObject ? *DeviceObject : NULL); + + /* if *DeviceObject is not NULL, we must use it as a PDO, + * and don't create a new one. + */ + if (DeviceObject && *DeviceObject) + Pdo = *DeviceObject; + else { - DPRINT("IopCreateDeviceNode() failed (Status 0x%08x)\n", Status); - return Status; + /* create a new PDO and return it in *DeviceObject */ + Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode); + if (!NT_SUCCESS(Status)) + { + DPRINT("IopCreateDeviceNode() failed (Status 0x%08lx)\n", Status); + return Status; + } + Pdo = DeviceNode->PhysicalDeviceObject; + if (DeviceObject) + *DeviceObject = Pdo; } - Status = IopInitializePnpServices(DeviceNode, FALSE); - if (!NT_SUCCESS(Status)) - { - DPRINT("IopInitializePnpServices() failed (Status 0x%08x)\n", Status); - return Status; - } - return IopInitializeDevice(DeviceNode, DriverObject); + /* we don't need to call AddDevice and send IRP_MN_START_DEVICE */ + + /* FIXME: save this device into the root-enumerated list, so this + * device would be detected as a PnP device during next startups. + */ + + return Status; } /* @@ -66,7 +80,7 @@ IoReportResourceForDetection( IN ULONG DeviceListSize OPTIONAL, OUT PBOOLEAN ConflictDetected) { - DPRINT("IoReportResourceForDetection UNIMPLEMENTED but returns success.\n"); + DPRINT1("IoReportResourceForDetection UNIMPLEMENTED but returns success.\n"); *ConflictDetected = FALSE; return STATUS_SUCCESS; }