public SafeTokenGroupsBuffer(SidAndAttributes[] sid_and_attr, SafeHandleList sids) : base(new TokenGroups() { GroupCount = sids.Count }, Marshal.SizeOf(typeof(SidAndAttributes)) * sids.Count, true) { _sids = sids; Data.WriteArray(0, sid_and_attr, 0, sid_and_attr.Length); }
/// <summary> /// Take a copy of the safe handle list so the the original can be disposed. /// </summary> /// <returns>The copy of the handle list.</returns> public SafeHandleList DangerousTakeCopy() { SafeHandleList ret = new SafeHandleList(this); foreach (SafeHandle handle in ret) { bool success = false; handle.DangerousAddRef(ref success); } return(ret); }
public SafeTokenGroupsBuffer ToBuffer() { using (SafeHandleList sids = new SafeHandleList(_sid_and_attrs.Count)) { SidAndAttributes[] result = new SidAndAttributes[_sid_and_attrs.Count]; for (int i = 0; i < _sid_and_attrs.Count; ++i) { sids.Add(_sid_and_attrs[i]._sid.ToSafeBuffer()); result[i] = new SidAndAttributes { Sid = sids[i].DangerousGetHandle(), Attributes = (GroupAttributes)_sid_and_attrs[i]._attr }; } return(new SafeTokenGroupsBuffer(result, sids.DangerousMove())); } }