diff --git a/src/dotnet/FileSystemBase.cs b/src/dotnet/FileSystemBase.cs index 5325d55c..7844d76f 100644 --- a/src/dotnet/FileSystemBase.cs +++ b/src/dotnet/FileSystemBase.cs @@ -326,8 +326,33 @@ namespace Fsp UInt32 Length, out UInt32 BytesTransferred) { + Object Context = null; + String StreamName; + UInt64 StreamSize, StreamAllocationSize; + StreamInfo StreamInfo = default(StreamInfo); BytesTransferred = default(UInt32); - return STATUS_INVALID_DEVICE_REQUEST; + while (GetStreamEntry(FileNode, FileDesc, + ref Context, out StreamName, out StreamSize, out StreamAllocationSize)) + { + StreamInfo.SetStreamNameBuf(StreamName); + if (!Api.FspFileSystemAddStreamInfo(ref StreamInfo, Buffer, Length, + out BytesTransferred)) + break; + } + return STATUS_SUCCESS; + } + public virtual Boolean GetStreamEntry( + Object FileNode, + Object FileDesc, + ref Object Context, + out String StreamName, + out UInt64 StreamSize, + out UInt64 StreamAllocationSize) + { + StreamName = default(String); + StreamSize = default(UInt64); + StreamAllocationSize = default(UInt64); + return false; } /* helpers */ diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index 149b33ee..0a78a7eb 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -164,7 +164,8 @@ namespace Fsp.Interop internal struct DirInfo { internal const int FileNameBufSize = 255; - internal static int FileNameBufOffset = (int)Marshal.OffsetOf(typeof(DirInfo), "FileNameBuf"); + internal static int FileNameBufOffset = + (int)Marshal.OffsetOf(typeof(DirInfo), "FileNameBuf"); internal UInt16 Size; internal FileInfo FileInfo; @@ -172,7 +173,7 @@ namespace Fsp.Interop //internal unsafe fixed UInt16 FileNameBuf[]; internal unsafe fixed UInt16 FileNameBuf[FileNameBufSize]; - public unsafe void SetFileNameBuf(String Value) + internal unsafe void SetFileNameBuf(String Value) { fixed (UInt16 *P = FileNameBuf) { @@ -189,10 +190,28 @@ namespace Fsp.Interop [StructLayout(LayoutKind.Sequential)] internal struct StreamInfo { + internal const int StreamNameBufSize = 255; + internal static int StreamNameBufOffset = + (int)Marshal.OffsetOf(typeof(StreamInfo), "StreamNameBuf"); + internal UInt16 Size; internal UInt64 StreamSize; internal UInt64 StreamAllocationSize; //internal unsafe fixed UInt16 StreamNameBuf[]; + internal unsafe fixed UInt16 StreamNameBuf[StreamNameBufSize]; + + internal unsafe void SetStreamNameBuf(String Value) + { + fixed (UInt16 *P = StreamNameBuf) + { + int Size = null != Value ? Value.Length : 0; + if (Size > StreamNameBufSize) + Size = StreamNameBufSize; + for (int I = 0; Size > I; I++) + P[I] = Value[I]; + this.Size = (UInt16)(StreamNameBufOffset + Size * 2); + } + } } [StructLayout(LayoutKind.Sequential)] @@ -621,7 +640,7 @@ namespace Fsp.Interop internal static Proto.FspFileSystemFindReparsePoint FspFileSystemFindReparsePoint; internal static Proto.FspFileSystemResolveReparsePoints FspFileSystemResolveReparsePoints; internal static Proto.FspFileSystemCanReplaceReparsePoint _FspFileSystemCanReplaceReparsePoint; - internal static Proto.FspFileSystemAddStreamInfo FspFileSystemAddStreamInfo; + internal static Proto.FspFileSystemAddStreamInfo _FspFileSystemAddStreamInfo; internal static Proto.FspFileSystemAcquireDirectoryBuffer FspFileSystemAcquireDirectoryBuffer; internal static Proto.FspFileSystemFillDirectoryBuffer FspFileSystemFillDirectoryBuffer; internal static Proto.FspFileSystemReleaseDirectoryBuffer FspFileSystemReleaseDirectoryBuffer; @@ -663,6 +682,15 @@ namespace Fsp.Interop fixed (DirInfo *P = &DirInfo) return _FspFileSystemAddDirInfo((IntPtr)P, Buffer, Length, out PBytesTransferred); } + internal static unsafe Boolean FspFileSystemAddStreamInfo( + ref StreamInfo StreamInfo, + IntPtr Buffer, + UInt32 Length, + out UInt32 PBytesTransferred) + { + fixed (StreamInfo *P = &StreamInfo) + return _FspFileSystemAddStreamInfo((IntPtr)P, Buffer, Length, out PBytesTransferred); + } internal unsafe static Object GetUserContext( IntPtr NativePtr) @@ -890,7 +918,7 @@ namespace Fsp.Interop FspFileSystemFindReparsePoint = GetEntryPoint(Module); FspFileSystemResolveReparsePoints = GetEntryPoint(Module); _FspFileSystemCanReplaceReparsePoint = GetEntryPoint(Module); - FspFileSystemAddStreamInfo = GetEntryPoint(Module); + _FspFileSystemAddStreamInfo = GetEntryPoint(Module); FspFileSystemAcquireDirectoryBuffer = GetEntryPoint(Module); FspFileSystemFillDirectoryBuffer = GetEntryPoint(Module); FspFileSystemReleaseDirectoryBuffer = GetEntryPoint(Module);