src: dotnet: WIP

This commit is contained in:
Bill Zissimopoulos 2017-04-02 16:36:10 -07:00
parent 5bc15a7e54
commit 39b60c1348
2 changed files with 461 additions and 169 deletions

View File

@ -172,6 +172,270 @@ namespace Fsp
return _FileSystem; return _FileSystem;
} }
/* FSP_FILE_SYSTEM_INTERFACE */
private static Int32 GetVolumeInfo(
IntPtr FileSystem,
out VolumeInfo VolumeInfo)
{
VolumeInfo = default(VolumeInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 SetVolumeLabel(
IntPtr FileSystem,
String VolumeLabel,
out VolumeInfo VolumeInfo)
{
VolumeInfo = default(VolumeInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 GetSecurityByName(
IntPtr FileSystem,
String FileName,
out UInt32 PFileAttributes/* or ReparsePointIndex */,
IntPtr SecurityDescriptor,
out UIntPtr PSecurityDescriptorSize)
{
PFileAttributes = default(UInt32);
PSecurityDescriptorSize = default(UIntPtr);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 Create(
IntPtr FileSystem,
String FileName,
UInt32 CreateOptions,
UInt32 GrantedAccess,
UInt32 FileAttributes,
IntPtr SecurityDescriptor,
UInt64 AllocationSize,
IntPtr PFileContext,
out FileInfo FileInfo)
{
FileInfo = default(FileInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 Open(
IntPtr FileSystem,
String FileName,
UInt32 CreateOptions,
UInt32 GrantedAccess,
IntPtr PFileContext,
out FileInfo FileInfo)
{
FileInfo = default(FileInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 Overwrite(
IntPtr FileSystem,
IntPtr FileContext,
UInt32 FileAttributes,
Boolean ReplaceFileAttributes,
UInt64 AllocationSize,
out FileInfo FileInfo)
{
FileInfo = default(FileInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static void Cleanup(
IntPtr FileSystem,
IntPtr FileContext,
String FileName,
UInt32 Flags)
{
}
private static void Close(
IntPtr FileSystem,
IntPtr FileContext)
{
}
private static Int32 Read(
IntPtr FileSystem,
IntPtr FileContext,
IntPtr Buffer,
UInt64 Offset,
UInt32 Length,
out UInt32 PBytesTransferred)
{
PBytesTransferred = default(UInt32);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 Write(
IntPtr FileSystem,
IntPtr FileContext,
IntPtr Buffer,
UInt64 Offset,
UInt32 Length,
Boolean WriteToEndOfFile,
Boolean ConstrainedIo,
out UInt32 PBytesTransferred,
out FileInfo FileInfo)
{
PBytesTransferred = default(UInt32);
FileInfo = default(FileInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 Flush(
IntPtr FileSystem,
IntPtr FileContext,
out FileInfo FileInfo)
{
FileInfo = default(FileInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 GetFileInfo(
IntPtr FileSystem,
IntPtr FileContext,
out FileInfo FileInfo)
{
FileInfo = default(FileInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 SetBasicInfo(
IntPtr FileSystem,
IntPtr FileContext,
UInt32 FileAttributes,
UInt64 CreationTime,
UInt64 LastAccessTime,
UInt64 LastWriteTime,
UInt64 ChangeTime,
out FileInfo FileInfo)
{
FileInfo = default(FileInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 SetFileSize(
IntPtr FileSystem,
IntPtr FileContext,
UInt64 NewSize,
Boolean SetAllocationSize,
out FileInfo FileInfo)
{
FileInfo = default(FileInfo);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 CanDelete(
IntPtr FileSystem,
IntPtr FileContext,
String FileName)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 Rename(
IntPtr FileSystem,
IntPtr FileContext,
String FileName,
String NewFileName,
Boolean ReplaceIfExists)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 GetSecurity(
IntPtr FileSystem,
IntPtr FileContext,
IntPtr SecurityDescriptor,
out UIntPtr PSecurityDescriptorSize)
{
PSecurityDescriptorSize = default(UIntPtr);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 SetSecurity(
IntPtr FileSystem,
IntPtr FileContext,
UInt32 SecurityInformation,
IntPtr ModificationDescriptor)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 ReadDirectory(
IntPtr FileSystem,
IntPtr FileContext,
String Pattern,
String Marker,
IntPtr Buffer,
UInt32 Length,
out UInt32 PBytesTransferred)
{
PBytesTransferred = default(UInt32);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 ResolveReparsePoints(
IntPtr FileSystem,
String FileName,
UInt32 ReparsePointIndex,
Boolean ResolveLastPathComponent,
out IoStatusBlock PIoStatus,
IntPtr Buffer,
out UIntPtr PSize)
{
PIoStatus = default(IoStatusBlock);
PSize = default(UIntPtr);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 GetReparsePoint(
IntPtr FileSystem,
IntPtr FileContext,
String FileName,
IntPtr Buffer,
out UIntPtr PSize)
{
PSize = default(UIntPtr);
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 SetReparsePoint(
IntPtr FileSystem,
IntPtr FileContext,
String FileName,
IntPtr Buffer,
UIntPtr Size)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 DeleteReparsePoint(
IntPtr FileSystem,
IntPtr FileContext,
String FileName,
IntPtr Buffer,
UIntPtr Size)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
private static Int32 GetStreamInfo(
IntPtr FileSystem,
IntPtr FileContext,
IntPtr Buffer,
UInt32 Length,
out UInt32 PBytesTransferred)
{
PBytesTransferred = default(UInt32);
return STATUS_INVALID_DEVICE_REQUEST;
}
static FileSystem()
{
_FileSystemInterface.GetVolumeInfo = GetVolumeInfo;
_FileSystemInterface.SetVolumeLabel = SetVolumeLabel;
_FileSystemInterface.GetSecurityByName = GetSecurityByName;
_FileSystemInterface.Create = Create;
_FileSystemInterface.Open = Open;
_FileSystemInterface.Overwrite = Overwrite;
_FileSystemInterface.Cleanup = Cleanup;
_FileSystemInterface.Close = Close;
_FileSystemInterface.Read = Read;
_FileSystemInterface.Write = Write;
_FileSystemInterface.Flush = Flush;
_FileSystemInterface.GetFileInfo = GetFileInfo;
_FileSystemInterface.SetBasicInfo = SetBasicInfo;
_FileSystemInterface.SetFileSize = SetFileSize;
_FileSystemInterface.CanDelete = CanDelete;
_FileSystemInterface.Rename = Rename;
_FileSystemInterface.GetSecurity = GetSecurity;
_FileSystemInterface.SetSecurity = SetSecurity;
_FileSystemInterface.ReadDirectory = ReadDirectory;
_FileSystemInterface.ResolveReparsePoints = ResolveReparsePoints;
_FileSystemInterface.GetReparsePoint = GetReparsePoint;
_FileSystemInterface.SetReparsePoint = SetReparsePoint;
_FileSystemInterface.DeleteReparsePoint = DeleteReparsePoint;
}
private static FileSystemInterface _FileSystemInterface; private static FileSystemInterface _FileSystemInterface;
private VolumeParams _VolumeParams; private VolumeParams _VolumeParams;
private IntPtr _FileSystem; private IntPtr _FileSystem;

View File

@ -145,175 +145,203 @@ namespace Fsp.Interop
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct FileSystemInterface internal struct FileSystemInterface
{ {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal struct Proto
internal delegate Int32 GetVolumeInfo( {
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
out VolumeInfo VolumeInfo); internal delegate Int32 GetVolumeInfo(
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr FileSystem,
internal delegate Int32 SetVolumeLabel( out VolumeInfo VolumeInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.LPWStr)] String VolumeLabel, internal delegate Int32 SetVolumeLabel(
out VolumeInfo VolumeInfo); IntPtr FileSystem,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [MarshalAs(UnmanagedType.LPWStr)] String VolumeLabel,
internal delegate Int32 GetSecurityByName( out VolumeInfo VolumeInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.LPWStr)] String FileName, internal delegate Int32 GetSecurityByName(
out UInt32 PFileAttributes/* or ReparsePointIndex */, IntPtr FileSystem,
IntPtr SecurityDescriptor, [MarshalAs(UnmanagedType.LPWStr)] String FileName,
out UIntPtr PSecurityDescriptorSize); out UInt32 PFileAttributes/* or ReparsePointIndex */,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr SecurityDescriptor,
internal delegate Int32 Create( out UIntPtr PSecurityDescriptorSize);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.LPWStr)] String FileName, internal delegate Int32 Create(
UInt32 CreateOptions, IntPtr FileSystem,
UInt32 GrantedAccess, [MarshalAs(UnmanagedType.LPWStr)] String FileName,
UInt32 FileAttributes, UInt32 CreateOptions,
IntPtr SecurityDescriptor, UInt32 GrantedAccess,
UInt64 AllocationSize, UInt32 FileAttributes,
IntPtr PFileContext, IntPtr SecurityDescriptor,
out FileInfo FileInfo); UInt64 AllocationSize,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr PFileContext,
internal delegate Int32 Open( out FileInfo FileInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.LPWStr)] String FileName, internal delegate Int32 Open(
UInt32 CreateOptions, IntPtr FileSystem,
UInt32 GrantedAccess, [MarshalAs(UnmanagedType.LPWStr)] String FileName,
IntPtr PFileContext, UInt32 CreateOptions,
out FileInfo FileInfo); UInt32 GrantedAccess,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr PFileContext,
internal delegate Int32 Overwrite( out FileInfo FileInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 Overwrite(
UInt32 FileAttributes, IntPtr FileSystem,
Boolean ReplaceFileAttributes, IntPtr FileContext,
UInt64 AllocationSize, UInt32 FileAttributes,
out FileInfo FileInfo); Boolean ReplaceFileAttributes,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] UInt64 AllocationSize,
internal delegate void Cleanup( out FileInfo FileInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate void Cleanup(
[MarshalAs(UnmanagedType.LPWStr)] String FileName, IntPtr FileSystem,
UInt32 Flags); IntPtr FileContext,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [MarshalAs(UnmanagedType.LPWStr)] String FileName,
internal delegate void Close( UInt32 Flags);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext); internal delegate void Close(
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr FileSystem,
internal delegate Int32 Read( IntPtr FileContext);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 Read(
IntPtr Buffer, IntPtr FileSystem,
UInt64 Offset, IntPtr FileContext,
UInt32 Length, IntPtr Buffer,
out UInt32 PBytesTransferred); UInt64 Offset,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] UInt32 Length,
internal delegate Int32 Write( out UInt32 PBytesTransferred);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 Write(
IntPtr Buffer, IntPtr FileSystem,
UInt64 Offset, IntPtr FileContext,
UInt32 Length, IntPtr Buffer,
Boolean WriteToEndOfFile, UInt64 Offset,
Boolean ConstrainedIo, UInt32 Length,
out UInt32 PBytesTransferred, Boolean WriteToEndOfFile,
out FileInfo FileInfo); Boolean ConstrainedIo,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] out UInt32 PBytesTransferred,
internal delegate Int32 Flush( out FileInfo FileInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 Flush(
out FileInfo FileInfo); IntPtr FileSystem,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr FileContext,
internal delegate Int32 GetFileInfo( out FileInfo FileInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 GetFileInfo(
out FileInfo FileInfo); IntPtr FileSystem,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr FileContext,
internal delegate Int32 SetBasicInfo( out FileInfo FileInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 SetBasicInfo(
UInt32 FileAttributes, IntPtr FileSystem,
UInt64 CreationTime, IntPtr FileContext,
UInt64 LastAccessTime, UInt32 FileAttributes,
UInt64 LastWriteTime, UInt64 CreationTime,
UInt64 ChangeTime, UInt64 LastAccessTime,
out FileInfo FileInfo); UInt64 LastWriteTime,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] UInt64 ChangeTime,
internal delegate Int32 SetFileSize( out FileInfo FileInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 SetFileSize(
UInt64 NewSize, IntPtr FileSystem,
Boolean SetAllocationSize, IntPtr FileContext,
out FileInfo FileInfo); UInt64 NewSize,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] Boolean SetAllocationSize,
internal delegate Int32 CanDelete( out FileInfo FileInfo);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 CanDelete(
[MarshalAs(UnmanagedType.LPWStr)] String FileName); IntPtr FileSystem,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr FileContext,
internal delegate Int32 Rename( [MarshalAs(UnmanagedType.LPWStr)] String FileName);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 Rename(
[MarshalAs(UnmanagedType.LPWStr)] String FileName, IntPtr FileSystem,
[MarshalAs(UnmanagedType.LPWStr)] String NewFileName, IntPtr FileContext,
Boolean ReplaceIfExists); [MarshalAs(UnmanagedType.LPWStr)] String FileName,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [MarshalAs(UnmanagedType.LPWStr)] String NewFileName,
internal delegate Int32 GetSecurity( Boolean ReplaceIfExists);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 GetSecurity(
IntPtr SecurityDescriptor, IntPtr FileSystem,
out UIntPtr PSecurityDescriptorSize); IntPtr FileContext,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr SecurityDescriptor,
internal delegate Int32 SetSecurity( out UIntPtr PSecurityDescriptorSize);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 SetSecurity(
UInt32 SecurityInformation, IntPtr FileSystem,
IntPtr ModificationDescriptor); IntPtr FileContext,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] UInt32 SecurityInformation,
internal delegate Int32 ReadDirectory( IntPtr ModificationDescriptor);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 ReadDirectory(
[MarshalAs(UnmanagedType.LPWStr)] String Pattern, IntPtr FileSystem,
[MarshalAs(UnmanagedType.LPWStr)] String Marker, IntPtr FileContext,
IntPtr Buffer, [MarshalAs(UnmanagedType.LPWStr)] String Pattern,
UInt32 Length, [MarshalAs(UnmanagedType.LPWStr)] String Marker,
out UInt32 PBytesTransferred); IntPtr Buffer,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] UInt32 Length,
internal delegate Int32 ResolveReparsePoints( out UInt32 PBytesTransferred);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.LPWStr)] String FileName, internal delegate Int32 ResolveReparsePoints(
UInt32 ReparsePointIndex, IntPtr FileSystem,
Boolean ResolveLastPathComponent, [MarshalAs(UnmanagedType.LPWStr)] String FileName,
out IoStatusBlock PIoStatus, UInt32 ReparsePointIndex,
IntPtr Buffer, Boolean ResolveLastPathComponent,
out UIntPtr PSize); out IoStatusBlock PIoStatus,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr Buffer,
internal delegate Int32 GetReparsePoint( out UIntPtr PSize);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 GetReparsePoint(
[MarshalAs(UnmanagedType.LPWStr)] String FileName, IntPtr FileSystem,
IntPtr Buffer, IntPtr FileContext,
out UIntPtr PSize); [MarshalAs(UnmanagedType.LPWStr)] String FileName,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr Buffer,
internal delegate Int32 SetReparsePoint( out UIntPtr PSize);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 SetReparsePoint(
[MarshalAs(UnmanagedType.LPWStr)] String FileName, IntPtr FileSystem,
IntPtr Buffer, IntPtr FileContext,
UIntPtr Size); [MarshalAs(UnmanagedType.LPWStr)] String FileName,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr Buffer,
internal delegate Int32 DeleteReparsePoint( UIntPtr Size);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 DeleteReparsePoint(
[MarshalAs(UnmanagedType.LPWStr)] String FileName, IntPtr FileSystem,
IntPtr Buffer, IntPtr FileContext,
UIntPtr Size); [MarshalAs(UnmanagedType.LPWStr)] String FileName,
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] IntPtr Buffer,
internal delegate Int32 GetStreamInfo( UIntPtr Size);
IntPtr FileSystem, [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
IntPtr FileContext, internal delegate Int32 GetStreamInfo(
IntPtr Buffer, IntPtr FileSystem,
UInt32 Length, IntPtr FileContext,
out UInt32 PBytesTransferred); IntPtr Buffer,
UInt32 Length,
out UInt32 PBytesTransferred);
}
internal Proto.GetVolumeInfo GetVolumeInfo;
internal Proto.SetVolumeLabel SetVolumeLabel;
internal Proto.GetSecurityByName GetSecurityByName;
internal Proto.Create Create;
internal Proto.Open Open;
internal Proto.Overwrite Overwrite;
internal Proto.Cleanup Cleanup;
internal Proto.Close Close;
internal Proto.Read Read;
internal Proto.Write Write;
internal Proto.Flush Flush;
internal Proto.GetFileInfo GetFileInfo;
internal Proto.SetBasicInfo SetBasicInfo;
internal Proto.SetFileSize SetFileSize;
internal Proto.CanDelete CanDelete;
internal Proto.Rename Rename;
internal Proto.GetSecurity GetSecurity;
internal Proto.SetSecurity SetSecurity;
internal Proto.ReadDirectory ReadDirectory;
internal Proto.ResolveReparsePoints ResolveReparsePoints;
internal Proto.GetReparsePoint GetReparsePoint;
internal Proto.SetReparsePoint SetReparsePoint;
internal Proto.DeleteReparsePoint DeleteReparsePoint;
internal Proto.DeleteReparsePoint GetStreamInfo;
internal unsafe fixed long/*IntPtr*/ Reserved[40]; internal unsafe fixed long/*IntPtr*/ Reserved[40];
/* NTSTATUS (*Reserved[40])(); */ /* NTSTATUS (*Reserved[40])(); */
} }