Пример #1
0
        internal void FromSafeBuffer(SafeAlpcMessageAttributesBuffer buffer, NtAlpc port, AlpcMessage message)
        {
            var result      = buffer.Result;
            var valid_attrs = result.ValidAttributes;

            if (valid_attrs.HasFlag(AlpcMessageAttributeFlags.Token))
            {
                AddAttribute <AlpcTokenMessageAttribute>(buffer, port, message);
            }
            if (valid_attrs.HasFlag(AlpcMessageAttributeFlags.Context))
            {
                AddAttribute <AlpcContextMessageAttribute>(buffer, port, message);
            }
            if (valid_attrs.HasFlag(AlpcMessageAttributeFlags.Handle))
            {
                var attribute = AddAttribute <AlpcHandleMessageAttribute>(buffer, port, message);
                _handles.AddRange(attribute.Handles.Select(h => NtObjectUtils.FromHandle(h.Handle, true)));
            }
            if (valid_attrs.HasFlag(AlpcMessageAttributeFlags.Security))
            {
                var attr = AddAttribute <AlpcSecurityMessageAttribute>(buffer, port, message);
                SecurityContext = new SafeAlpcSecurityContextHandle(attr.ContextHandle, true, port, attr.Flags, attr.SecurityQoS);
            }
            if (valid_attrs.HasFlag(AlpcMessageAttributeFlags.View))
            {
                var attr = AddAttribute <AlpcDataViewMessageAttribute>(buffer, port, message);
                DataView = new SafeAlpcDataViewBuffer(new IntPtr(attr.ViewBase), attr.ViewSize,
                                                      new SafeAlpcPortSectionHandle(attr.SectionHandle, true, port), attr.Flags, true);
            }
            if (valid_attrs.HasFlag(AlpcMessageAttributeFlags.WorkOnBehalfOf))
            {
                AddAttribute <AlpcWorkOnBehalfMessageAttribute>(buffer, port, message);
            }
        }