public HResult GetSecurity(SecurityInformation RequestedInformation, out IntPtr SecurityDescriptor, bool Default) { try { using (var sd = _securable.GetSecurity(RequestedInformation)) { // Since the ACL editor will free the security descriptor using // LocalFree, we need to use a local memory allocation and copy // the security descriptor into it. using (var localAlloc = new LocalMemoryAlloc(sd.Length)) { localAlloc.WriteMemory(0, sd.Memory, sd.Length); localAlloc.Reference(); // reference for ACL editor SecurityDescriptor = localAlloc; } } } catch (WindowsException ex) { SecurityDescriptor = IntPtr.Zero; return(ex.ErrorCode.GetHResult()); } return(HResult.OK); }