return Status;
}
-
-/*
- * IopActionInterrogateDeviceStack
- *
- * Retrieve information for all (direct) child nodes of a parent node.
- *
- * Parameters
- * DeviceNode
- * Pointer to device node.
- * Context
- * Pointer to parent node to retrieve child node information for.
- *
- * Remarks
- * Any errors that occur are logged instead so that all child services have a chance
- * of being interrogated.
- */
-
NTSTATUS
-IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
- PVOID Context)
+IopCreateDeviceInstancePath(
+ _In_ PDEVICE_NODE DeviceNode,
+ _Out_ PUNICODE_STRING InstancePathU)
{
IO_STATUS_BLOCK IoStatusBlock;
PWSTR InformationString;
- PDEVICE_NODE ParentDeviceNode;
WCHAR InstancePath[MAX_PATH];
IO_STACK_LOCATION Stack;
NTSTATUS Status;
- ULONG RequiredLength;
- LCID LocaleId;
- HANDLE InstanceKey = NULL;
- UNICODE_STRING ValueName;
UNICODE_STRING ParentIdPrefix = { 0, 0, NULL };
- UNICODE_STRING InstancePathU;
DEVICE_CAPABILITIES DeviceCapabilities;
- PDEVICE_OBJECT OldDeviceObject;
-
- DPRINT("IopActionInterrogateDeviceStack(%p, %p)\n", DeviceNode, Context);
- DPRINT("PDO 0x%p\n", DeviceNode->PhysicalDeviceObject);
-
- ParentDeviceNode = (PDEVICE_NODE)Context;
-
- /*
- * We are called for the parent too, but we don't need to do special
- * handling for this node
- */
- if (DeviceNode == ParentDeviceNode)
- {
- DPRINT("Success\n");
- return STATUS_SUCCESS;
- }
-
- /*
- * Make sure this device node is a direct child of the parent device node
- * that is given as an argument
- */
- if (DeviceNode->Parent != ParentDeviceNode)
- {
- DPRINT("Skipping 2+ level child\n");
- return STATUS_SUCCESS;
- }
-
- /* Skip processing if it was already completed before */
- if (DeviceNode->Flags & DNF_PROCESSED)
- {
- /* Nothing to do */
- return STATUS_SUCCESS;
- }
-
- /* Get Locale ID */
- Status = ZwQueryDefaultLocale(FALSE, &LocaleId);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("ZwQueryDefaultLocale() failed with status 0x%lx\n", Status);
- return Status;
- }
-
- /*
- * FIXME: For critical errors, cleanup and disable device, but always
- * return STATUS_SUCCESS.
- */
DPRINT("Sending IRP_MN_QUERY_ID.BusQueryDeviceID to device stack\n");
if (!NT_SUCCESS(Status))
{
DPRINT1("IopInitiatePnpIrp() failed (Status %x)\n", Status);
-
- /* We have to return success otherwise we abort the traverse operation */
- return STATUS_SUCCESS;
+ return Status;
}
/* Copy the device id string */
if (!NT_SUCCESS(Status))
{
DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
-
- /* We have to return success otherwise we abort the traverse operation */
- return STATUS_SUCCESS;
+ return Status;
}
/* This bit is only check after enumeration */
{
/* FIXME: Cleanup device */
DeviceNode->Flags |= DNF_DISABLED;
- return STATUS_SUCCESS;
+ return STATUS_PLUGPLAY_NO_DEVICE;
}
else
{
if (!NT_SUCCESS(Status))
{
DPRINT1("IopGetParentIdPrefix() failed (Status 0x%08lx)\n", Status);
-
- /* We have to return success otherwise we abort the traverse operation */
- return STATUS_SUCCESS;
+ return Status;
}
}
}
RtlFreeUnicodeString(&ParentIdPrefix);
- if (!RtlCreateUnicodeString(&InstancePathU, InstancePath))
+ if (!RtlCreateUnicodeString(InstancePathU, InstancePath))
{
- DPRINT("No resources\n");
- /* FIXME: Cleanup and disable device */
+ DPRINT1("RtlCreateUnicodeString failed\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+
+/*
+ * IopActionInterrogateDeviceStack
+ *
+ * Retrieve information for all (direct) child nodes of a parent node.
+ *
+ * Parameters
+ * DeviceNode
+ * Pointer to device node.
+ * Context
+ * Pointer to parent node to retrieve child node information for.
+ *
+ * Remarks
+ * Any errors that occur are logged instead so that all child services have a chance
+ * of being interrogated.
+ */
+
+NTSTATUS
+IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
+ PVOID Context)
+{
+ IO_STATUS_BLOCK IoStatusBlock;
+ PWSTR InformationString;
+ PDEVICE_NODE ParentDeviceNode;
+ IO_STACK_LOCATION Stack;
+ NTSTATUS Status;
+ ULONG RequiredLength;
+ LCID LocaleId;
+ HANDLE InstanceKey = NULL;
+ UNICODE_STRING ValueName;
+ UNICODE_STRING InstancePathU;
+ PDEVICE_OBJECT OldDeviceObject;
+
+ DPRINT("IopActionInterrogateDeviceStack(%p, %p)\n", DeviceNode, Context);
+ DPRINT("PDO 0x%p\n", DeviceNode->PhysicalDeviceObject);
+
+ ParentDeviceNode = (PDEVICE_NODE)Context;
+
+ /*
+ * We are called for the parent too, but we don't need to do special
+ * handling for this node
+ */
+ if (DeviceNode == ParentDeviceNode)
+ {
+ DPRINT("Success\n");
+ return STATUS_SUCCESS;
+ }
+
+ /*
+ * Make sure this device node is a direct child of the parent device node
+ * that is given as an argument
+ */
+ if (DeviceNode->Parent != ParentDeviceNode)
+ {
+ DPRINT("Skipping 2+ level child\n");
+ return STATUS_SUCCESS;
+ }
+
+ /* Skip processing if it was already completed before */
+ if (DeviceNode->Flags & DNF_PROCESSED)
+ {
+ /* Nothing to do */
+ return STATUS_SUCCESS;
+ }
+
+ /* Get Locale ID */
+ Status = ZwQueryDefaultLocale(FALSE, &LocaleId);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("ZwQueryDefaultLocale() failed with status 0x%lx\n", Status);
+ return Status;
+ }
+
+ /*
+ * FIXME: For critical errors, cleanup and disable device, but always
+ * return STATUS_SUCCESS.
+ */
+
+ Status = IopCreateDeviceInstancePath(DeviceNode, &InstancePathU);
+ if (!NT_SUCCESS(Status))
+ {
+ if (Status != STATUS_PLUGPLAY_NO_DEVICE)
+ {
+ DPRINT1("IopCreateDeviceInstancePath() failed with status 0x%lx\n", Status);
+ }
+
+ /* We have to return success otherwise we abort the traverse operation */
+ return STATUS_SUCCESS;
}
/* Verify that this is not a duplicate */