mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
Add asyncronous support for dotnet.
This commit is contained in:
parent
ee1ae0370e
commit
290896b010
@ -381,6 +381,89 @@ namespace Fsp
|
|||||||
{
|
{
|
||||||
return Api.GetVersion();
|
return Api.GetVersion();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a RequestHint to reference the current operation asynchronously.
|
||||||
|
/// </summary>
|
||||||
|
public UInt64 GetOperationRequestHint()
|
||||||
|
{
|
||||||
|
return Api.FspFileSystemGetOperationRequestHint();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously complete a Write operation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="RequestHint">
|
||||||
|
/// A reference to the operation to complete.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="Status">
|
||||||
|
/// STATUS_SUCCESS or error code.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="BytesTransferred">
|
||||||
|
/// The number of bytes written.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="FileInfo">
|
||||||
|
/// Updated file information.
|
||||||
|
/// </param>
|
||||||
|
public void SendWriteResponse(UInt64 RequestHint, UInt32 Status, UInt32 BytesTransferred, ref FileInfo FileInfo)
|
||||||
|
{
|
||||||
|
var Response = new FspFsctlTransactRsp()
|
||||||
|
{
|
||||||
|
Size = 128,
|
||||||
|
Kind = (UInt32) FspFsctlTransact.WriteKind,
|
||||||
|
Hint = RequestHint
|
||||||
|
};
|
||||||
|
Response.IoStatus.Information = BytesTransferred;
|
||||||
|
Response.IoStatus.Status = Status;
|
||||||
|
Response.WriteFileInfo = FileInfo;
|
||||||
|
Api.FspFileSystemSendResponse(_FileSystemPtr, ref Response);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously complete a Read operation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="RequestHint">
|
||||||
|
/// A reference to the operation to complete.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="Status">
|
||||||
|
/// STATUS_SUCCESS or error code.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="BytesTransferred">
|
||||||
|
/// Number of bytes read.
|
||||||
|
/// </param>
|
||||||
|
public void SendReadResponse(UInt64 RequestHint, UInt32 Status, UInt32 BytesTransferred)
|
||||||
|
{
|
||||||
|
var Response = new FspFsctlTransactRsp()
|
||||||
|
{
|
||||||
|
Size = 128,
|
||||||
|
Kind = (UInt32) FspFsctlTransact.ReadKind,
|
||||||
|
Hint = RequestHint
|
||||||
|
};
|
||||||
|
Response.IoStatus.Information = BytesTransferred;
|
||||||
|
Response.IoStatus.Status = Status;
|
||||||
|
Api.FspFileSystemSendResponse(_FileSystemPtr, ref Response);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously complete a ReadDirectory operation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="RequestHint">
|
||||||
|
/// A reference to the operation to complete.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="Status">
|
||||||
|
/// STATUS_SUCCESS or error code.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="BytesTransferred">
|
||||||
|
/// Number of bytes read.
|
||||||
|
/// </param>
|
||||||
|
public void SendReadDirectoryResponse(UInt64 RequestHint, UInt32 Status, UInt32 BytesTransferred)
|
||||||
|
{
|
||||||
|
var Response = new FspFsctlTransactRsp()
|
||||||
|
{
|
||||||
|
Size = 128,
|
||||||
|
Kind = (UInt32) FspFsctlTransact.QueryDirectoryKind,
|
||||||
|
Hint = RequestHint
|
||||||
|
};
|
||||||
|
Response.IoStatus.Information = BytesTransferred;
|
||||||
|
Response.IoStatus.Status = Status;
|
||||||
|
Api.FspFileSystemSendResponse(_FileSystemPtr, ref Response);
|
||||||
|
}
|
||||||
|
|
||||||
/* FSP_FILE_SYSTEM_INTERFACE */
|
/* FSP_FILE_SYSTEM_INTERFACE */
|
||||||
private static Byte[] ByteBufferNotNull = new Byte[0];
|
private static Byte[] ByteBufferNotNull = new Byte[0];
|
||||||
|
@ -354,6 +354,65 @@ namespace Fsp.Interop
|
|||||||
public IntPtr Information;
|
public IntPtr Information;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct IoStatus
|
||||||
|
{
|
||||||
|
internal UInt32 Information;
|
||||||
|
internal UInt32 Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum FspFsctlTransact
|
||||||
|
{
|
||||||
|
ReadKind = 5,
|
||||||
|
WriteKind = 6,
|
||||||
|
QueryDirectoryKind = 14
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
|
internal struct FspFsctlTransactReq
|
||||||
|
{
|
||||||
|
[FieldOffset(0)]
|
||||||
|
internal UInt16 Version;
|
||||||
|
[FieldOffset(2)]
|
||||||
|
internal UInt16 Size;
|
||||||
|
[FieldOffset(4)]
|
||||||
|
internal UInt32 Kind;
|
||||||
|
[FieldOffset(8)]
|
||||||
|
internal UInt64 Hint;
|
||||||
|
|
||||||
|
[FieldOffset(0)]
|
||||||
|
internal unsafe fixed Byte Padding[88];
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
|
internal struct FspFsctlTransactRsp
|
||||||
|
{
|
||||||
|
[FieldOffset(0)]
|
||||||
|
internal UInt16 Version;
|
||||||
|
[FieldOffset(2)]
|
||||||
|
internal UInt16 Size;
|
||||||
|
[FieldOffset(4)]
|
||||||
|
internal UInt32 Kind;
|
||||||
|
[FieldOffset(8)]
|
||||||
|
internal UInt64 Hint;
|
||||||
|
|
||||||
|
[FieldOffset(16)]
|
||||||
|
internal IoStatus IoStatus;
|
||||||
|
|
||||||
|
[FieldOffset(24)]
|
||||||
|
internal FileInfo WriteFileInfo;
|
||||||
|
|
||||||
|
[FieldOffset(0)]
|
||||||
|
internal unsafe fixed Byte Padding[128];
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal unsafe struct FspFileSystemOperationContext
|
||||||
|
{
|
||||||
|
internal FspFsctlTransactReq *Request;
|
||||||
|
internal FspFsctlTransactRsp *Response;
|
||||||
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
internal struct FileSystemInterface
|
internal struct FileSystemInterface
|
||||||
{
|
{
|
||||||
@ -662,6 +721,12 @@ namespace Fsp.Interop
|
|||||||
internal delegate Int32 FspFileSystemStopDispatcher(
|
internal delegate Int32 FspFileSystemStopDispatcher(
|
||||||
IntPtr FileSystem);
|
IntPtr FileSystem);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
internal delegate void FspFileSystemSendResponse(
|
||||||
|
IntPtr FileSystem,
|
||||||
|
ref FspFsctlTransactRsp Response);
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
internal delegate ref FspFileSystemOperationContext FspFileSystemGetOperationContext();
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
internal delegate IntPtr FspFileSystemMountPointF(
|
internal delegate IntPtr FspFileSystemMountPointF(
|
||||||
IntPtr FileSystem);
|
IntPtr FileSystem);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
@ -846,6 +911,8 @@ namespace Fsp.Interop
|
|||||||
internal static Proto.FspFileSystemRemoveMountPoint FspFileSystemRemoveMountPoint;
|
internal static Proto.FspFileSystemRemoveMountPoint FspFileSystemRemoveMountPoint;
|
||||||
internal static Proto.FspFileSystemStartDispatcher FspFileSystemStartDispatcher;
|
internal static Proto.FspFileSystemStartDispatcher FspFileSystemStartDispatcher;
|
||||||
internal static Proto.FspFileSystemStopDispatcher FspFileSystemStopDispatcher;
|
internal static Proto.FspFileSystemStopDispatcher FspFileSystemStopDispatcher;
|
||||||
|
internal static Proto.FspFileSystemSendResponse FspFileSystemSendResponse;
|
||||||
|
internal static Proto.FspFileSystemGetOperationContext FspFileSystemGetOperationContext;
|
||||||
internal static Proto.FspFileSystemMountPointF FspFileSystemMountPoint;
|
internal static Proto.FspFileSystemMountPointF FspFileSystemMountPoint;
|
||||||
internal static Proto.FspFileSystemSetOperationGuardStrategyF FspFileSystemSetOperationGuardStrategy;
|
internal static Proto.FspFileSystemSetOperationGuardStrategyF FspFileSystemSetOperationGuardStrategy;
|
||||||
internal static Proto.FspFileSystemSetDebugLogF FspFileSystemSetDebugLog;
|
internal static Proto.FspFileSystemSetDebugLogF FspFileSystemSetDebugLog;
|
||||||
@ -892,6 +959,12 @@ namespace Fsp.Interop
|
|||||||
else
|
else
|
||||||
return _FspFileSystemSetMountPointEx(FileSystem, MountPoint, IntPtr.Zero);
|
return _FspFileSystemSetMountPointEx(FileSystem, MountPoint, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
internal static unsafe UInt64 FspFileSystemGetOperationRequestHint()
|
||||||
|
{
|
||||||
|
FspFileSystemOperationContext Context = FspFileSystemGetOperationContext();
|
||||||
|
FspFsctlTransactReq Request = *Context.Request;
|
||||||
|
return Request.Hint;
|
||||||
|
}
|
||||||
internal static unsafe Boolean FspFileSystemAddDirInfo(
|
internal static unsafe Boolean FspFileSystemAddDirInfo(
|
||||||
ref DirInfo DirInfo,
|
ref DirInfo DirInfo,
|
||||||
IntPtr Buffer,
|
IntPtr Buffer,
|
||||||
@ -1240,6 +1313,8 @@ namespace Fsp.Interop
|
|||||||
FspFileSystemRemoveMountPoint = GetEntryPoint<Proto.FspFileSystemRemoveMountPoint>(Module);
|
FspFileSystemRemoveMountPoint = GetEntryPoint<Proto.FspFileSystemRemoveMountPoint>(Module);
|
||||||
FspFileSystemStartDispatcher = GetEntryPoint<Proto.FspFileSystemStartDispatcher>(Module);
|
FspFileSystemStartDispatcher = GetEntryPoint<Proto.FspFileSystemStartDispatcher>(Module);
|
||||||
FspFileSystemStopDispatcher = GetEntryPoint<Proto.FspFileSystemStopDispatcher>(Module);
|
FspFileSystemStopDispatcher = GetEntryPoint<Proto.FspFileSystemStopDispatcher>(Module);
|
||||||
|
FspFileSystemSendResponse = GetEntryPoint<Proto.FspFileSystemSendResponse>(Module);
|
||||||
|
FspFileSystemGetOperationContext = GetEntryPoint<Proto.FspFileSystemGetOperationContext>(Module);
|
||||||
FspFileSystemMountPoint = GetEntryPoint<Proto.FspFileSystemMountPointF>(Module);
|
FspFileSystemMountPoint = GetEntryPoint<Proto.FspFileSystemMountPointF>(Module);
|
||||||
FspFileSystemSetOperationGuardStrategy = GetEntryPoint<Proto.FspFileSystemSetOperationGuardStrategyF>(Module);
|
FspFileSystemSetOperationGuardStrategy = GetEntryPoint<Proto.FspFileSystemSetOperationGuardStrategyF>(Module);
|
||||||
FspFileSystemSetDebugLog = GetEntryPoint<Proto.FspFileSystemSetDebugLogF>(Module);
|
FspFileSystemSetDebugLog = GetEntryPoint<Proto.FspFileSystemSetDebugLogF>(Module);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user