From 320ad29ff4e60f687909c6866306aa983832f707 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 18 Aug 2011 17:32:26 +0000 Subject: [PATCH] [NTOSKRNL] - Return an informational success status if the device interface already exists svn path=/trunk/; revision=53301 --- reactos/ntoskrnl/io/iomgr/deviface.c | 52 +++++++++++++++------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/deviface.c b/reactos/ntoskrnl/io/iomgr/deviface.c index 0a52f2aaf8d..e0a0b78b769 100644 --- a/reactos/ntoskrnl/io/iomgr/deviface.c +++ b/reactos/ntoskrnl/io/iomgr/deviface.c @@ -1136,23 +1136,6 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, } RtlAppendUnicodeToString(SymbolicLinkName, L"#"); RtlAppendUnicodeStringToString(SymbolicLinkName, &GuidString); - SymbolicLinkName->Buffer[SymbolicLinkName->Length/sizeof(WCHAR)] = L'\0'; - - /* Create symbolic link */ - DPRINT("IoRegisterDeviceInterface(): creating symbolic link %wZ -> %wZ\n", SymbolicLinkName, &PdoNameInfo->Name); - Status = IoCreateSymbolicLink(SymbolicLinkName, &PdoNameInfo->Name); - if (!NT_SUCCESS(Status) && ReferenceString == NULL) - { - DPRINT1("IoCreateSymbolicLink() failed with status 0x%08lx\n", Status); - ZwClose(SubKey); - ZwClose(InterfaceKey); - ZwClose(ClassKey); - ExFreePool(SubKeyName.Buffer); - ExFreePool(InterfaceKeyName.Buffer); - ExFreePool(BaseKeyName.Buffer); - ExFreePool(SymbolicLinkName->Buffer); - return Status; - } if (ReferenceString && ReferenceString->Length) { @@ -1163,13 +1146,12 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, /* Write symbolic link name in registry */ SymbolicLinkName->Buffer[1] = '\\'; - Status = ZwSetValueKey( - SubKey, - &SymbolicLink, - 0, /* TileIndex */ - REG_SZ, - SymbolicLinkName->Buffer, - SymbolicLinkName->Length); + Status = ZwSetValueKey(SubKey, + &SymbolicLink, + 0, /* TileIndex */ + REG_SZ, + SymbolicLinkName->Buffer, + SymbolicLinkName->Length); if (!NT_SUCCESS(Status)) { DPRINT1("ZwSetValueKey() failed with status 0x%08lx\n", Status); @@ -1180,6 +1162,28 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, SymbolicLinkName->Buffer[1] = '?'; } + /* Create symbolic link */ + DPRINT("IoRegisterDeviceInterface(): creating symbolic link %wZ -> %wZ\n", SymbolicLinkName, &PdoNameInfo->Name); + Status = IoCreateSymbolicLink(SymbolicLinkName, &PdoNameInfo->Name); + + /* If the symbolic link already exists, return an informational success status */ + if (Status == STATUS_OBJECT_NAME_COLLISION) + Status = STATUS_OBJECT_NAME_EXISTS; + + /* Check if it really failed */ + if (!NT_SUCCESS(Status)) + { + DPRINT1("IoCreateSymbolicLink() failed with status 0x%08lx\n", Status); + ZwClose(SubKey); + ZwClose(InterfaceKey); + ZwClose(ClassKey); + ExFreePool(SubKeyName.Buffer); + ExFreePool(InterfaceKeyName.Buffer); + ExFreePool(BaseKeyName.Buffer); + ExFreePool(SymbolicLinkName->Buffer); + return Status; + } + ZwClose(SubKey); ZwClose(InterfaceKey); ZwClose(ClassKey);