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.
13 Get SymblicName from Parameters in Registry Key
14 Caller is responsible for freeing pool of returned pointer
17 GetSymbolicName(PDEVICE_OBJECT DeviceObject
)
21 UNICODE_STRING SymbolicName
;
22 PKEY_VALUE_PARTIAL_INFORMATION KeyPartInfo
;
24 PWCHAR SymbolicNameString
= NULL
;
26 Status
= IoOpenDeviceRegistryKey(DeviceObject
,
27 PLUGPLAY_REGKEY_DEVICE
,
31 DPRINT("IoOpenDeviceRegistryKey PLUGPLAY_REGKEY_DEVICE Status %x\n", Status
);
33 if (NT_SUCCESS(Status
))
35 RtlInitUnicodeString(&SymbolicName
, L
"SymbolicName");
36 Status
= ZwQueryValueKey(DevInstRegKey
,
38 KeyValuePartialInformation
,
43 DPRINT("ZwQueryValueKey status %x, %d\n", Status
, SizeNeeded
);
45 if (Status
== STATUS_BUFFER_TOO_SMALL
)
47 KeyPartInfo
= (PKEY_VALUE_PARTIAL_INFORMATION
) ExAllocatePool(PagedPool
, SizeNeeded
);
50 DPRINT1("OUT OF MEMORY\n");
55 Status
= ZwQueryValueKey(DevInstRegKey
,
57 KeyValuePartialInformation
,
62 SymbolicNameString
= ExAllocatePool(PagedPool
, (KeyPartInfo
->DataLength
+ sizeof(WCHAR
)));
63 if (!SymbolicNameString
)
67 RtlZeroMemory(SymbolicNameString
, KeyPartInfo
->DataLength
+ 2);
68 RtlCopyMemory(SymbolicNameString
, KeyPartInfo
->Data
, KeyPartInfo
->DataLength
);
71 ExFreePool(KeyPartInfo
);
74 ZwClose(DevInstRegKey
);
77 return SymbolicNameString
;
81 Get Physical Device Object Name from registry
82 Caller is responsible for freeing pool
85 GetPhysicalDeviceObjectName(PDEVICE_OBJECT DeviceObject
)
88 PWSTR ObjectName
= NULL
;
91 Status
= IoGetDeviceProperty(DeviceObject
,
92 DevicePropertyPhysicalDeviceObjectName
,
97 if (Status
!= STATUS_BUFFER_TOO_SMALL
)
99 DPRINT1("Expected STATUS_BUFFER_TOO_SMALL, got %x!\n", Status
);
103 ObjectName
= (PWSTR
) ExAllocatePool(PagedPool
, SizeNeeded
+ sizeof(WCHAR
));
106 DPRINT1("Out of memory\n");
110 Status
= IoGetDeviceProperty(DeviceObject
,
111 DevicePropertyPhysicalDeviceObjectName
,
115 if (!NT_SUCCESS(Status
))
117 DPRINT1("Failed to Get Property\n");