2 * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/usb/usbehci/misc.c
5 * PURPOSE: Misceallenous operations.
15 Get SymblicName from Parameters in Registry Key
16 Caller is responsible for freeing pool of returned pointer
19 GetSymbolicName(PDEVICE_OBJECT DeviceObject
)
23 UNICODE_STRING SymbolicName
;
24 PKEY_VALUE_PARTIAL_INFORMATION KeyPartInfo
;
26 PWCHAR SymbolicNameString
= NULL
;
28 Status
= IoOpenDeviceRegistryKey(DeviceObject
,
29 PLUGPLAY_REGKEY_DEVICE
,
33 DPRINT("IoOpenDeviceRegistryKey PLUGPLAY_REGKEY_DEVICE Status %x\n", Status
);
35 if (NT_SUCCESS(Status
))
37 RtlInitUnicodeString(&SymbolicName
, L
"SymbolicName");
38 Status
= ZwQueryValueKey(DevInstRegKey
,
40 KeyValuePartialInformation
,
45 DPRINT("ZwQueryValueKey status %x, %d\n", Status
, SizeNeeded
);
47 if (Status
== STATUS_BUFFER_TOO_SMALL
)
49 KeyPartInfo
= (PKEY_VALUE_PARTIAL_INFORMATION
) ExAllocatePool(PagedPool
, SizeNeeded
);
52 DPRINT1("OUT OF MEMORY\n");
57 Status
= ZwQueryValueKey(DevInstRegKey
,
59 KeyValuePartialInformation
,
64 SymbolicNameString
= ExAllocatePool(PagedPool
, (KeyPartInfo
->DataLength
+ sizeof(WCHAR
)));
65 if (!SymbolicNameString
)
69 RtlZeroMemory(SymbolicNameString
, KeyPartInfo
->DataLength
+ 2);
70 RtlCopyMemory(SymbolicNameString
, KeyPartInfo
->Data
, KeyPartInfo
->DataLength
);
73 ExFreePool(KeyPartInfo
);
76 ZwClose(DevInstRegKey
);
79 return SymbolicNameString
;
83 Get Physical Device Object Name from registry
84 Caller is responsible for freeing pool
87 GetPhysicalDeviceObjectName(PDEVICE_OBJECT DeviceObject
)
90 PWSTR ObjectName
= NULL
;
93 Status
= IoGetDeviceProperty(DeviceObject
,
94 DevicePropertyPhysicalDeviceObjectName
,
99 if (Status
!= STATUS_BUFFER_TOO_SMALL
)
101 DPRINT1("Expected STATUS_BUFFER_TOO_SMALL, got %x!\n", Status
);
105 ObjectName
= (PWSTR
) ExAllocatePool(PagedPool
, SizeNeeded
+ sizeof(WCHAR
));
108 DPRINT1("Out of memory\n");
112 Status
= IoGetDeviceProperty(DeviceObject
,
113 DevicePropertyPhysicalDeviceObjectName
,
117 if (!NT_SUCCESS(Status
))
119 DPRINT1("Failed to Get Property\n");
126 PUSB_DEVICE
DeviceHandleToUsbDevice(PPDO_DEVICE_EXTENSION PdoDeviceExtension
, PUSB_DEVICE_HANDLE DeviceHandle
)
130 for (i
=0; i
<127; i
++)
132 if (PdoDeviceExtension
->UsbDevices
[i
] == (PUSB_DEVICE
)DeviceHandle
)
133 return (PUSB_DEVICE
)DeviceHandle
;