mirror of
https://github.com/winfsp/winfsp.git
synced 2025-06-08 13:02:10 -05:00
src: dll: SetDebugLogFile and other fixes
This commit is contained in:
parent
83c9351d38
commit
668948ebc1
@ -123,13 +123,13 @@ namespace Fsp
|
||||
}
|
||||
|
||||
/* control */
|
||||
Int32 Preflight(String MountPoint)
|
||||
public Int32 Preflight(String MountPoint)
|
||||
{
|
||||
return Api.FspFileSystemPreflight(
|
||||
_VolumeParams.IsPrefixEmpty() ? "WinFsp.Disk" : "WinFsp.Net",
|
||||
MountPoint);
|
||||
}
|
||||
Int32 Mount(String MountPoint,
|
||||
public Int32 Mount(String MountPoint,
|
||||
Byte[] SecurityDescriptor = null,
|
||||
Boolean Synchronized = false,
|
||||
UInt32 DebugLog = 0)
|
||||
@ -164,13 +164,14 @@ namespace Fsp
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
#if false
|
||||
PWSTR MountPoint()
|
||||
public String MountPoint()
|
||||
{
|
||||
return "UNKNOWN";
|
||||
#if false
|
||||
return 0 != _FileSystem ? FspFileSystemMountPoint(_FileSystem) : 0;
|
||||
}
|
||||
#endif
|
||||
IntPtr FileSystemHandle()
|
||||
}
|
||||
public IntPtr FileSystemHandle()
|
||||
{
|
||||
return _FileSystem;
|
||||
}
|
||||
@ -184,9 +185,9 @@ namespace Fsp
|
||||
{
|
||||
return Api.FspWin32FromNtStatus(Status);
|
||||
}
|
||||
public static void FspDebugLogSetHandle(IntPtr Handle)
|
||||
public static Int32 SetDebugLogFile(String FileName)
|
||||
{
|
||||
Api.FspDebugLogSetHandle(Handle);
|
||||
return Api.SetDebugLogFile(FileName);
|
||||
}
|
||||
|
||||
/* operations */
|
||||
|
@ -20,6 +20,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Security.AccessControl;
|
||||
|
||||
namespace Fsp.Interop
|
||||
{
|
||||
@ -663,6 +664,26 @@ namespace Fsp.Interop
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static Int32 SetDebugLogFile(String FileName)
|
||||
{
|
||||
IntPtr Handle;
|
||||
if ("-" == FileName)
|
||||
Handle = GetStdHandle(unchecked((UInt32)(-12))/*STD_ERROR_HANDLE*/);
|
||||
else
|
||||
Handle = CreateFileW(
|
||||
FileName,
|
||||
(UInt32)FileSystemRights.AppendData,
|
||||
(UInt32)(FileShare.Read | FileShare.Write),
|
||||
IntPtr.Zero,
|
||||
(UInt32)FileMode.OpenOrCreate,
|
||||
(UInt32)FileAttributes.Normal,
|
||||
IntPtr.Zero);
|
||||
if ((IntPtr)(-1) == Handle)
|
||||
return FspNtStatusFromWin32((UInt32)Marshal.GetLastWin32Error());
|
||||
Api.FspDebugLogSetHandle(Handle);
|
||||
return 0/*STATUS_SUCCESS*/;
|
||||
}
|
||||
|
||||
/* initialization */
|
||||
private static IntPtr LoadDll()
|
||||
{
|
||||
@ -738,6 +759,17 @@ namespace Fsp.Interop
|
||||
[MarshalAs(UnmanagedType.LPStr)] String lpProcName);
|
||||
[DllImport("advapi32.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern UInt32 GetSecurityDescriptorLength(IntPtr SecurityDescriptor);
|
||||
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||
private static extern IntPtr GetStdHandle(UInt32 nStdHandle);
|
||||
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
|
||||
private static extern IntPtr CreateFileW(
|
||||
[MarshalAs(UnmanagedType.LPWStr)] String lpFileName,
|
||||
UInt32 dwDesiredAccess,
|
||||
UInt32 dwShareMode,
|
||||
IntPtr lpSecurityAttributes,
|
||||
UInt32 dwCreationDisposition,
|
||||
UInt32 dwFlagsAndAttributes,
|
||||
IntPtr hTemplateFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user