Make IoGetDeviceObjectFromDeviceInstance work without using the Registry. (experimental)

svn path=/trunk/; revision=16686
This commit is contained in:
Eric Kohl 2005-07-21 20:30:55 +00:00
parent 446d367792
commit c85a086e9e

View file

@ -223,9 +223,36 @@ NtGetPlugPlayEvent(IN ULONG Reserved1,
}
static PDEVICE_OBJECT
IopTraverseDeviceNode(PDEVICE_NODE Node, PUNICODE_STRING DeviceInstance)
{
PDEVICE_OBJECT DeviceObject;
PDEVICE_NODE ChildNode;
if (RtlEqualUnicodeString(&Node->InstancePath,
DeviceInstance, TRUE))
return Node->PhysicalDeviceObject;
/* Traversal of all children nodes */
for (ChildNode = Node->Child;
ChildNode != NULL;
ChildNode = ChildNode->NextSibling)
{
DeviceObject = IopTraverseDeviceNode(ChildNode, DeviceInstance);
if (DeviceObject != NULL)
{
return DeviceObject;
}
}
return NULL;
}
static PDEVICE_OBJECT
IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
{
#if 0
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName, ValueName;
LPWSTR KeyNameBuffer;
@ -308,7 +335,7 @@ IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
ZwClose(ControlKeyHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to open the 'Control' key (Status %lx)\n", Status);
DPRINT1("Failed to query the 'DeviceReference' value (Status %lx)\n", Status);
return NULL;
}
@ -336,9 +363,30 @@ IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
DPRINT("IopGetDeviceObjectFromDeviceInstance() done\n");
return DeviceObject;
#endif
if (IopRootDeviceNode == NULL)
return NULL;
if (DeviceInstance == NULL ||
DeviceInstance->Length == 0
)
{
if (IopRootDeviceNode->PhysicalDeviceObject)
{
ObReferenceObject(IopRootDeviceNode->PhysicalDeviceObject);
return IopRootDeviceNode->PhysicalDeviceObject;
}
else
return NULL;
}
return IopTraverseDeviceNode(IopRootDeviceNode, DeviceInstance);
}
static NTSTATUS
IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
{