[NTOSKRNL] Use faster internal helper to query name
authorPierre Schweitzer <pierre@reactos.org>
Wed, 3 Oct 2018 08:21:39 +0000 (10:21 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Wed, 3 Oct 2018 08:22:33 +0000 (10:22 +0200)
This only applies if we're called from kernel mode
with a synchronous file.

ntoskrnl/include/internal/io.h
ntoskrnl/io/iomgr/file.c

index 29ecb80..95e3607 100644 (file)
@@ -1276,6 +1276,16 @@ IoComputeDesiredAccessFileObject(
     IN PACCESS_MASK DesiredAccess
 );
 
+NTSTATUS
+NTAPI
+IopGetFileInformation(
+    IN PFILE_OBJECT FileObject,
+    IN ULONG Length,
+    IN FILE_INFORMATION_CLASS FileInfoClass,
+    OUT PVOID Buffer,
+    OUT PULONG ReturnedLength
+);
+
 //
 // I/O Timer Routines
 //
index 4cbdb64..e877888 100644 (file)
@@ -1941,11 +1941,23 @@ IopQueryNameInternal(IN PVOID ObjectBody,
                  FIELD_OFFSET(FILE_NAME_INFORMATION, FileName);
 
     /* Query the File name */
-    Status = IoQueryFileInformation(FileObject,
-                                    FileNameInformation,
-                                    LengthMismatch ? Length : FileLength,
-                                    LocalFileInfo,
-                                    &LocalReturnLength);
+    if (PreviousMode == KernelMode &&
+        BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO))
+    {
+        Status = IopGetFileInformation(FileObject,
+                                       LengthMismatch ? Length : FileLength,
+                                       FileNameInformation,
+                                       LocalFileInfo,
+                                       &LocalReturnLength);
+    }
+    else
+    {
+        Status = IoQueryFileInformation(FileObject,
+                                        FileNameInformation,
+                                        LengthMismatch ? Length : FileLength,
+                                        LocalFileInfo,
+                                        &LocalReturnLength);
+    }
     if (NT_ERROR(Status))
     {
         /* Fail on errors only, allow warnings */