Beispiel #1
0
        internal void SetHandleAttribute(AlpcHandleMessageAttribute attribute)
        {
            // If not handle attributes then just leave as is.
            if (!attribute.Handles.Any())
            {
                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
                };
            }
        }
Beispiel #2
0
 internal static SafeStructureInOutBuffer <T> AddStructureRef <T>(this DisposableList list, T value) where T : struct
 {
     return(list.AddResource(new SafeStructureInOutBuffer <T>(value)));
 }