Make IoGetDeviceObjectFromDeviceInstance work without using the Registry. (experimental) Modified: trunk/reactos/ntoskrnl/io/plugplay.c _____
Modified: trunk/reactos/ntoskrnl/io/plugplay.c --- trunk/reactos/ntoskrnl/io/plugplay.c 2005-07-21 20:10:47 UTC (rev 16685) +++ trunk/reactos/ntoskrnl/io/plugplay.c 2005-07-21 20:30:55 UTC (rev 16686) @@ -224,8 +224,35 @@
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 @@ 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 @@ 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) {