Fix string returned by IoRegisterDeviceInterface() Modified: trunk/reactos/ntoskrnl/io/deviface.c _____
Modified: trunk/reactos/ntoskrnl/io/deviface.c --- trunk/reactos/ntoskrnl/io/deviface.c 2005-06-13 20:51:07 UTC (rev 15898) +++ trunk/reactos/ntoskrnl/io/deviface.c 2005-06-13 21:44:32 UTC (rev 15899) @@ -830,6 +830,7 @@
}
/* Write symbolic link name in registry */ + SymbolicLinkName->Buffer[1] = '\'; Status = ZwSetValueKey( SubKey, &SymbolicLink, @@ -843,6 +844,14 @@ 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(InterfaceKey); ZwClose(ClassKey); @@ -864,6 +873,7 @@ { PDEVICE_OBJECT PhysicalDeviceObject; PFILE_OBJECT FileObject; + UNICODE_STRING ObjectName; UNICODE_STRING GuidString; PWCHAR StartPosition; PWCHAR EndPosition; @@ -873,14 +883,8 @@ return STATUS_INVALID_PARAMETER_1;
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 */ StartPosition = wcschr(SymbolicLinkName->Buffer, L'{'); EndPosition = wcschr(SymbolicLinkName->Buffer, L'}'); @@ -889,6 +893,26 @@ GuidString.Buffer = 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( PhysicalDeviceObject, EventCategoryDeviceInterfaceChange, @@ -897,6 +921,7 @@ (PVOID)SymbolicLinkName);
ObDereferenceObject(FileObject); + ExFreePool(ObjectName.Buffer);
return STATUS_SUCCESS; }