mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-10-30 19:48:38 -05:00 
			
		
		
		
	dotnet: reparse point changes
This commit is contained in:
		| @@ -267,7 +267,7 @@ namespace Fsp | |||||||
|             Boolean ResolveLastPathComponent, |             Boolean ResolveLastPathComponent, | ||||||
|             out IoStatusBlock IoStatus, |             out IoStatusBlock IoStatus, | ||||||
|             IntPtr Buffer, |             IntPtr Buffer, | ||||||
|             ref UIntPtr Size) |             IntPtr PSize) | ||||||
|         { |         { | ||||||
|             GCHandle Handle = GCHandle.Alloc(this, GCHandleType.Normal); |             GCHandle Handle = GCHandle.Alloc(this, GCHandleType.Normal); | ||||||
|             try |             try | ||||||
| @@ -281,7 +281,7 @@ namespace Fsp | |||||||
|                     ResolveLastPathComponent, |                     ResolveLastPathComponent, | ||||||
|                     out IoStatus, |                     out IoStatus, | ||||||
|                     Buffer, |                     Buffer, | ||||||
|                     ref Size); |                     PSize); | ||||||
|             } |             } | ||||||
|             finally |             finally | ||||||
|             { |             { | ||||||
| @@ -291,8 +291,7 @@ namespace Fsp | |||||||
|         public virtual Int32 GetReparsePointByName( |         public virtual Int32 GetReparsePointByName( | ||||||
|             String FileName, |             String FileName, | ||||||
|             Boolean IsDirectory, |             Boolean IsDirectory, | ||||||
|             IntPtr Buffer, |             ref Byte[] ReparsePoint) | ||||||
|             ref UIntPtr Size) |  | ||||||
|         { |         { | ||||||
|             return STATUS_INVALID_DEVICE_REQUEST; |             return STATUS_INVALID_DEVICE_REQUEST; | ||||||
|         } |         } | ||||||
| @@ -300,18 +299,15 @@ namespace Fsp | |||||||
|             Object FileNode, |             Object FileNode, | ||||||
|             Object FileDesc, |             Object FileDesc, | ||||||
|             String FileName, |             String FileName, | ||||||
|             IntPtr Buffer, |             ref Byte[] ReparsePoint) | ||||||
|             out UIntPtr Size) |  | ||||||
|         { |         { | ||||||
|             Size = default(UIntPtr); |  | ||||||
|             return STATUS_INVALID_DEVICE_REQUEST; |             return STATUS_INVALID_DEVICE_REQUEST; | ||||||
|         } |         } | ||||||
|         public virtual Int32 SetReparsePoint( |         public virtual Int32 SetReparsePoint( | ||||||
|             Object FileNode, |             Object FileNode, | ||||||
|             Object FileDesc, |             Object FileDesc, | ||||||
|             String FileName, |             String FileName, | ||||||
|             IntPtr Buffer, |             Byte[] ReparsePoint) | ||||||
|             UIntPtr Size) |  | ||||||
|         { |         { | ||||||
|             return STATUS_INVALID_DEVICE_REQUEST; |             return STATUS_INVALID_DEVICE_REQUEST; | ||||||
|         } |         } | ||||||
| @@ -319,8 +315,7 @@ namespace Fsp | |||||||
|             Object FileNode, |             Object FileNode, | ||||||
|             Object FileDesc, |             Object FileDesc, | ||||||
|             String FileName, |             String FileName, | ||||||
|             IntPtr Buffer, |             Byte[] ReparsePoint) | ||||||
|             UIntPtr Size) |  | ||||||
|         { |         { | ||||||
|             return STATUS_INVALID_DEVICE_REQUEST; |             return STATUS_INVALID_DEVICE_REQUEST; | ||||||
|         } |         } | ||||||
| @@ -427,22 +422,40 @@ namespace Fsp | |||||||
|                 Handle.Free(); |                 Handle.Free(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         public static UInt32 GetReparseTag( | ||||||
|  |             Byte[] ReparseData) | ||||||
|  |         { | ||||||
|  |             return 0; | ||||||
|  |         } | ||||||
|  |         public static Int32 CanReplaceReparsePoint( | ||||||
|  |             Byte[] CurrentReparseData, | ||||||
|  |             Byte[] ReplaceReparseData) | ||||||
|  |         { | ||||||
|  |             // !!!: NOT IMPLEMENTED | ||||||
|  |             return STATUS_SUCCESS; | ||||||
|  |         } | ||||||
|         private static Int32 GetReparsePointByName( |         private static Int32 GetReparsePointByName( | ||||||
|             IntPtr FileSystem, |             IntPtr FileSystem, | ||||||
|             IntPtr Context, |             IntPtr Context, | ||||||
|             String FileName, |             String FileName, | ||||||
|             Boolean IsDirectory, |             Boolean IsDirectory, | ||||||
|             IntPtr Buffer, |             IntPtr Buffer, | ||||||
|             ref UIntPtr Size) |             IntPtr PSize) | ||||||
|         { |         { | ||||||
|             FileSystemBase self = (FileSystemBase)GCHandle.FromIntPtr(Context).Target; |             FileSystemBase self = (FileSystemBase)GCHandle.FromIntPtr(Context).Target; | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 return self.GetReparsePointByName( |                 Byte[] ReparsePointBytes; | ||||||
|  |                 Int32 Result; | ||||||
|  |                 ReparsePointBytes = null; | ||||||
|  |                 Result = self.GetReparsePointByName( | ||||||
|                     FileName, |                     FileName, | ||||||
|                     IsDirectory, |                     IsDirectory, | ||||||
|                     Buffer, |                     ref ReparsePointBytes); | ||||||
|                     ref Size); |                 if (0 <= Result) | ||||||
|  |                     Result = Api.CopyReparsePoint(ReparsePointBytes, Buffer, PSize); | ||||||
|  |                 return Result; | ||||||
|  |  | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -763,7 +763,7 @@ namespace Fsp | |||||||
|             Boolean ResolveLastPathComponent, |             Boolean ResolveLastPathComponent, | ||||||
|             out IoStatusBlock PIoStatus, |             out IoStatusBlock PIoStatus, | ||||||
|             IntPtr Buffer, |             IntPtr Buffer, | ||||||
|             ref UIntPtr PSize) |             IntPtr PSize) | ||||||
|         { |         { | ||||||
|             FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr); |             FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr); | ||||||
|             try |             try | ||||||
| @@ -774,7 +774,7 @@ namespace Fsp | |||||||
|                     ResolveLastPathComponent, |                     ResolveLastPathComponent, | ||||||
|                     out PIoStatus, |                     out PIoStatus, | ||||||
|                     Buffer, |                     Buffer, | ||||||
|                     ref PSize); |                     PSize); | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
| @@ -787,23 +787,27 @@ namespace Fsp | |||||||
|             ref FullContext FullContext, |             ref FullContext FullContext, | ||||||
|             String FileName, |             String FileName, | ||||||
|             IntPtr Buffer, |             IntPtr Buffer, | ||||||
|             out UIntPtr PSize) |             IntPtr PSize) | ||||||
|         { |         { | ||||||
|             FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr); |             FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr); | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|  |                 Byte[] ReparsePointBytes; | ||||||
|                 Object FileNode, FileDesc; |                 Object FileNode, FileDesc; | ||||||
|  |                 Int32 Result; | ||||||
|                 Api.GetFullContext(ref FullContext, out FileNode, out FileDesc); |                 Api.GetFullContext(ref FullContext, out FileNode, out FileDesc); | ||||||
|                 return FileSystem.GetReparsePoint( |                 ReparsePointBytes = null; | ||||||
|  |                 Result = FileSystem.GetReparsePoint( | ||||||
|                     FileNode, |                     FileNode, | ||||||
|                     FileDesc, |                     FileDesc, | ||||||
|                     FileName, |                     FileName, | ||||||
|                     Buffer, |                     ref ReparsePointBytes); | ||||||
|                     out PSize); |                 if (0 <= Result) | ||||||
|  |                     Result = Api.CopyReparsePoint(ReparsePointBytes, Buffer, PSize); | ||||||
|  |                 return Result; | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|                 PSize = default(UIntPtr); |  | ||||||
|                 return ExceptionHandler(FileSystem, ex); |                 return ExceptionHandler(FileSystem, ex); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -823,8 +827,7 @@ namespace Fsp | |||||||
|                     FileNode, |                     FileNode, | ||||||
|                     FileDesc, |                     FileDesc, | ||||||
|                     FileName, |                     FileName, | ||||||
|                     Buffer, |                     Api.MakeReparsePoint(Buffer, Size)); | ||||||
|                     Size); |  | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
| @@ -847,8 +850,7 @@ namespace Fsp | |||||||
|                     FileNode, |                     FileNode, | ||||||
|                     FileDesc, |                     FileDesc, | ||||||
|                     FileName, |                     FileName, | ||||||
|                     Buffer, |                     Api.MakeReparsePoint(Buffer, Size)); | ||||||
|                     Size); |  | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|   | |||||||
| @@ -354,14 +354,14 @@ namespace Fsp.Interop | |||||||
|                 [MarshalAs(UnmanagedType.U1)] Boolean ResolveLastPathComponent, |                 [MarshalAs(UnmanagedType.U1)] Boolean ResolveLastPathComponent, | ||||||
|                 out IoStatusBlock PIoStatus, |                 out IoStatusBlock PIoStatus, | ||||||
|                 IntPtr Buffer, |                 IntPtr Buffer, | ||||||
|                 ref UIntPtr PSize); |                 IntPtr PSize); | ||||||
|             [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |             [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | ||||||
|             internal delegate Int32 GetReparsePoint( |             internal delegate Int32 GetReparsePoint( | ||||||
|                 IntPtr FileSystem, |                 IntPtr FileSystem, | ||||||
|                 ref FullContext FullContext, |                 ref FullContext FullContext, | ||||||
|                 [MarshalAs(UnmanagedType.LPWStr)] String FileName, |                 [MarshalAs(UnmanagedType.LPWStr)] String FileName, | ||||||
|                 IntPtr Buffer, |                 IntPtr Buffer, | ||||||
|                 out UIntPtr PSize); |                 IntPtr PSize); | ||||||
|             [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |             [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | ||||||
|             internal delegate Int32 SetReparsePoint( |             internal delegate Int32 SetReparsePoint( | ||||||
|                 IntPtr FileSystem, |                 IntPtr FileSystem, | ||||||
| @@ -488,7 +488,7 @@ namespace Fsp.Interop | |||||||
|                 [MarshalAs(UnmanagedType.U1)] Boolean ResolveLastPathComponent, |                 [MarshalAs(UnmanagedType.U1)] Boolean ResolveLastPathComponent, | ||||||
|                 out IoStatusBlock PIoStatus, |                 out IoStatusBlock PIoStatus, | ||||||
|                 IntPtr Buffer, |                 IntPtr Buffer, | ||||||
|                 ref UIntPtr PSize); |                 IntPtr PSize); | ||||||
|             [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |             [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | ||||||
|             internal delegate Int32 FspFileSystemCanReplaceReparsePoint( |             internal delegate Int32 FspFileSystemCanReplaceReparsePoint( | ||||||
|                 IntPtr CurrentReparseData, |                 IntPtr CurrentReparseData, | ||||||
| @@ -587,7 +587,7 @@ namespace Fsp.Interop | |||||||
|                 [MarshalAs(UnmanagedType.LPWStr)] String FileName, |                 [MarshalAs(UnmanagedType.LPWStr)] String FileName, | ||||||
|                 [MarshalAs(UnmanagedType.U1)] Boolean IsDirectory, |                 [MarshalAs(UnmanagedType.U1)] Boolean IsDirectory, | ||||||
|                 IntPtr Buffer, |                 IntPtr Buffer, | ||||||
|                 ref UIntPtr PSize); |                 IntPtr PSize); | ||||||
|             [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |             [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | ||||||
|             internal delegate Int32 ServiceStart( |             internal delegate Int32 ServiceStart( | ||||||
|                 IntPtr Service, |                 IntPtr Service, | ||||||
| @@ -770,6 +770,39 @@ namespace Fsp.Interop | |||||||
|                 return null; |                 return null; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         internal unsafe static Int32 CopyReparsePoint( | ||||||
|  |             Byte[] ReparsePointBytes, | ||||||
|  |             IntPtr Buffer, | ||||||
|  |             IntPtr PSize) | ||||||
|  |         { | ||||||
|  |             if (IntPtr.Zero != Buffer) | ||||||
|  |             { | ||||||
|  |                 if (null != ReparsePointBytes) | ||||||
|  |                 { | ||||||
|  |                     if (ReparsePointBytes.Length > (int)*(UIntPtr *)PSize) | ||||||
|  |                         return unchecked((Int32)0xc0000023)/*STATUS_BUFFER_TOO_SMALL*/; | ||||||
|  |                     *(UIntPtr *)PSize = (UIntPtr)ReparsePointBytes.Length; | ||||||
|  |                     Marshal.Copy(ReparsePointBytes, 0, Buffer, ReparsePointBytes.Length); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     *(UIntPtr *)PSize = UIntPtr.Zero; | ||||||
|  |             } | ||||||
|  |             return 0/*STATUS_SUCCESS*/; | ||||||
|  |         } | ||||||
|  |         internal static Byte[] MakeReparsePoint( | ||||||
|  |             IntPtr Buffer, | ||||||
|  |             UIntPtr Size) | ||||||
|  |         { | ||||||
|  |             if (IntPtr.Zero != Buffer) | ||||||
|  |             { | ||||||
|  |                 Byte[] ReparsePointBytes = new Byte[(int)Size]; | ||||||
|  |                 Marshal.Copy(Buffer, ReparsePointBytes, 0, ReparsePointBytes.Length); | ||||||
|  |                 return ReparsePointBytes; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |                 return null; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         internal static Int32 SetDebugLogFile(String FileName) |         internal static Int32 SetDebugLogFile(String FileName) | ||||||
|         { |         { | ||||||
|             IntPtr Handle; |             IntPtr Handle; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user