mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 08:53:01 -05:00
src: dotnet: WIP
This commit is contained in:
parent
4cbee05849
commit
1980f511ce
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Security.AccessControl;
|
using System.Security.AccessControl;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using Fsp.Interop;
|
using Fsp.Interop;
|
||||||
|
|
||||||
@ -194,15 +195,15 @@ namespace Fsp
|
|||||||
}
|
}
|
||||||
protected virtual Int32 GetSecurityByName(
|
protected virtual Int32 GetSecurityByName(
|
||||||
String FileName,
|
String FileName,
|
||||||
out UInt32 PFileAttributes/* or ReparsePointIndex */,
|
out UInt32 FileAttributes/* or ReparsePointIndex */,
|
||||||
out GenericSecurityDescriptor SecurityDescriptor)
|
ref Object SecurityDescriptor)
|
||||||
{
|
{
|
||||||
PFileAttributes = default(UInt32);
|
FileAttributes = default(UInt32);
|
||||||
SecurityDescriptor = default(GenericSecurityDescriptor);
|
|
||||||
return STATUS_INVALID_DEVICE_REQUEST;
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FSP_FILE_SYSTEM_INTERFACE */
|
/* FSP_FILE_SYSTEM_INTERFACE */
|
||||||
|
private static Object SecurityDescriptorNotNull = new Object();
|
||||||
private static Int32 GetVolumeInfo(
|
private static Int32 GetVolumeInfo(
|
||||||
IntPtr FileSystem,
|
IntPtr FileSystem,
|
||||||
out VolumeInfo VolumeInfo)
|
out VolumeInfo VolumeInfo)
|
||||||
@ -241,29 +242,25 @@ namespace Fsp
|
|||||||
IntPtr SecurityDescriptor,
|
IntPtr SecurityDescriptor,
|
||||||
IntPtr PSecurityDescriptorSize)
|
IntPtr PSecurityDescriptorSize)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_DEVICE_REQUEST;
|
|
||||||
#if false
|
|
||||||
FileSystem self = (FileSystem)Api.FspFileSystemGetUserContext(FileSystem);
|
FileSystem self = (FileSystem)Api.FspFileSystemGetUserContext(FileSystem);
|
||||||
GenericSecurityDescriptor GenericSecurityDescriptor = null;
|
UInt32 FileAttributes;
|
||||||
|
Object SecurityDescriptorObject = null;
|
||||||
Int32 Result;
|
Int32 Result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Result = self.GetSecurityByName(FileName, out PFileAttributes,
|
if (IntPtr.Zero != PSecurityDescriptorSize)
|
||||||
out GenericSecurityDescriptor);
|
SecurityDescriptorObject = SecurityDescriptorNotNull;
|
||||||
|
Result = self.GetSecurityByName(FileName,
|
||||||
|
out FileAttributes, ref SecurityDescriptorObject);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
PFileAttributes = default(UInt32);
|
|
||||||
return self.ExceptionHandler(ex);
|
return self.ExceptionHandler(ex);
|
||||||
}
|
}
|
||||||
if (null != GenericSecurityDescriptor)
|
if (IntPtr.Zero != PFileAttributes)
|
||||||
{
|
Marshal.WriteInt32(PFileAttributes, (Int32)FileAttributes);
|
||||||
}
|
return Api.CopySecurityDescriptor(SecurityDescriptorObject,
|
||||||
else
|
SecurityDescriptor, PSecurityDescriptorSize);
|
||||||
{
|
|
||||||
}
|
|
||||||
return Result;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
private static Int32 Create(
|
private static Int32 Create(
|
||||||
IntPtr FileSystem,
|
IntPtr FileSystem,
|
||||||
|
@ -449,6 +449,35 @@ namespace Fsp.Interop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal static Int32 CopySecurityDescriptor(
|
||||||
|
Object SecurityDescriptorObject,
|
||||||
|
IntPtr SecurityDescriptor,
|
||||||
|
IntPtr PSecurityDescriptorSize)
|
||||||
|
{
|
||||||
|
if (IntPtr.Zero != PSecurityDescriptorSize)
|
||||||
|
{
|
||||||
|
GenericSecurityDescriptor GenericSecurityDescriptor =
|
||||||
|
SecurityDescriptorObject as GenericSecurityDescriptor;
|
||||||
|
if (null != GenericSecurityDescriptor)
|
||||||
|
{
|
||||||
|
if (GenericSecurityDescriptor.BinaryLength > Marshal.ReadInt32(PSecurityDescriptorSize))
|
||||||
|
{
|
||||||
|
Marshal.WriteInt32(PSecurityDescriptorSize, GenericSecurityDescriptor.BinaryLength);
|
||||||
|
return unchecked((Int32)0x80000005)/*STATUS_BUFFER_OVERFLOW*/;
|
||||||
|
}
|
||||||
|
Marshal.WriteInt32(PSecurityDescriptorSize, GenericSecurityDescriptor.BinaryLength);
|
||||||
|
if (IntPtr.Zero != SecurityDescriptor)
|
||||||
|
{
|
||||||
|
byte[] Bytes = new byte[GenericSecurityDescriptor.BinaryLength];
|
||||||
|
GenericSecurityDescriptor.GetBinaryForm(Bytes, 0);
|
||||||
|
Marshal.Copy(Bytes, 0, SecurityDescriptor, GenericSecurityDescriptor.BinaryLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Marshal.WriteInt32(PSecurityDescriptorSize, 0);
|
||||||
|
}
|
||||||
|
return 0/*STATUS_SUCCESS*/;
|
||||||
|
}
|
||||||
|
|
||||||
/* initialization */
|
/* initialization */
|
||||||
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user