From 1bff31fef8b22f21c15ad35f3cb27da6c92fa37e Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Fri, 28 Jul 2017 13:44:07 -0700 Subject: [PATCH 1/2] Use supported API to set CAPID in the SACL --- src/Microsoft.PowerShell.Security/security/AclCommands.cs | 2 +- src/System.Management.Automation/security/nativeMethods.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.PowerShell.Security/security/AclCommands.cs b/src/Microsoft.PowerShell.Security/security/AclCommands.cs index fd93a869517..3d1a73f6358 100644 --- a/src/Microsoft.PowerShell.Security/security/AclCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/AclCommands.cs @@ -1194,7 +1194,7 @@ private IntPtr GetSaclWithCapId(string capStr) } // Add CAPID to the SACL. - rs = NativeMethods.RtlAddScopedPolicyIDAce( + rs = NativeMethods.AddScopedPolicyIDAce( pSacl, NativeMethods.ACL_REVISION, NativeMethods.SUB_CONTAINERS_AND_OBJECTS_INHERIT, diff --git a/src/System.Management.Automation/security/nativeMethods.cs b/src/System.Management.Automation/security/nativeMethods.cs index e1465e8fdec..0a953234e11 100644 --- a/src/System.Management.Automation/security/nativeMethods.cs +++ b/src/System.Management.Automation/security/nativeMethods.cs @@ -1786,8 +1786,8 @@ internal static extern bool InitializeAcl( uint nAclLength, uint dwAclRevision); - [DllImport("ntdll.dll", CharSet = CharSet.Unicode)] - internal static extern uint RtlAddScopedPolicyIDAce( + [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + internal static extern uint AddScopedPolicyIDAce( IntPtr Acl, uint AceRevision, uint AceFlags, From 96b896a27e575351db1ceeea7d47831932601005 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Fri, 4 Aug 2017 11:24:53 -0700 Subject: [PATCH 2/2] switch to use win8.1 API set for AddScopedPolicyIDAce --- src/System.Management.Automation/security/nativeMethods.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/security/nativeMethods.cs b/src/System.Management.Automation/security/nativeMethods.cs index 0a953234e11..49561ae58df 100644 --- a/src/System.Management.Automation/security/nativeMethods.cs +++ b/src/System.Management.Automation/security/nativeMethods.cs @@ -1786,7 +1786,7 @@ internal static extern bool InitializeAcl( uint nAclLength, uint dwAclRevision); - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + [DllImport("api-ms-win-security-base-l1-2-0.dll", CharSet = CharSet.Unicode)] internal static extern uint AddScopedPolicyIDAce( IntPtr Acl, uint AceRevision,