From 5fb02a865bc7e6cc9888e60f3c40ee6819676a11 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Fri, 21 Aug 2009 10:02:25 +0000 Subject: [PATCH] - Reference strings are not part of the symbolic link. Therefore don't include them when creating the symbolic link (IoCreateSymbolicLink) - Reference strings are used by the kernel streaming system to distinguish kernel streaming filters. As it is perfectly possible, to provide more than one filter with same guid but different reference string, ignore the failure for now if IoCreateSymbolicLink fails See issue #4566 for more details. svn path=/trunk/; revision=42819 --- reactos/ntoskrnl/io/iomgr/deviface.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/deviface.c b/reactos/ntoskrnl/io/iomgr/deviface.c index 34a50928897..d83124a7bbb 100644 --- a/reactos/ntoskrnl/io/iomgr/deviface.c +++ b/reactos/ntoskrnl/io/iomgr/deviface.c @@ -881,17 +881,12 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, } RtlAppendUnicodeToString(SymbolicLinkName, L"#"); RtlAppendUnicodeStringToString(SymbolicLinkName, &GuidString); - if (ReferenceString && ReferenceString->Length) - { - RtlAppendUnicodeToString(SymbolicLinkName, L"\\"); - RtlAppendUnicodeStringToString(SymbolicLinkName, ReferenceString); - } SymbolicLinkName->Buffer[SymbolicLinkName->Length/sizeof(WCHAR)] = L'\0'; /* Create symbolic link */ DPRINT1("IoRegisterDeviceInterface(): creating symbolic link %wZ -> %wZ\n", SymbolicLinkName, &PdoNameInfo->Name); Status = IoCreateSymbolicLink(SymbolicLinkName, &PdoNameInfo->Name); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status) && ReferenceString == NULL) { DPRINT("IoCreateSymbolicLink() failed with status 0x%08lx\n", Status); ZwClose(SubKey); @@ -904,6 +899,13 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, return Status; } + if (ReferenceString && ReferenceString->Length) + { + RtlAppendUnicodeToString(SymbolicLinkName, L"\\"); + RtlAppendUnicodeStringToString(SymbolicLinkName, ReferenceString); + } + SymbolicLinkName->Buffer[SymbolicLinkName->Length/sizeof(WCHAR)] = L'\0'; + /* Write symbolic link name in registry */ SymbolicLinkName->Buffer[1] = '\\'; Status = ZwSetValueKey( @@ -958,11 +960,13 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, PDEVICE_OBJECT PhysicalDeviceObject; PFILE_OBJECT FileObject; UNICODE_STRING GuidString; + UNICODE_STRING SymLink; PWCHAR StartPosition; PWCHAR EndPosition; NTSTATUS Status; LPCGUID EventGuid; + if (SymbolicLinkName == NULL) return STATUS_INVALID_PARAMETER_1; @@ -980,9 +984,13 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, GuidString.Buffer = StartPosition; GuidString.MaximumLength = GuidString.Length = (USHORT)((ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)StartPosition); + SymLink.Buffer = SymbolicLinkName->Buffer; + SymLink.MaximumLength = SymLink.Length = (USHORT)((ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)SymLink.Buffer); + + /* Get pointer to the PDO */ Status = IoGetDeviceObjectPointer( - SymbolicLinkName, + &SymLink, 0, /* DesiredAccess */ &FileObject, &PhysicalDeviceObject);