Exemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="arrayType">Array type</param>
 public ArraySig(TypeSig arrayType)
     : base(arrayType)
 {
     this.sizes       = ThreadSafeListCreator.Create <uint>();
     this.lowerBounds = ThreadSafeListCreator.Create <int>();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="callingConvention">调用约定</param>
 /// <param name="genParamCount">通用参数的数量</param>
 public MethodSig(CallingConvention callingConvention, uint genParamCount)
 {
     this.callingConvention = callingConvention;
     this.genParamCount     = genParamCount;
     this.parameters        = ThreadSafeListCreator.Create <TypeSig>();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="callingConvention">Calling convention (must have Property set)</param>
 internal PropertySig(CallingConvention callingConvention)
 {
     this.callingConvention = callingConvention;
     this.parameters        = ThreadSafeListCreator.Create <TypeSig>();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the locals
 /// </summary>
 /// <param name="sig">this</param>
 /// <returns>All locals</returns>
 public static IList <TypeSig> GetLocals(this LocalSig sig)
 {
     return(sig == null?ThreadSafeListCreator.Create <TypeSig>() : sig.Locals);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 默认构造函数
 /// </summary>
 public MethodSig()
 {
     this.parameters = ThreadSafeListCreator.Create <TypeSig>();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="callingConvention">Calling convention (must have GenericInst set)</param>
 /// <param name="size">Number of generic args</param>
 internal GenericInstMethodSig(CallingConvention callingConvention, uint size)
 {
     this.callingConvention = callingConvention;
     this.genericArgs       = ThreadSafeListCreator.Create <TypeSig>((int)size);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="args">Generic args</param>
 public GenericInstMethodSig(IList <TypeSig> args)
 {
     this.callingConvention = CallingConvention.GenericInst;
     this.genericArgs       = ThreadSafeListCreator.Create <TypeSig>(args);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ctor">Custom attribute constructor</param>
        /// <param name="arguments">Constructor arguments. The list is now owned by this instance.</param>
        /// <param name="namedArguments">Named arguments. The list is now owned by this instance.</param>
        /// <param name="blobReader">A reader that returns the original custom attribute blob data</param>
        internal CustomAttribute(ICustomAttributeType ctor, List <CAArgument> arguments, List <CANamedArgument> namedArguments, IBinaryReader blobReader)
        {
            this.ctor      = ctor;
            this.arguments = arguments == null?ThreadSafeListCreator.Create <CAArgument>() : ThreadSafeListCreator.MakeThreadSafe(arguments);

            this.namedArguments = namedArguments == null?ThreadSafeListCreator.Create <CANamedArgument>() : ThreadSafeListCreator.MakeThreadSafe(namedArguments);

            this.blobReader = blobReader;
        }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a new instruction with an instruction target list operand
 /// </summary>
 /// <param name="targets">The targets</param>
 /// <returns>A new <see cref="Instruction"/> instance</returns>
 public Instruction ToInstruction(IList <Instruction> targets)
 {
     return(Instruction.Create(this, ThreadSafeListCreator.MakeThreadSafe(targets)));
 }
Exemplo n.º 10
0
 /// <summary>Initializes <see cref="overrides"/></summary>
 protected virtual void InitializeOverrides()
 {
     Interlocked.CompareExchange(ref overrides, ThreadSafeListCreator.Create <MethodOverride>(), null);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ctor">Custom attribute constructor</param>
        /// <param name="arguments">Constructor arguments or <c>null</c> if none</param>
        /// <param name="namedArguments">Named arguments or <c>null</c> if none</param>
        /// <param name="blobReader">A reader that returns the original custom attribute blob data</param>
        public CustomAttribute(ICustomAttributeType ctor, IEnumerable <CAArgument> arguments, IEnumerable <CANamedArgument> namedArguments, IBinaryReader blobReader)
        {
            this.ctor      = ctor;
            this.arguments = arguments == null?ThreadSafeListCreator.Create <CAArgument>() : ThreadSafeListCreator.Create <CAArgument>(arguments);

            this.namedArguments = namedArguments == null?ThreadSafeListCreator.Create <CANamedArgument>() : ThreadSafeListCreator.Create <CANamedArgument>(namedArguments);

            this.blobReader = blobReader;
        }
Exemplo n.º 12
0
 /// <summary>Initializes <see cref="customDebugInfos"/></summary>
 protected virtual void InitializeCustomDebugInfos()
 {
     Interlocked.CompareExchange(ref customDebugInfos, ThreadSafeListCreator.Create <PdbCustomDebugInfo>(), null);
 }
Exemplo n.º 13
0
 /// <inheritdoc/>
 public override ThreadSafe.IList <int> GetLowerBounds()
 {
     return(ThreadSafeListCreator.Create <int>());
 }
Exemplo n.º 14
0
 /// <inheritdoc/>
 public override ThreadSafe.IList <uint> GetSizes()
 {
     return(ThreadSafeListCreator.Create <uint>());
 }
Exemplo n.º 15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="locals">All locals</param>
 public LocalSig(IList <TypeSig> locals)
 {
     this.callingConvention = CallingConvention.LocalSig;
     this.locals            = ThreadSafeListCreator.Create <TypeSig>(locals);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="action">The security action</param>
 /// <param name="securityAttrs">The security attributes (now owned by this)</param>
 public DeclSecurityUser(SecurityAction action, IList <SecurityAttribute> securityAttrs)
 {
     this.action             = action;
     this.securityAttributes = ThreadSafeListCreator.MakeThreadSafe(securityAttrs);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="locals">All locals (this instance now owns it)</param>
 /// <param name="dummy">Dummy</param>
 internal LocalSig(IList <TypeSig> locals, bool dummy)
 {
     this.callingConvention = CallingConvention.LocalSig;
     this.locals            = ThreadSafeListCreator.MakeThreadSafe(locals);
 }
Exemplo n.º 18
0
 /// <summary>Initializes <see cref="securityAttributes"/></summary>
 protected virtual void InitializeSecurityAttributes()
 {
     Interlocked.CompareExchange(ref securityAttributes, ThreadSafeListCreator.Create <SecurityAttribute>(), null);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="arg1">Generic arg #1</param>
 /// <param name="arg2">Generic arg #2</param>
 /// <param name="arg3">Generic arg #3</param>
 public GenericInstMethodSig(TypeSig arg1, TypeSig arg2, TypeSig arg3)
 {
     this.callingConvention = CallingConvention.GenericInst;
     this.genericArgs       = ThreadSafeListCreator.Create <TypeSig>(arg1, arg2, arg3);
 }
Exemplo n.º 20
0
 /// <summary>Initializes <see cref="declSecurities"/></summary>
 protected virtual void InitializeDeclSecurities()
 {
     Interlocked.CompareExchange(ref declSecurities, ThreadSafeListCreator.Create <DeclSecurity>(), null);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Gets the parameters
 /// </summary>
 /// <param name="sig">this</param>
 /// <returns>The parameters</returns>
 public static IList <TypeSig> GetParams(this MethodBaseSig sig)
 {
     return(sig == null?ThreadSafeListCreator.Create <TypeSig>() : sig.Params);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="attrType">Attribute type</param>
 /// <param name="namedArguments">Named arguments that will be owned by this instance</param>
 public SecurityAttribute(ITypeDefOrRef attrType, IList <CANamedArgument> namedArguments)
 {
     this.attrType       = attrType;
     this.namedArguments = ThreadSafeListCreator.MakeThreadSafe(namedArguments ?? new List <CANamedArgument>());
 }
Exemplo n.º 23
0
 /// <summary>
 /// Gets the generic arguments
 /// </summary>
 /// <param name="sig">this</param>
 /// <returns>All generic arguments</returns>
 public static IList <TypeSig> GetGenericArguments(this GenericInstMethodSig sig)
 {
     return(sig == null?ThreadSafeListCreator.Create <TypeSig>() : sig.GenericArguments);
 }
Exemplo n.º 24
0
        /// <inheritdoc/>
        protected override void InitializeInternal()
        {
            var hotHeapVersion = GetHotHeapVersion(peImage.FileName, mdHeader.VersionString);

            IImageStream     imageStream = null, fullStream = null;
            DotNetStream     dns        = null;
            List <HotStream> hotStreams = null;
            HotStream        hotStream  = null;
            var newAllStreams           = new List <DotNetStream>(allStreams);

            try
            {
                var mdRva = cor20Header.MetaData.VirtualAddress;
                for (int i = mdHeader.StreamHeaders.Count - 1; i >= 0; i--)
                {
                    var sh         = mdHeader.StreamHeaders[i];
                    var rva        = mdRva + sh.Offset;
                    var fileOffset = peImage.ToFileOffset(rva);
                    imageStream = peImage.CreateStream(fileOffset, sh.StreamSize);
                    switch (sh.Name)
                    {
                    case "#Strings":
                        if (stringsStream == null)
                        {
                            stringsStream = new StringsStream(imageStream, sh);
                            imageStream   = null;
                            newAllStreams.Add(stringsStream);
                            continue;
                        }
                        break;

                    case "#US":
                        if (usStream == null)
                        {
                            usStream    = new USStream(imageStream, sh);
                            imageStream = null;
                            newAllStreams.Add(usStream);
                            continue;
                        }
                        break;

                    case "#Blob":
                        if (blobStream == null)
                        {
                            blobStream  = new BlobStream(imageStream, sh);
                            imageStream = null;
                            newAllStreams.Add(blobStream);
                            continue;
                        }
                        break;

                    case "#GUID":
                        if (guidStream == null)
                        {
                            guidStream  = new GuidStream(imageStream, sh);
                            imageStream = null;
                            newAllStreams.Add(guidStream);
                            continue;
                        }
                        break;

                    case "#~":
                        if (tablesStream == null)
                        {
                            tablesStream = new TablesStream(imageStream, sh);
                            imageStream  = null;
                            newAllStreams.Add(tablesStream);
                            continue;
                        }
                        break;

                    case "#!":
                        if (hotStreams == null)
                        {
                            hotStreams = new List <HotStream>();
                        }
                        fullStream = peImage.CreateFullStream();
                        hotStream  = HotStream.Create(hotHeapVersion, imageStream, sh, fullStream, fileOffset);
                        fullStream = null;
                        hotStreams.Add(hotStream);
                        newAllStreams.Add(hotStream);
                        hotStream   = null;
                        imageStream = null;
                        continue;
                    }
                    dns         = new DotNetStream(imageStream, sh);
                    imageStream = null;
                    newAllStreams.Add(dns);
                    dns = null;
                }
            }
            finally
            {
                if (imageStream != null)
                {
                    imageStream.Dispose();
                }
                if (fullStream != null)
                {
                    fullStream.Dispose();
                }
                if (dns != null)
                {
                    dns.Dispose();
                }
                if (hotStream != null)
                {
                    hotStream.Dispose();
                }
                newAllStreams.Reverse();
                allStreams = ThreadSafeListCreator.MakeThreadSafe(newAllStreams);
            }

            if (tablesStream == null)
            {
                throw new BadImageFormatException("Missing MD stream");
            }

            if (hotStreams != null)
            {
                hotStreams.Reverse();
                InitializeHotStreams(hotStreams);
            }

            tablesStream.Initialize(peImage);
        }
Exemplo n.º 25
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="callingConvention">调用约定</param>
 public MethodSig(CallingConvention callingConvention)
 {
     this.callingConvention = callingConvention;
     this.parameters        = ThreadSafeListCreator.Create <TypeSig>();
 }
Exemplo n.º 26
0
 /// <summary>
 /// Initializes <see cref="otherMethods"/>, <see cref="addMethod"/>,
 /// <see cref="invokeMethod"/> and <see cref="removeMethod"/>.
 /// </summary>
 protected virtual void InitializeEventMethods_NoLock()
 {
     otherMethods = ThreadSafeListCreator.Create <MethodDef>();
 }
Exemplo n.º 27
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public PropertySig()
 {
     this.callingConvention = CallingConvention.Property;
     this.parameters        = ThreadSafeListCreator.Create <TypeSig>();
 }
Exemplo n.º 28
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="local1">Local type #1</param>
 /// <param name="local2">Local type #2</param>
 /// <param name="local3">Local type #3</param>
 public LocalSig(TypeSig local1, TypeSig local2, TypeSig local3)
 {
     this.callingConvention = CallingConvention.LocalSig;
     this.locals            = ThreadSafeListCreator.Create <TypeSig>(local1, local2, local3);
 }
Exemplo n.º 29
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="hasThis"><c>true</c> if instance, <c>false</c> if static</param>
 public PropertySig(bool hasThis)
 {
     this.callingConvention = CallingConvention.Property | (hasThis ? CallingConvention.HasThis : 0);
     this.parameters        = ThreadSafeListCreator.Create <TypeSig>();
 }
Exemplo n.º 30
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="genericType">The generic type</param>
 /// <param name="genArgs">Generic arguments</param>
 public GenericInstSig(ClassOrValueTypeSig genericType, IList <TypeSig> genArgs)
 {
     this.genericType = genericType;
     this.genericArgs = ThreadSafeListCreator.Create <TypeSig>(genArgs);
 }