Browse Source

NTFileSystemAdapter: Added support for alternate data streams

Tal Aloni 6 years ago
parent
commit
1e40ac4cde

+ 10 - 5
SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Query.cs

@@ -125,11 +125,16 @@ namespace SMBLibrary
                         // This information class is used to enumerate the data streams of a file or a directory.
                         // This information class is used to enumerate the data streams of a file or a directory.
                         // A buffer of FileStreamInformation data elements is returned by the server.
                         // A buffer of FileStreamInformation data elements is returned by the server.
                         FileStreamInformation information = new FileStreamInformation();
                         FileStreamInformation information = new FileStreamInformation();
-                        FileStreamEntry streamEntry = new FileStreamEntry();
-                        streamEntry.StreamSize = (long)entry.Size;
-                        streamEntry.StreamAllocationSize = (long)GetAllocationSize(entry.Size);
-                        streamEntry.StreamName = "::$DATA";
-                        information.Entries.Add(streamEntry);
+                        List<KeyValuePair<string, ulong>> dataStreams = m_fileSystem.ListDataStreams(fileHandle.Path);
+                        foreach (KeyValuePair<string, ulong> dataStream in dataStreams)
+                        {
+                            FileStreamEntry streamEntry = new FileStreamEntry();
+                            ulong streamSize = dataStream.Value;
+                            streamEntry.StreamSize = (long)streamSize;
+                            streamEntry.StreamAllocationSize = (long)GetAllocationSize(streamSize);
+                            streamEntry.StreamName = dataStream.Key;
+                            information.Entries.Add(streamEntry);
+                        }
                         result = information;
                         result = information;
                         return NTStatus.STATUS_SUCCESS;
                         return NTStatus.STATUS_SUCCESS;
                     }
                     }

+ 1 - 1
SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.cs

@@ -44,7 +44,7 @@ namespace SMBLibrary
             }
             }
 
 
             // Windows will try to access named streams (alternate data streams) regardless of the FILE_NAMED_STREAMS flag, we need to prevent this behaviour.
             // Windows will try to access named streams (alternate data streams) regardless of the FILE_NAMED_STREAMS flag, we need to prevent this behaviour.
-            if (path.Contains(":"))
+            if (!m_fileSystem.SupportsNamedStreams && path.Contains(":"))
             {
             {
                 // Windows Server 2003 will return STATUS_OBJECT_NAME_NOT_FOUND
                 // Windows Server 2003 will return STATUS_OBJECT_NAME_NOT_FOUND
                 return NTStatus.STATUS_NO_SUCH_FILE;
                 return NTStatus.STATUS_NO_SUCH_FILE;