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
ff5850847f
commit
fc51b7cc22
@ -306,60 +306,99 @@ namespace Fsp.Interop
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
[SuppressUnmanagedCodeSecurity]
|
||||||
internal static class Native
|
internal static class Api
|
||||||
{
|
{
|
||||||
internal const String dllname = "winfsp.dll";
|
internal const String DllName = "winfsp.dll";
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern Int32 FspFileSystemPreflight(
|
internal static extern Int32 FspFileSystemPreflight(
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] String DevicePath,
|
[MarshalAs(UnmanagedType.LPWStr)] String DevicePath,
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] String MountPoint);
|
[MarshalAs(UnmanagedType.LPWStr)] String MountPoint);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern Int32 FspFileSystemCreate(
|
internal static extern Int32 FspFileSystemCreate(
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] String DevicePath,
|
[MarshalAs(UnmanagedType.LPWStr)] String DevicePath,
|
||||||
ref VolumeParams VolumeParams,
|
ref VolumeParams VolumeParams,
|
||||||
ref FileSystemInterface Interface,
|
ref FileSystemInterface Interface,
|
||||||
out IntPtr PFileSystem);
|
out IntPtr PFileSystem);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern void FspFileSystemDelete(IntPtr FileSystem);
|
internal static extern void FspFileSystemDelete(IntPtr FileSystem);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern Int32 FspFileSystemSetMountPoint(
|
internal static extern Int32 FspFileSystemSetMountPoint(
|
||||||
IntPtr FileSystem,
|
IntPtr FileSystem,
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] String MountPoint);
|
[MarshalAs(UnmanagedType.LPWStr)] String MountPoint);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern Int32 FspFileSystemSetMountPointEx(
|
internal static extern Int32 FspFileSystemSetMountPointEx(
|
||||||
IntPtr FileSystem,
|
IntPtr FileSystem,
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] String MountPoint,
|
[MarshalAs(UnmanagedType.LPWStr)] String MountPoint,
|
||||||
IntPtr SecurityDescriptor);
|
IntPtr SecurityDescriptor);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern Int32 FspFileSystemRemoveMountPoint(
|
internal static extern Int32 FspFileSystemRemoveMountPoint(
|
||||||
IntPtr FileSystem);
|
IntPtr FileSystem);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern Int32 FspFileSystemStartDispatcher(
|
internal static extern Int32 FspFileSystemStartDispatcher(
|
||||||
IntPtr FileSystem,
|
IntPtr FileSystem,
|
||||||
UInt32 ThreadCount);
|
UInt32 ThreadCount);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern Int32 FspFileSystemStopDispatcher(
|
internal static extern Int32 FspFileSystemStopDispatcher(
|
||||||
IntPtr FileSystem);
|
IntPtr FileSystem);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern Int32 FspVersion(
|
internal static extern Int32 FspVersion(
|
||||||
out UInt32 PVersion);
|
out UInt32 PVersion);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern Int32 FspNtStatusFromWin32(
|
internal static extern Int32 FspNtStatusFromWin32(
|
||||||
UInt32 Error);
|
UInt32 Error);
|
||||||
|
|
||||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
internal static extern UInt32 FspWin32FromNtStatus(
|
internal static extern UInt32 FspWin32FromNtStatus(
|
||||||
Int32 Status);
|
Int32 Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static class Initializer
|
||||||
|
{
|
||||||
|
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||||
|
private static extern IntPtr LoadLibraryW(
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] String DllName);
|
||||||
|
|
||||||
|
private static Boolean Load()
|
||||||
|
{
|
||||||
|
String DllPath = null;
|
||||||
|
String DllName = 8 == IntPtr.Size ? "winfsp-x64.dll" : "winfsp-x86.dll";
|
||||||
|
String KeyName = 8 == IntPtr.Size ?
|
||||||
|
"HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\WinFsp" :
|
||||||
|
"HKEY_LOCAL_MACHINE\\Software\\WinFsp";
|
||||||
|
IntPtr Module;
|
||||||
|
|
||||||
|
Module = LoadLibraryW(DllName);
|
||||||
|
if (IntPtr.Zero == Module)
|
||||||
|
{
|
||||||
|
DllPath = Microsoft.Win32.Registry.GetValue(KeyName, "InstallDir", null) as String;
|
||||||
|
if (null == DllPath)
|
||||||
|
return false;
|
||||||
|
Module = LoadLibraryW(DllPath + DllName);
|
||||||
|
if (IntPtr.Zero == Module)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Initialize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static Initializer()
|
||||||
|
{
|
||||||
|
if (!Load())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user