[NTOS:IO]
[reactos.git] / reactos / ntoskrnl / io / pnpmgr / pnpinit.c
index 15a468a..733a68e 100644 (file)
@@ -268,7 +268,8 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
                                   KEY_READ);
     if (!NT_SUCCESS(Status))
     {
-        DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status);
+        DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
+                &EnumRoot, Status);
         return Status;
     }
 
@@ -280,7 +281,8 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
     ZwClose(EnumRootKey);
     if (!NT_SUCCESS(Status))
     {
-        DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status);
+        DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
+                &DeviceNode->InstancePath, Status);
         return Status;
     }
 
@@ -304,7 +306,8 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
         if (!NT_SUCCESS(Status))
         {
             /* No class key */
-            DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status);
+            DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
+                    &ControlClass, Status);
             ClassKey = NULL;
         }
         else
@@ -318,7 +321,8 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
             if (!NT_SUCCESS(Status))
             {
                 /* No class key */
-                DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status);
+                DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
+                        &ClassGuid, Status);
                 ClassKey = NULL;
             }
         }
@@ -336,7 +340,8 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
             if (!NT_SUCCESS(Status))
             {
                 /* No properties */
-                DPRINT("IopOpenRegistryKeyEx() failed with Status %08X\n", Status);
+                DPRINT("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
+                       &Properties, Status);
                 PropertiesKey = NULL;
             }
             else
@@ -350,26 +355,31 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
     }
 
     /* Do ReactOS-style setup */
-    Status = IopAttachFilterDrivers(DeviceNode, TRUE);
+    Status = IopAttachFilterDrivers(DeviceNode, SubKey, TRUE);
     if (!NT_SUCCESS(Status))
     {
         IopRemoveDevice(DeviceNode);
-        return Status;
+        goto Exit;
     }
+
     Status = IopInitializeDevice(DeviceNode, DriverObject);
-    if (NT_SUCCESS(Status))
+    if (!NT_SUCCESS(Status))
     {
-        Status = IopAttachFilterDrivers(DeviceNode, FALSE);
-        if (!NT_SUCCESS(Status))
-        {
-            IopRemoveDevice(DeviceNode);
-            return Status;
-        }
+        goto Exit;
+    }
 
-        Status = IopStartDevice(DeviceNode);
+    Status = IopAttachFilterDrivers(DeviceNode, SubKey, FALSE);
+    if (!NT_SUCCESS(Status))
+    {
+        IopRemoveDevice(DeviceNode);
+        goto Exit;
     }
 
-    /* Return status */
+    Status = IopStartDevice(DeviceNode);
+
+Exit:
+    /* Close key and return status */
+    ZwClose(SubKey);
     return Status;
 }
 
@@ -452,7 +462,6 @@ IopInitializePlugPlayServices(VOID)
     if (Disposition == REG_CREATED_NEW_KEY)
     {
         /* FIXME: DACLs */
-        DPRINT1("Need to build DACL\n");
     }
 
     /* Create the root key */