From 1e40ac4cdef9f93f19399bdc32f4d7b156d9417d Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 30 Nov 2018 14:41:53 +0200 Subject: [PATCH] NTFileSystemAdapter: Added support for alternate data streams --- .../Adapter/NTFileSystemAdapter.Query.cs | 15 ++++++++++----- .../NTFileStore/Adapter/NTFileSystemAdapter.cs | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Query.cs b/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Query.cs index b423dec..c2ceec8 100644 --- a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.Query.cs +++ b/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. // A buffer of FileStreamInformation data elements is returned by the server. 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> dataStreams = m_fileSystem.ListDataStreams(fileHandle.Path); + foreach (KeyValuePair 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; return NTStatus.STATUS_SUCCESS; } diff --git a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.cs b/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.cs index 9613d53..1fd62fd 100644 --- a/SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.cs +++ b/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. - if (path.Contains(":")) + if (!m_fileSystem.SupportsNamedStreams && path.Contains(":")) { // Windows Server 2003 will return STATUS_OBJECT_NAME_NOT_FOUND return NTStatus.STATUS_NO_SUCH_FILE;