[NTOSKRNL]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 18 Feb 2014 19:53:48 +0000 (19:53 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 18 Feb 2014 19:53:48 +0000 (19:53 +0000)
Fix returned symbolic links in IoGetDeviceInterfaces.

svn path=/trunk/; revision=62249

reactos/ntoskrnl/io/iomgr/deviface.c

index 980ef17..4c4f618 100644 (file)
@@ -466,7 +466,7 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
         goto cleanup;
     }
 
-    /* Enumerate subkeys (ie the different device objets) */
+    /* Enumerate subkeys (i.e. the different device objects) */
     while (TRUE)
     {
         Status = ZwEnumerateKey(
@@ -729,14 +729,17 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
                 Status = STATUS_UNSUCCESSFUL;
                 goto cleanup;
             }
-            KeyName.Length = KeyName.MaximumLength = (USHORT)bip->DataLength - 4 * sizeof(WCHAR);
-            KeyName.Buffer = &((PWSTR)bip->Data)[4];
+            KeyName.Length = KeyName.MaximumLength = (USHORT)bip->DataLength;
+            KeyName.Buffer = (PWSTR)bip->Data;
+
+            /* Fixup the prefix (from "\\?\") */
+            RtlCopyMemory(KeyName.Buffer, L"\\??\\", 4 * sizeof(WCHAR));
 
             /* Add new symbolic link to symbolic link list */
             if (ReturnBuffer.Length + KeyName.Length + sizeof(WCHAR) > ReturnBuffer.MaximumLength)
             {
                 PWSTR NewBuffer;
-                ReturnBuffer.MaximumLength = (USHORT)max(ReturnBuffer.MaximumLength * 2,
+                ReturnBuffer.MaximumLength = (USHORT)max(ReturnBuffer.MaximumLength * sizeof(WCHAR),
                                                          (USHORT)(ReturnBuffer.Length +
                                                          KeyName.Length +
                                                          2 * sizeof(WCHAR)));