Fix the case when IRP_MN_QUERY_DEVICE_TEXT returns nothing
authorHervé Poussineau <hpoussin@reactos.org>
Mon, 12 Dec 2005 16:44:09 +0000 (16:44 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Mon, 12 Dec 2005 16:44:09 +0000 (16:44 +0000)
Set DN_DRIVER_LOADED and DN_STARTED flags

svn path=/trunk/; revision=20103

reactos/ntoskrnl/io/device.c
reactos/ntoskrnl/io/pnpmgr.c
reactos/ntoskrnl/io/pnproot.c

index ddc2b56..6de7723 100644 (file)
@@ -163,7 +163,10 @@ IopStartDevice(
    }
 
    ObDereferenceObject(Fdo);
-   
+
+   if (NT_SUCCESS(Status))
+       DeviceNode->Flags |= DN_STARTED;
+
    return Status;
 }
 
index 4a1ecf8..f2a94bd 100644 (file)
@@ -1753,7 +1753,7 @@ IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
    RtlInitUnicodeString(&ValueName, L"DeviceDesc");
    if (ZwQueryValueKey(InstanceKey, &ValueName, KeyValueBasicInformation, NULL, 0, &RequiredLength) == STATUS_OBJECT_NAME_NOT_FOUND)
    {
-      if (NT_SUCCESS(IoStatusBlock.Status) &&
+      if (NT_SUCCESS(Status) &&
          IoStatusBlock.Information &&
          (*(PWSTR)IoStatusBlock.Information != 0))
       {
@@ -1768,16 +1768,15 @@ IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
       }
       else
       {
-         UNICODE_STRING DeviceDesc;
-         RtlInitUnicodeString(&DeviceDesc, L"Unknown Device");
-         DPRINT("Driver didn't return DeviceDesc (Status %x), so place unknown device there\n", Status);
+         UNICODE_STRING DeviceDesc = RTL_CONSTANT_STRING(L"Unknown device");
+         DPRINT("Driver didn't return DeviceDesc (Status 0x%08lx), so place unknown device there\n", Status);
 
          Status = ZwSetValueKey(InstanceKey,
             &ValueName,
             0,
             REG_SZ,
-            &DeviceDesc,
-            (wcslen((PWSTR)&DeviceDesc) + 1) * sizeof(WCHAR));
+            DeviceDesc.Buffer,
+            DeviceDesc.MaximumLength);
 
          if (!NT_SUCCESS(Status))
          {
@@ -2014,6 +2013,7 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode,
              * device is started */
             DPRINT("%wZ is using NULL driver\n", &DeviceNode->InstancePath);
             IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED);
+            DeviceNode->Flags |= DN_STARTED;
          }
          return STATUS_SUCCESS;
       }
@@ -2095,8 +2095,11 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode,
       if (NT_SUCCESS(Status) || Status == STATUS_IMAGE_ALREADY_LOADED)
       {
          if (Status != STATUS_IMAGE_ALREADY_LOADED)
+         {
+            DeviceNode->Flags |= DN_DRIVER_LOADED;
             Status = IopInitializeDriverModule(DeviceNode, ModuleObject,
                &DeviceNode->ServiceName, FALSE, &DriverObject);
+         }
          else
          {
             /* get existing DriverObject pointer */
index d4c24fd..dca0644 100644 (file)
@@ -579,7 +579,7 @@ PnpRootFdoReadDeviceInfo(
 
   if (!NT_SUCCESS(Status))
   {
-    /* FIXME: */
+    Device->DeviceDescription.Buffer = NULL;
   }
 
   DPRINT("Got device description: %S\n", DeviceDesc->Buffer);
@@ -1184,8 +1184,8 @@ PnpRootDriverEntry(
 {
   DPRINT("Called\n");
 
-  DriverObject->MajorFunction[IRP_MJ_PNP] = (PDRIVER_DISPATCH) PnpRootPnpControl;
-  DriverObject->MajorFunction[IRP_MJ_POWER] = (PDRIVER_DISPATCH) PnpRootPowerControl;
+  DriverObject->MajorFunction[IRP_MJ_PNP] = PnpRootPnpControl;
+  DriverObject->MajorFunction[IRP_MJ_POWER] = PnpRootPowerControl;
   DriverObject->DriverExtension->AddDevice = PnpRootAddDevice;
 
   return STATUS_SUCCESS;