mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
dotnet: implement Control operation
This commit is contained in:
parent
05f622f2de
commit
637a1dac7e
@ -966,6 +966,49 @@ namespace Fsp
|
||||
FileInfo = default(FileInfo);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
/// <summary>
|
||||
/// Processes a control code.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This function is called when a program uses the DeviceIoControl API.
|
||||
/// </remarks>
|
||||
/// <param name="FileNode">
|
||||
/// The file node of the file or directory to be controled.
|
||||
/// </param>
|
||||
/// <param name="FileDesc">
|
||||
/// The file descriptor of the file or directory to be controled.
|
||||
/// </param>
|
||||
/// <param name="ControlCode">
|
||||
/// The control code for the operation. This code must have a DeviceType with bit
|
||||
/// 0x8000 set and must have a TransferType of METHOD_BUFFERED.
|
||||
/// </param>
|
||||
/// <param name="InputBuffer">
|
||||
/// Pointer to a buffer that contains the input data.
|
||||
/// </param>
|
||||
/// <param name="InputBufferLength">
|
||||
/// Input data length.
|
||||
/// </param>
|
||||
/// <param name="OutputBuffer">
|
||||
/// Pointer to a buffer that will receive the output data.
|
||||
/// </param>
|
||||
/// <param name="OutputBufferLength">
|
||||
/// Output data length.
|
||||
/// </param>
|
||||
/// <param name="BytesTransferred">
|
||||
/// Receives the actual number of bytes transferred.
|
||||
/// </param>
|
||||
/// <returns>STATUS_SUCCESS or error code.</returns>
|
||||
public virtual Int32 Control(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
UInt32 ControlCode,
|
||||
IntPtr InputBuffer, UInt32 InputBufferLength,
|
||||
IntPtr OutputBuffer, UInt32 OutputBufferLength,
|
||||
out UInt32 BytesTransferred)
|
||||
{
|
||||
BytesTransferred = default(UInt32);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
|
||||
/* helpers */
|
||||
/// <summary>
|
||||
|
@ -1020,6 +1020,35 @@ namespace Fsp
|
||||
return ExceptionHandler(FileSystem, ex);
|
||||
}
|
||||
}
|
||||
private static Int32 Control(
|
||||
IntPtr FileSystemPtr,
|
||||
ref FullContext FullContext,
|
||||
UInt32 ControlCode,
|
||||
IntPtr InputBuffer, UInt32 InputBufferLength,
|
||||
IntPtr OutputBuffer, UInt32 OutputBufferLength,
|
||||
out UInt32 PBytesTransferred)
|
||||
{
|
||||
FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr);
|
||||
try
|
||||
{
|
||||
Object FileNode, FileDesc;
|
||||
Api.GetFullContext(ref FullContext, out FileNode, out FileDesc);
|
||||
return FileSystem.Control(
|
||||
FileNode,
|
||||
FileDesc,
|
||||
ControlCode,
|
||||
InputBuffer,
|
||||
InputBufferLength,
|
||||
OutputBuffer,
|
||||
OutputBufferLength,
|
||||
out PBytesTransferred);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PBytesTransferred = default(UInt32);
|
||||
return ExceptionHandler(FileSystem, ex);
|
||||
}
|
||||
}
|
||||
|
||||
static FileSystemHost()
|
||||
{
|
||||
@ -1048,6 +1077,7 @@ namespace Fsp
|
||||
_FileSystemInterface.DeleteReparsePoint = DeleteReparsePoint;
|
||||
_FileSystemInterface.GetStreamInfo = GetStreamInfo;
|
||||
_FileSystemInterface.GetDirInfoByName = GetDirInfoByName;
|
||||
_FileSystemInterface.Control = Control;
|
||||
|
||||
_FileSystemInterfacePtr = Marshal.AllocHGlobal(FileSystemInterface.Size);
|
||||
Marshal.StructureToPtr(_FileSystemInterface, _FileSystemInterfacePtr, false);
|
||||
|
@ -457,6 +457,14 @@ namespace Fsp.Interop
|
||||
ref FullContext FullContext,
|
||||
[MarshalAs(UnmanagedType.LPWStr)] String FileName,
|
||||
out DirInfo DirInfo);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate Int32 Control(
|
||||
IntPtr FileSystem,
|
||||
ref FullContext FullContext,
|
||||
UInt32 ControlCode,
|
||||
IntPtr InputBuffer, UInt32 InputBufferLength,
|
||||
IntPtr OutputBuffer, UInt32 OutputBufferLength,
|
||||
out UInt32 PBytesTransferred);
|
||||
}
|
||||
|
||||
internal static int Size = IntPtr.Size * 64;
|
||||
@ -486,7 +494,8 @@ namespace Fsp.Interop
|
||||
internal Proto.DeleteReparsePoint DeleteReparsePoint;
|
||||
internal Proto.GetStreamInfo GetStreamInfo;
|
||||
internal Proto.GetDirInfoByName GetDirInfoByName;
|
||||
/* NTSTATUS (*Reserved[39])(); */
|
||||
internal Proto.Control Control;
|
||||
/* NTSTATUS (*Reserved[38])(); */
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
|
Loading…
x
Reference in New Issue
Block a user