コード例 #1
0
ファイル: TypeHelper.cs プロジェクト: liangran10000/dnlib-1
 /// <summary>
 /// Checks whether <paramref name="localSig"/> contains a <see cref="GenericVar"/> or a
 /// <see cref="GenericMVar"/>.
 /// </summary>
 /// <param name="localSig">Local signature</param>
 /// <returns><c>true</c> if <paramref name="localSig"/> contains a <see cref="GenericVar"/>
 /// or a <see cref="GenericMVar"/>.</returns>
 public static bool ContainsGenericParameter(LocalSig localSig)
 {
     return(new TypeHelper().ContainsGenericParameterInternal(localSig));
 }
コード例 #2
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="localSig">A locals sig</param>
		public StandAloneSigUser(LocalSig localSig) {
			this.signature = localSig;
		}
コード例 #3
0
ファイル: TypeHelper.cs プロジェクト: EmilZhou/dnlib
		bool ContainsGenericParameterInternal(LocalSig ls) {
			if (ls == null)
				return false;
			if (!recursionCounter.Increment())
				return false;

			bool res = ContainsGenericParameter(ls.Locals);

			recursionCounter.Decrement();
			return res;
		}
コード例 #4
0
ファイル: MemberRefFinder.cs プロジェクト: GreenDamTan/de4dot
 void Add(LocalSig sig)
 {
     if (sig == null)
         return;
     Add(sig.Locals);
 }
コード例 #5
0
ファイル: TypeHelper.cs プロジェクト: EmilZhou/dnlib
		/// <summary>
		/// Checks whether <paramref name="localSig"/> contains a <see cref="GenericVar"/> or a
		/// <see cref="GenericMVar"/>.
		/// </summary>
		/// <param name="localSig">Local signature</param>
		/// <returns><c>true</c> if <paramref name="localSig"/> contains a <see cref="GenericVar"/>
		/// or a <see cref="GenericMVar"/>.</returns>
		public static bool ContainsGenericParameter(LocalSig localSig) {
			return new TypeHelper().ContainsGenericParameterInternal(localSig);
		}
コード例 #6
0
ファイル: JITBody.cs プロジェクト: 2sic4you/ConfuserEx
        public void Write()
        {
            uint codeSize = InitializeInstructionOffsets();
            jitBody.MaxStack = keepMaxStack ? body.MaxStack : GetMaxStack();

            jitBody.Options = 0;
            if (body.InitLocals)
                jitBody.Options |= 0x10;

            if (body.Variables.Count > 0) {
                var local = new LocalSig(body.Variables.Select(var => var.Type).ToList());
                jitBody.LocalVars = SignatureWriter.Write(metadata, local);
            }
            else
                jitBody.LocalVars = new byte[0];

            using (var ms = new MemoryStream()) {
                uint _codeSize = WriteInstructions(new BinaryWriter(ms));
                Debug.Assert(codeSize == _codeSize);
                jitBody.ILCode = ms.ToArray();
            }

            jitBody.EHs = new JITEHClause[exceptionHandlers.Count];
            if (exceptionHandlers.Count > 0) {
                jitBody.Options |= 8;
                for (int i = 0; i < exceptionHandlers.Count; i++) {
                    ExceptionHandler eh = exceptionHandlers[i];
                    jitBody.EHs[i].Flags = (uint)eh.HandlerType;

                    uint tryStart = GetOffset(eh.TryStart);
                    uint tryEnd = GetOffset(eh.TryEnd);
                    jitBody.EHs[i].TryOffset = tryStart;
                    jitBody.EHs[i].TryLength = tryEnd - tryStart;

                    uint handlerStart = GetOffset(eh.HandlerStart);
                    uint handlerEnd = GetOffset(eh.HandlerEnd);
                    jitBody.EHs[i].HandlerOffset = handlerStart;
                    jitBody.EHs[i].HandlerLength = handlerEnd - handlerStart;

                    if (eh.HandlerType == ExceptionHandlerType.Catch) {
                        uint token = metadata.GetToken(eh.CatchType).Raw;
                        if ((token & 0xff000000) == 0x1b000000)
                            jitBody.Options |= 0x80;

                        jitBody.EHs[i].ClassTokenOrFilterOffset = token;
                    }
                    else if (eh.HandlerType == ExceptionHandlerType.Filter) {
                        jitBody.EHs[i].ClassTokenOrFilterOffset = GetOffset(eh.FilterStart);
                    }
                }
            }
        }
コード例 #7
0
ファイル: StandAloneSig.cs プロジェクト: modulexcite/dnlib
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="localSig">A locals sig</param>
 public StandAloneSigUser(LocalSig localSig)
 {
     this.signature = localSig;
 }
コード例 #8
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);
 }
コード例 #9
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 ? new List <TypeSig>() : sig.Locals);
 }