diff --git a/build/VStudio/winfsp.net.csproj b/build/VStudio/winfsp.net.csproj
index e8b9e06c..695a13e0 100644
--- a/build/VStudio/winfsp.net.csproj
+++ b/build/VStudio/winfsp.net.csproj
@@ -24,7 +24,7 @@
DEBUG;TRACE
prompt
4
- false
+ true
pdbonly
diff --git a/src/dotnet/FileSystem.cs b/src/dotnet/FileSystem.cs
index 6b8737d1..ee5b70e2 100644
--- a/src/dotnet/FileSystem.cs
+++ b/src/dotnet/FileSystem.cs
@@ -111,18 +111,18 @@ namespace Fsp
}
public void SetPrefix(String Prefix)
{
- _VolumeParams.Prefix = Prefix;
+ _VolumeParams.SetPrefix(Prefix);
}
public void SetFileSystemName(String FileSystemName)
{
- _VolumeParams.FileSystemName = FileSystemName;
+ _VolumeParams.SetFileSystemName(FileSystemName);
}
/* control */
Int32 Preflight(String MountPoint)
{
return Api.FspFileSystemPreflight(
- 0 < _VolumeParams.Prefix.Length ? "WinFsp.Net" : "WinFsp.Disk",
+ _VolumeParams.IsPrefixEmpty() ? "WinFsp.Disk" : "WinFsp.Net",
MountPoint);
}
Int32 Mount(String MountPoint,
@@ -130,11 +130,10 @@ namespace Fsp
Boolean Synchronized = false,
UInt32 DebugLog = 0)
{
- FileSystemInterface Intf; // ???: padding
Int32 Result;
Result = Api.FspFileSystemCreate(
- 0 < _VolumeParams.Prefix.Length ? "WinFsp.Net" : "WinFsp.Disk",
- ref _VolumeParams, ref Intf, out _FileSystem);
+ _VolumeParams.IsPrefixEmpty() ? "WinFsp.Disk" : "WinFsp.Net",
+ ref _VolumeParams, ref _FileSystemInterface, out _FileSystem);
if (0 <= Result)
{
#if false
@@ -144,7 +143,8 @@ namespace Fsp
FSP_FILE_SYSTEM_OPERATION_GUARD_STRATEGY_FINE);
FspFileSystemSetDebugLog(_FileSystem, DebugLog);
#endif
- Result = Api.FspFileSystemSetMountPointEx(_FileSystem, MountPoint, IntPtr.Zero);
+ Result = Api.FspFileSystemSetMountPointEx(_FileSystem, MountPoint,
+ SecurityDescriptor);
if (0 <= Result)
Result = Api.FspFileSystemStartDispatcher(_FileSystem, 0);
}
@@ -172,6 +172,7 @@ namespace Fsp
return _FileSystem;
}
+ private static FileSystemInterface _FileSystemInterface;
private VolumeParams _VolumeParams;
private IntPtr _FileSystem;
}
diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs
index c365dd86..a4f8983a 100644
--- a/src/dotnet/Interop.cs
+++ b/src/dotnet/Interop.cs
@@ -16,6 +16,7 @@
*/
using System;
+using System.Security.AccessControl;
using System.Runtime.InteropServices;
using System.Security;
@@ -56,10 +57,39 @@ namespace Fsp.Interop
internal UInt32 IrpCapacity;
internal UInt32 FileInfoTimeout;
internal UInt32 Flags;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = PrefixSize)]
- internal String Prefix;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = FileSystemNameSize)]
- internal String FileSystemName;
+ internal unsafe fixed UInt16 Prefix[PrefixSize];
+ internal unsafe fixed UInt16 FileSystemName[FileSystemNameSize];
+
+ /* helpers */
+ internal unsafe void SetPrefix(String Value)
+ {
+ fixed (UInt16 *P = Prefix)
+ {
+ int Size = Value.Length;
+ if (Size > PrefixSize - 1)
+ Size = PrefixSize - 1;
+ for (int I = 0; Size > I; I++)
+ P[I] = Value[I];
+ P[Size] = 0;
+ }
+ }
+ internal unsafe void SetFileSystemName(String Value)
+ {
+ fixed (UInt16 *P = FileSystemName)
+ {
+ int Size = Value.Length;
+ if (Size > FileSystemNameSize - 1)
+ Size = FileSystemNameSize - 1;
+ for (int I = 0; Size > I; I++)
+ P[I] = Value[I];
+ P[Size] = 0;
+ }
+ }
+ internal unsafe Boolean IsPrefixEmpty()
+ {
+ fixed (UInt16 *P = Prefix)
+ return 0 == *P;
+ }
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
@@ -70,8 +100,7 @@ namespace Fsp.Interop
internal UInt64 TotalSize;
internal UInt64 FreeSize;
internal UInt16 VolumeLabelLength;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = VolumeLabelSize)]
- internal String VolumeLabel;
+ internal unsafe fixed UInt16 VolumeLabel[VolumeLabelSize];
}
[StructLayout(LayoutKind.Sequential)]
@@ -102,7 +131,7 @@ namespace Fsp.Interop
{
internal UInt16 Size;
internal FileInfo FileInfo;
- //internal unsafe fixed Byte Padding[24];
+ internal unsafe fixed Byte Padding[24];
//internal unsafe fixed UInt16 FileNameBuf[];
}
@@ -309,7 +338,8 @@ namespace Fsp.Interop
UInt32 Length,
out UInt32 PBytesTransferred);
- //internal unsafe fixed IntPtr Reserved[40];
+ internal unsafe fixed long/*IntPtr*/ Reserved[40];
+ /* NTSTATUS (*Reserved[40])(); */
}
[SuppressUnmanagedCodeSecurity]
@@ -367,6 +397,22 @@ namespace Fsp.Interop
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
internal static extern UInt32 FspWin32FromNtStatus(
Int32 Status);
+
+ internal static unsafe Int32 FspFileSystemSetMountPointEx(
+ IntPtr FileSystem,
+ String MountPoint,
+ GenericSecurityDescriptor SecurityDescriptor)
+ {
+ if (null != SecurityDescriptor)
+ {
+ byte[] Bytes = new byte[SecurityDescriptor.BinaryLength];
+ SecurityDescriptor.GetBinaryForm(Bytes, 0);
+ fixed (byte *P = Bytes)
+ return FspFileSystemSetMountPointEx(FileSystem, MountPoint, (IntPtr)P);
+ }
+ else
+ return FspFileSystemSetMountPointEx(FileSystem, MountPoint, IntPtr.Zero);
+ }
}
internal static class Initializer