示例#1
0
        internal void SetHandleAttribute(AlpcHandleMessageAttribute attribute)
        {
            // If no handle attributes then just zero the buffer.
            if (!attribute.Handles.Any())
            {
                var attr = GetAttribute <AlpcHandleAttr>(AlpcMessageAttributeFlags.Handle);
                attr.Result = new AlpcHandleAttr()
                {
                    Flags         = 0,
                    ObjectType    = 0,
                    Handle        = IntPtr.Zero,
                    DesiredAccess = 0
                };
                return;
            }

            int count = attribute.Handles.Count();

            if (count > 1)
            {
                var attr    = GetAttribute <AlpcHandleAttrIndirect>(AlpcMessageAttributeFlags.Handle);
                var handles = attribute.Handles.Select(h => new AlpcHandleAttr32()
                {
                    Handle        = h.Handle,
                    ObjectType    = h.ObjectType,
                    Flags         = h.Flags,
                    DesiredAccess = h.DesiredAccess
                }
                                                       );
                var handle_buffer = _resources.AddResource(handles.ToArray().ToBuffer());
                attr.Result = new AlpcHandleAttrIndirect()
                {
                    HandleAttrArray = handle_buffer.DangerousGetHandle(),
                    HandleCount     = count,
                    Flags           = AlpcHandleAttrFlags.Indirect
                };
            }
            else
            {
                var attr = GetAttribute <AlpcHandleAttr>(AlpcMessageAttributeFlags.Handle);
                AlpcHandleMessageAttributeEntry handle = attribute.Handles.First();
                attr.Result = new AlpcHandleAttr()
                {
                    Flags         = handle.Flags,
                    ObjectType    = handle.ObjectType,
                    Handle        = new IntPtr(handle.Handle),
                    DesiredAccess = handle.DesiredAccess
                };
            }
        }
示例#2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="handle">The handle entry.</param>
 public AlpcHandleMessageAttribute(AlpcHandleMessageAttributeEntry handle)
     : this(new AlpcHandleMessageAttributeEntry[] { handle })
 {
 }
示例#3
0
 /// <summary>
 /// Add a list of handles to the send attributes.
 /// </summary>
 /// <param name="handle">The handle to add.</param>
 public void AddHandle(AlpcHandleMessageAttributeEntry handle)
 {
     AddHandles(new AlpcHandleMessageAttributeEntry[] { handle });
 }