[NTOS] Remove some hacks that are not needed anymore, since a real registry hive...
[reactos.git] / ntoskrnl / io / pnpmgr / pnpinit.c
index 504565f..5ae33e3 100644 (file)
@@ -56,15 +56,6 @@ PiInitCacheGroupInformation(VOID)
         RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet"
                             L"\\Control\\ServiceGroupOrder");
 
-    /* ReactOS HACK for SETUPLDR */
-    if (KeLoaderBlock->SetupLdrBlock)
-    {
-        /* Bogus data */
-        PiInitGroupOrderTableCount = 0;
-        PiInitGroupOrderTable = (PVOID)0xBABEB00B;
-        return STATUS_SUCCESS;
-    }
-
     /* Open the registry key */
     Status = IopOpenRegistryKeyEx(&KeyHandle,
                                   NULL,
@@ -251,7 +242,8 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
                        IN PDRIVER_OBJECT DriverObject)
 {
     NTSTATUS Status;
-    HANDLE EnumRootKey, SubKey, ControlKey, ClassKey, PropertiesKey;
+    HANDLE EnumRootKey, SubKey;
+    HANDLE ControlKey, ClassKey = NULL, PropertiesKey;
     UNICODE_STRING ClassGuid, Properties;
     UNICODE_STRING EnumRoot = RTL_CONSTANT_STRING(ENUM_ROOT);
     UNICODE_STRING ControlClass =
@@ -266,7 +258,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;
     }
 
@@ -278,7 +271,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;
     }
 
@@ -302,8 +296,8 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
         if (!NT_SUCCESS(Status))
         {
             /* No class key */
-            DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status);
-            ClassKey = NULL;
+            DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
+                    &ControlClass, Status);
         }
         else
         {
@@ -316,8 +310,8 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
             if (!NT_SUCCESS(Status))
             {
                 /* No class key */
-                DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status);
-                ClassKey = NULL;
+                DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
+                        &ClassGuid, Status);
             }
         }
 
@@ -330,11 +324,11 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
                                           ClassKey,
                                           &Properties,
                                           KEY_READ);
-            ZwClose(ClassKey);
             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
@@ -348,26 +342,35 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
     }
 
     /* Do ReactOS-style setup */
-    Status = IopAttachFilterDrivers(DeviceNode, TRUE);
+    Status = IopAttachFilterDrivers(DeviceNode, SubKey, ClassKey, 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, ClassKey, FALSE);
+    if (!NT_SUCCESS(Status))
+    {
+        IopRemoveDevice(DeviceNode);
+        goto Exit;
     }
 
-    /* Return status */
+    Status = IopStartDevice(DeviceNode);
+
+Exit:
+    /* Close keys and return status */
+    ZwClose(SubKey);
+    if (ClassKey != NULL)
+    {
+        ZwClose(ClassKey);
+    }
     return Status;
 }
 
@@ -385,8 +388,8 @@ IopInitializePlugPlayServices(VOID)
 
     /* Initialize locks and such */
     KeInitializeSpinLock(&IopDeviceTreeLock);
-    KeInitializeSpinLock(&IopDeviceRelationsSpinLock);
-    InitializeListHead(&IopDeviceRelationsRequestList);
+    KeInitializeSpinLock(&IopDeviceActionLock);
+    InitializeListHead(&IopDeviceActionRequestList);
 
     /* Get the default interface */
     PnpDefaultInterfaceType = IopDetermineDefaultInterfaceType();
@@ -450,7 +453,6 @@ IopInitializePlugPlayServices(VOID)
     if (Disposition == REG_CREATED_NEW_KEY)
     {
         /* FIXME: DACLs */
-        DPRINT1("Need to build DACL\n");
     }
 
     /* Create the root key */