src: dotnet: WIP

This commit is contained in:
Bill Zissimopoulos 2017-04-02 11:44:25 -07:00
parent 8e7e959d8a
commit 02cec420e7
3 changed files with 15 additions and 33 deletions

View File

@ -24,7 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>

View File

@ -112,33 +112,11 @@ namespace Fsp
} }
public void SetPrefix(String Prefix) public void SetPrefix(String Prefix)
{ {
int Size = Prefix.Length; _VolumeParams.Prefix = Prefix;
if (Size > VolumeParams.PrefixSize - 1)
Size = VolumeParams.PrefixSize - 1;
unsafe
{
fixed (UInt16 *P = _VolumeParams.Prefix)
{
for (int I = 0; Size > I; I++)
P[I] = Prefix[I];
P[Size] = '\0';
}
}
} }
public void SetFileSystemName(String FileSystemName) public void SetFileSystemName(String FileSystemName)
{ {
int Size = FileSystemName.Length; _VolumeParams.FileSystemName = FileSystemName;
if (Size > VolumeParams.FileSystemNameSize - 1)
Size = VolumeParams.FileSystemNameSize - 1;
unsafe
{
fixed (UInt16 *P = _VolumeParams.FileSystemName)
{
for (int I = 0; Size > I; I++)
P[I] = FileSystemName[I];
P[Size] = '\0';
}
}
} }
private VolumeParams _VolumeParams; private VolumeParams _VolumeParams;

View File

@ -22,7 +22,7 @@ using System.Security;
namespace Fsp.Interop namespace Fsp.Interop
{ {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct VolumeParams internal struct VolumeParams
{ {
/* const */ /* const */
@ -56,17 +56,22 @@ namespace Fsp.Interop
internal UInt32 IrpCapacity; internal UInt32 IrpCapacity;
internal UInt32 FileInfoTimeout; internal UInt32 FileInfoTimeout;
internal UInt32 Flags; internal UInt32 Flags;
internal unsafe fixed UInt16 Prefix[PrefixSize]; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = PrefixSize)]
internal unsafe fixed UInt16 FileSystemName[FileSystemNameSize]; internal String Prefix;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = FileSystemNameSize)]
internal String FileSystemName;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct VolumeInfo internal struct VolumeInfo
{ {
internal const int VolumeLabelSize = 32;
internal UInt64 TotalSize; internal UInt64 TotalSize;
internal UInt64 FreeSize; internal UInt64 FreeSize;
internal UInt16 VolumeLabelLength; internal UInt16 VolumeLabelLength;
internal unsafe fixed UInt16 VolumeLabel[32]; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = VolumeLabelSize)]
internal String VolumeLabel;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
@ -97,7 +102,7 @@ namespace Fsp.Interop
{ {
internal UInt16 Size; internal UInt16 Size;
internal FileInfo FileInfo; internal FileInfo FileInfo;
internal unsafe fixed Byte Padding[24]; //internal unsafe fixed Byte Padding[24];
//internal unsafe fixed UInt16 FileNameBuf[]; //internal unsafe fixed UInt16 FileNameBuf[];
} }
@ -304,8 +309,7 @@ namespace Fsp.Interop
UInt32 Length, UInt32 Length,
out UInt32 PBytesTransferred); out UInt32 PBytesTransferred);
internal unsafe fixed ulong Reserved[40]; //internal unsafe fixed IntPtr Reserved[40];
/* cannot use IntPtr with fixed; on 32-bit struct will be too long, but that's ok */
} }
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]