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>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@ -112,33 +112,11 @@ namespace Fsp
}
public void SetPrefix(String Prefix)
{
int Size = Prefix.Length;
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';
}
}
_VolumeParams.Prefix = Prefix;
}
public void SetFileSystemName(String FileSystemName)
{
int Size = FileSystemName.Length;
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';
}
}
_VolumeParams.FileSystemName = FileSystemName;
}
private VolumeParams _VolumeParams;

View File

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