mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fix string returned by IoRegisterDeviceInterface()
svn path=/trunk/; revision=15899
This commit is contained in:
parent
d520f41934
commit
a189416191
1 changed files with 32 additions and 7 deletions
|
@ -830,6 +830,7 @@ IoRegisterDeviceInterface(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write symbolic link name in registry */
|
/* Write symbolic link name in registry */
|
||||||
|
SymbolicLinkName->Buffer[1] = '\\';
|
||||||
Status = ZwSetValueKey(
|
Status = ZwSetValueKey(
|
||||||
SubKey,
|
SubKey,
|
||||||
&SymbolicLink,
|
&SymbolicLink,
|
||||||
|
@ -843,6 +844,14 @@ IoRegisterDeviceInterface(
|
||||||
ExFreePool(SymbolicLinkName->Buffer);
|
ExFreePool(SymbolicLinkName->Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove \\?\ at the start of symbolic link name */
|
||||||
|
SymbolicLinkName->Length -= 4 * sizeof(WCHAR);
|
||||||
|
SymbolicLinkName->MaximumLength -= 4 * sizeof(WCHAR);
|
||||||
|
RtlMoveMemory(
|
||||||
|
SymbolicLinkName->Buffer,
|
||||||
|
&SymbolicLinkName->Buffer[4],
|
||||||
|
SymbolicLinkName->Length);
|
||||||
|
|
||||||
ZwClose(SubKey);
|
ZwClose(SubKey);
|
||||||
ZwClose(InterfaceKey);
|
ZwClose(InterfaceKey);
|
||||||
ZwClose(ClassKey);
|
ZwClose(ClassKey);
|
||||||
|
@ -864,6 +873,7 @@ IoSetDeviceInterfaceState(
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT PhysicalDeviceObject;
|
PDEVICE_OBJECT PhysicalDeviceObject;
|
||||||
PFILE_OBJECT FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
|
UNICODE_STRING ObjectName;
|
||||||
UNICODE_STRING GuidString;
|
UNICODE_STRING GuidString;
|
||||||
PWCHAR StartPosition;
|
PWCHAR StartPosition;
|
||||||
PWCHAR EndPosition;
|
PWCHAR EndPosition;
|
||||||
|
@ -873,14 +883,8 @@ IoSetDeviceInterfaceState(
|
||||||
return STATUS_INVALID_PARAMETER_1;
|
return STATUS_INVALID_PARAMETER_1;
|
||||||
|
|
||||||
DPRINT("IoSetDeviceInterfaceState('%wZ', %d)\n", SymbolicLinkName, Enable);
|
DPRINT("IoSetDeviceInterfaceState('%wZ', %d)\n", SymbolicLinkName, Enable);
|
||||||
Status = IoGetDeviceObjectPointer(SymbolicLinkName,
|
|
||||||
0, /* DesiredAccess */
|
|
||||||
&FileObject,
|
|
||||||
&PhysicalDeviceObject);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
return Status;
|
|
||||||
|
|
||||||
/* Symbolic link name is \??\ACPI#PNP0501#1#{GUID}\ReferenceString */
|
/* Symbolic link name is ACPI#PNP0501#1#{GUID}\ReferenceString */
|
||||||
/* Get GUID from SymbolicLinkName */
|
/* Get GUID from SymbolicLinkName */
|
||||||
StartPosition = wcschr(SymbolicLinkName->Buffer, L'{');
|
StartPosition = wcschr(SymbolicLinkName->Buffer, L'{');
|
||||||
EndPosition = wcschr(SymbolicLinkName->Buffer, L'}');
|
EndPosition = wcschr(SymbolicLinkName->Buffer, L'}');
|
||||||
|
@ -889,6 +893,26 @@ IoSetDeviceInterfaceState(
|
||||||
GuidString.Buffer = StartPosition;
|
GuidString.Buffer = StartPosition;
|
||||||
GuidString.MaximumLength = GuidString.Length = (ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)StartPosition;
|
GuidString.MaximumLength = GuidString.Length = (ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)StartPosition;
|
||||||
|
|
||||||
|
/* Create \??\SymbolicLinkName string */
|
||||||
|
ObjectName.Length = 0;
|
||||||
|
ObjectName.MaximumLength = SymbolicLinkName->Length + 4 * sizeof(WCHAR);
|
||||||
|
ObjectName.Buffer = ExAllocatePool(PagedPool, ObjectName.MaximumLength);
|
||||||
|
if (!ObjectName.Buffer)
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
RtlAppendUnicodeToString(&ObjectName, L"\\??\\");
|
||||||
|
RtlAppendUnicodeStringToString(&ObjectName, SymbolicLinkName);
|
||||||
|
|
||||||
|
/* Get pointer to the PDO */
|
||||||
|
Status = IoGetDeviceObjectPointer(&ObjectName,
|
||||||
|
0, /* DesiredAccess */
|
||||||
|
&FileObject,
|
||||||
|
&PhysicalDeviceObject);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ExFreePool(ObjectName.Buffer);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
IopNotifyPlugPlayNotification(
|
IopNotifyPlugPlayNotification(
|
||||||
PhysicalDeviceObject,
|
PhysicalDeviceObject,
|
||||||
EventCategoryDeviceInterfaceChange,
|
EventCategoryDeviceInterfaceChange,
|
||||||
|
@ -897,6 +921,7 @@ IoSetDeviceInterfaceState(
|
||||||
(PVOID)SymbolicLinkName);
|
(PVOID)SymbolicLinkName);
|
||||||
|
|
||||||
ObDereferenceObject(FileObject);
|
ObDereferenceObject(FileObject);
|
||||||
|
ExFreePool(ObjectName.Buffer);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue