mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
src: dotnet: WIP
This commit is contained in:
parent
36d50facd7
commit
30dae34700
@ -286,7 +286,7 @@ namespace Fsp
|
|||||||
UInt32 FileAttributes,
|
UInt32 FileAttributes,
|
||||||
IntPtr SecurityDescriptor,
|
IntPtr SecurityDescriptor,
|
||||||
UInt64 AllocationSize,
|
UInt64 AllocationSize,
|
||||||
out FullContext FullContext,
|
ref FullContext FullContext,
|
||||||
out FileInfo FileInfo)
|
out FileInfo FileInfo)
|
||||||
{
|
{
|
||||||
FileSystem self = (FileSystem)Api.FspFileSystemGetUserContext(FileSystem);
|
FileSystem self = (FileSystem)Api.FspFileSystemGetUserContext(FileSystem);
|
||||||
@ -304,7 +304,7 @@ namespace Fsp
|
|||||||
out FileNode,
|
out FileNode,
|
||||||
out FileDesc,
|
out FileDesc,
|
||||||
out FileInfo);
|
out FileInfo);
|
||||||
Api.SetFullContext(out FullContext, FileNode, FileDesc);
|
Api.SetFullContext(ref FullContext, FileNode, FileDesc);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -319,7 +319,7 @@ namespace Fsp
|
|||||||
String FileName,
|
String FileName,
|
||||||
UInt32 CreateOptions,
|
UInt32 CreateOptions,
|
||||||
UInt32 GrantedAccess,
|
UInt32 GrantedAccess,
|
||||||
out FullContext FullContext,
|
ref FullContext FullContext,
|
||||||
out FileInfo FileInfo)
|
out FileInfo FileInfo)
|
||||||
{
|
{
|
||||||
FullContext = default(FullContext);
|
FullContext = default(FullContext);
|
||||||
|
@ -202,7 +202,7 @@ namespace Fsp.Interop
|
|||||||
UInt32 FileAttributes,
|
UInt32 FileAttributes,
|
||||||
IntPtr SecurityDescriptor,
|
IntPtr SecurityDescriptor,
|
||||||
UInt64 AllocationSize,
|
UInt64 AllocationSize,
|
||||||
out FullContext FullContext,
|
ref FullContext FullContext,
|
||||||
out FileInfo FileInfo);
|
out FileInfo FileInfo);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
internal delegate Int32 Open(
|
internal delegate Int32 Open(
|
||||||
@ -210,7 +210,7 @@ namespace Fsp.Interop
|
|||||||
[MarshalAs(UnmanagedType.LPWStr)] String FileName,
|
[MarshalAs(UnmanagedType.LPWStr)] String FileName,
|
||||||
UInt32 CreateOptions,
|
UInt32 CreateOptions,
|
||||||
UInt32 GrantedAccess,
|
UInt32 GrantedAccess,
|
||||||
out FullContext FullContext,
|
ref FullContext FullContext,
|
||||||
out FileInfo FileInfo);
|
out FileInfo FileInfo);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
internal delegate Int32 Overwrite(
|
internal delegate Int32 Overwrite(
|
||||||
@ -469,13 +469,42 @@ namespace Fsp.Interop
|
|||||||
internal static void GetFullContext(ref FullContext FullContext,
|
internal static void GetFullContext(ref FullContext FullContext,
|
||||||
out Object FileNode, out Object FileDesc)
|
out Object FileNode, out Object FileDesc)
|
||||||
{
|
{
|
||||||
FileNode = default(Object);
|
FileNode = 0 != FullContext.UserContext ?
|
||||||
FileDesc = default(Object);
|
((GCHandle)(IntPtr)FullContext.UserContext).Target : null;
|
||||||
|
FileDesc = 0 != FullContext.UserContext2 ?
|
||||||
|
((GCHandle)(IntPtr)FullContext.UserContext2).Target : null;
|
||||||
}
|
}
|
||||||
internal static void SetFullContext(out FullContext FullContext,
|
internal static void SetFullContext(ref FullContext FullContext,
|
||||||
Object FileNode, Object FileDesc)
|
Object FileNode, Object FileDesc)
|
||||||
{
|
{
|
||||||
FullContext = default(FullContext);
|
if (null != FileNode)
|
||||||
|
{
|
||||||
|
Debug.Assert(0 == FullContext.UserContext);
|
||||||
|
GCHandle Handle = GCHandle.Alloc(FileNode, GCHandleType.Normal);
|
||||||
|
FullContext.UserContext = (UInt64)(IntPtr)Handle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (0 != FullContext.UserContext)
|
||||||
|
{
|
||||||
|
((GCHandle)(IntPtr)FullContext.UserContext).Free();
|
||||||
|
FullContext.UserContext = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != FileDesc)
|
||||||
|
{
|
||||||
|
Debug.Assert(0 == FullContext.UserContext2);
|
||||||
|
GCHandle Handle = GCHandle.Alloc(FileDesc, GCHandleType.Normal);
|
||||||
|
FullContext.UserContext2 = (UInt64)(IntPtr)Handle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (0 != FullContext.UserContext2)
|
||||||
|
{
|
||||||
|
((GCHandle)(IntPtr)FullContext.UserContext2).Free();
|
||||||
|
FullContext.UserContext2 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("advapi32.dll", CallingConvention = CallingConvention.StdCall)]
|
[DllImport("advapi32.dll", CallingConvention = CallingConvention.StdCall)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user