diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ComGuids.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ComGuids.cs index b6398fa0e06..a7d699dba64 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ComGuids.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ComGuids.cs @@ -33,6 +33,8 @@ internal static class IID public const string ShellFolder = "000214E6-0000-0000-C000-000000000046"; /// IID_IShellLink public const string ShellLink = "000214F9-0000-0000-C000-000000000046"; + /// IID_IShellLinkDataList + public const string ShellLinkDataList = "45E2B4AE-B1C3-11D0-B92F-00A0C90312E1"; /// IID_IShellItem public const string ShellItem = "43826d1e-e718-42ee-bc55-a1e261c37bfe"; /// IID_IShellItem2 diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs index faf5535bf60..e42ba965559 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs @@ -428,6 +428,30 @@ internal interface IShellLinkW void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile); } + /// + /// Critical: Suppresses unmanaged code security. + /// + [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] + [ + ComImport, + InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown), + Guid(IID.ShellLinkDataList), + ] + internal interface IShellLinkDataList + { + [PreserveSig] + Int32 AddDataBlock(IntPtr pDataBlock); + + [PreserveSig] + Int32 CopyDataBlock(uint dwSig, out IntPtr ppDataBlock); + + [PreserveSig] + Int32 RemoveDataBlock(uint dwSig); + + void GetFlags(out uint pdwFlags); + void SetFlags(uint dwFlags); + } + /// /// Critical: Suppresses unmanaged code security. /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpList.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpList.cs index 5abea09af77..35773c9ae70 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpList.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpList.cs @@ -1082,6 +1082,17 @@ private static IShellLinkW CreateLinkFromJumpTask(JumpTask jumpTask, bool allowS link.SetDescription(jumpTask.Description); } + if (jumpTask.FlagsToEnable != null) + { + var shellLinkDataList = (IShellLinkDataList)link; + shellLinkDataList.GetFlags(out uint flags); + foreach (uint flagToEnable in jumpTask.FlagsToEnable) + { + flags |= flagToEnable; + } + shellLinkDataList.SetFlags(flags); + } + IPropertyStore propStore = (IPropertyStore)link; var pv = new PROPVARIANT(); try diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpTask.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpTask.cs index f8b8c44c8f0..0c366c340d8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpTask.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/JumpTask.cs @@ -24,5 +24,11 @@ public JumpTask() : base() public string IconResourcePath { get; set; } public int IconResourceIndex { get; set; } + + /// + /// Shell link data flags to enable. For more details see the SHELL_LINK_DATA_FLAGS documentation + /// https://docs.microsoft.com/windows/desktop/api/shlobj_core/ne-shlobj_core-shell_link_data_flags + /// + public int[] FlagsToEnable { get; set; } } }