Merge pull request #3998 from drwtsn32x/fix-attribute-masking

Disable file attribute masking on Windows 10
This commit is contained in:
Hendrik
2019-11-27 11:38:27 +01:00
committed by GitHub
2 changed files with 49 additions and 0 deletions
@@ -234,6 +234,31 @@ namespace Duplicati.Library.Main
}
}
/// <summary>
/// Expose all filesystem attributes
/// </summary>
private static void ExposeAllFilesystemAttributes()
{
// Starting with Windows 10 1803, the operating system may mask the process's view of some
// file attributes such as reparse, offline, and sparse.
//
// This function will turn off such masking.
//
// See https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-rtlqueryprocessplaceholdercompatibilitymode
if (Platform.IsClientWindows)
{
try
{
Win32.RtlSetProcessPlaceholderCompatibilityMode(Win32.PHCM_VALUES.PHCM_EXPOSE_PLACEHOLDERS);
}
catch
{
// Ignore exceptions - not applicable on this version of Windows
}
}
}
/// <summary>
/// Starts the process controller
/// </summary>
@@ -245,6 +270,8 @@ namespace Duplicati.Library.Main
if (options.UseBackgroundIOPriority)
ActivateBackgroundIOPriority();
ExposeAllFilesystemAttributes();
}
/// <summary>
+22
View File
@@ -170,6 +170,19 @@ namespace Duplicati.Library.Utility
MaxProcessInfoClass
}
/// <summary>
/// Placeholder Compatibility Mode values
/// </summary>
public enum PHCM_VALUES : sbyte
{
PHCM_APPLICATION_DEFAULT = 0,
PHCM_DISGUISE_PLACEHOLDER = 1,
PHCM_EXPOSE_PLACEHOLDERS = 2,
PHCM_MAX = 2,
PHCM_ERROR_INVALID_PARAMETER = -1,
PHCM_ERROR_NO_TEB = -2,
}
#endregion
#region Function calls
@@ -227,6 +240,15 @@ namespace Duplicati.Library.Utility
/// <param name="handle">A handle to the process. The handle must have the PROCESS_SET_INFORMATION access right.</param>
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern PROCESS_PRIORITY_CLASS GetPriorityClass(IntPtr handle);
/// <summary>
/// Sets the current placeholder compatibility mode for the process.
/// </summary>
/// <returns>The previous <see cref="PHCM_VALUES"/> value.</returns>
/// <param name="pcm">New value to set.</param>
[DllImport("ntdll.dll")]
public static extern PHCM_VALUES RtlSetProcessPlaceholderCompatibilityMode(PHCM_VALUES pcm);
#endregion
}
}