From 77a1e3b88a394a731892bb7873ed2362e80ee84b Mon Sep 17 00:00:00 2001 From: drwtsn32x Date: Fri, 22 Nov 2019 08:00:58 -0800 Subject: [PATCH 1/3] disable attribute masking --- Duplicati/Library/Main/ProcessController.cs | 31 +++++++++++++++++++++ Duplicati/Library/Utility/Win32.cs | 29 +++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/Duplicati/Library/Main/ProcessController.cs b/Duplicati/Library/Main/ProcessController.cs index acbba2fc6..76d54abff 100755 --- a/Duplicati/Library/Main/ProcessController.cs +++ b/Duplicati/Library/Main/ProcessController.cs @@ -234,6 +234,35 @@ namespace Duplicati.Library.Main } } + /// + /// Expose all filesystem attributes + /// + private 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 + { + var currentPcm = Win32.RtlQueryProcessPlaceholderCompatibilityMode(); + if (currentPcm == Win32.PHCM_VALUES.PHCM_DISGUISE_PLACEHOLDER) + { + Win32.RtlSetProcessPlaceholderCompatibilityMode(Win32.PHCM_VALUES.PHCM_EXPOSE_PLACEHOLDERS); + } + } + catch + { + // Ignore exceptions - not supported on this version of Windows + } + } + } + /// /// Starts the process controller /// @@ -245,6 +274,8 @@ namespace Duplicati.Library.Main if (options.UseBackgroundIOPriority) ActivateBackgroundIOPriority(); + + ExposeAllFilesystemAttributes(); } /// diff --git a/Duplicati/Library/Utility/Win32.cs b/Duplicati/Library/Utility/Win32.cs index 1c1f4a331..fc78060c7 100644 --- a/Duplicati/Library/Utility/Win32.cs +++ b/Duplicati/Library/Utility/Win32.cs @@ -170,6 +170,19 @@ namespace Duplicati.Library.Utility MaxProcessInfoClass } + /// + /// Placeholder Compatibility Mode values + /// + 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,22 @@ namespace Duplicati.Library.Utility /// A handle to the process. The handle must have the PROCESS_SET_INFORMATION access right. [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern PROCESS_PRIORITY_CLASS GetPriorityClass(IntPtr handle); + + /// + /// Gets the current placeholder compatibility mode for the process. + /// + /// The value. + [DllImport("ntdll.dll")] + public static extern PHCM_VALUES RtlQueryProcessPlaceholderCompatibilityMode(); + + /// + /// Sets the current placeholder compatibility mode for the process. + /// + /// The previous value. + /// New value to set. + [DllImport("ntdll.dll")] + public static extern PHCM_VALUES RtlSetProcessPlaceholderCompatibilityMode(PHCM_VALUES pcm); + #endregion } } From f599336bf070ffe35ee17f655fd03bde9a57ae8c Mon Sep 17 00:00:00 2001 From: drwtsn32x Date: Fri, 22 Nov 2019 08:26:38 -0800 Subject: [PATCH 2/3] tweak for codacity --- Duplicati/Library/Main/ProcessController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Duplicati/Library/Main/ProcessController.cs b/Duplicati/Library/Main/ProcessController.cs index 76d54abff..a86cf05bf 100755 --- a/Duplicati/Library/Main/ProcessController.cs +++ b/Duplicati/Library/Main/ProcessController.cs @@ -237,7 +237,7 @@ namespace Duplicati.Library.Main /// /// Expose all filesystem attributes /// - private void ExposeAllFilesystemAttributes() + 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. From 942d8b820df66c8d0c81a35e13323a28c25e54c8 Mon Sep 17 00:00:00 2001 From: drwtsn32x Date: Tue, 26 Nov 2019 19:27:46 -0800 Subject: [PATCH 3/3] removed getter --- Duplicati/Library/Main/ProcessController.cs | 8 ++------ Duplicati/Library/Utility/Win32.cs | 7 ------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/Duplicati/Library/Main/ProcessController.cs b/Duplicati/Library/Main/ProcessController.cs index a86cf05bf..dd7c2f794 100755 --- a/Duplicati/Library/Main/ProcessController.cs +++ b/Duplicati/Library/Main/ProcessController.cs @@ -250,15 +250,11 @@ namespace Duplicati.Library.Main { try { - var currentPcm = Win32.RtlQueryProcessPlaceholderCompatibilityMode(); - if (currentPcm == Win32.PHCM_VALUES.PHCM_DISGUISE_PLACEHOLDER) - { - Win32.RtlSetProcessPlaceholderCompatibilityMode(Win32.PHCM_VALUES.PHCM_EXPOSE_PLACEHOLDERS); - } + Win32.RtlSetProcessPlaceholderCompatibilityMode(Win32.PHCM_VALUES.PHCM_EXPOSE_PLACEHOLDERS); } catch { - // Ignore exceptions - not supported on this version of Windows + // Ignore exceptions - not applicable on this version of Windows } } } diff --git a/Duplicati/Library/Utility/Win32.cs b/Duplicati/Library/Utility/Win32.cs index fc78060c7..8b56a7e2a 100644 --- a/Duplicati/Library/Utility/Win32.cs +++ b/Duplicati/Library/Utility/Win32.cs @@ -241,13 +241,6 @@ namespace Duplicati.Library.Utility [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern PROCESS_PRIORITY_CLASS GetPriorityClass(IntPtr handle); - /// - /// Gets the current placeholder compatibility mode for the process. - /// - /// The value. - [DllImport("ntdll.dll")] - public static extern PHCM_VALUES RtlQueryProcessPlaceholderCompatibilityMode(); - /// /// Sets the current placeholder compatibility mode for the process. ///