NTFileSystemAdapter: Added support for alternate data streams

This commit is contained in:
Tal Aloni 2018-11-30 14:41:53 +02:00
parent 73b6c288a4
commit 1e40ac4cde
2 changed files with 11 additions and 6 deletions

View file

@ -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<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;
return NTStatus.STATUS_SUCCESS;
}

View file

@ -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;