示例#1
0
        // v3.3.134+
        bool FindInt6(int index)
        {
            index = GetNextLdci4InSameBlock(index);
            if (index < 0)
            {
                return(true);
            }

            return(stringMethodConsts.GetNextInt32(ref index, out i6));
        }
示例#2
0
        bool FindIntsCctor(MethodDef cctor)
        {
            int index = 0;

            if (!FindCallGetFrame(cctor, ref index))
            {
                return(FindIntsCctor2(cctor));
            }

            int tmp1, tmp2, tmp3 = 0;
            var constantsReader = new EfConstantsReader(cctor);

            if (!constantsReader.GetNextInt32(ref index, out tmp1))
            {
                return(false);
            }
            if (tmp1 == 0 && !constantsReader.GetNextInt32(ref index, out tmp1))
            {
                return(false);
            }
            if (!constantsReader.GetNextInt32(ref index, out tmp2))
            {
                return(false);
            }
            if (tmp2 == 0 && !constantsReader.GetNextInt32(ref index, out tmp2))
            {
                return(false);
            }

            index = 0;
            var instrs = cctor.Body.Instructions;

            while (index < instrs.Count)
            {
                int tmp4;
                if (!constantsReader.GetNextInt32(ref index, out tmp4))
                {
                    break;
                }
                if (index < instrs.Count && instrs[index].IsLdloc())
                {
                    tmp3 = tmp4;
                }
            }

            i1 = tmp1 ^ tmp2 ^ tmp3;
            return(true);
        }
        static List <int> GetConstants(MethodDef method)
        {
            var list = new List <int>();

            if (method == null)
            {
                return(list);
            }

            int index           = 0;
            var instrs          = method.Body.Instructions;
            var constantsReader = new EfConstantsReader(method);

            while (true)
            {
                int val;
                if (!constantsReader.GetNextInt32(ref index, out val))
                {
                    break;
                }

                if (index < instrs.Count && instrs[index].OpCode.Code != Code.Ret)
                {
                    list.Add(val);
                }
            }

            return(list);
        }
示例#4
0
        // Compact Framework doesn't have StackFrame
        bool FindIntsCctor2(MethodDef cctor)
        {
            int index           = 0;
            var instrs          = cctor.Body.Instructions;
            var constantsReader = new EfConstantsReader(cctor);

            while (index >= 0)
            {
                int val;
                if (!constantsReader.GetNextInt32(ref index, out val))
                {
                    break;
                }
                if (index < instrs.Count && instrs[index].OpCode.Code == Code.Add)
                {
                    i1 = val;
                    return(true);
                }
            }

            return(false);
        }
示例#5
0
		// Compact Framework doesn't have StackFrame
		bool FindIntsCctor2(MethodDef cctor) {
			int index = 0;
			var instrs = cctor.Body.Instructions;
			var constantsReader = new EfConstantsReader(cctor);
			while (index >= 0) {
				int val;
				if (!constantsReader.GetNextInt32(ref index, out val))
					break;
				if (index < instrs.Count && instrs[index].OpCode.Code == Code.Add) {
					i1 = val;
					return true;
				}
			}

			return false;
		}
示例#6
0
		bool FindIntsCctor(MethodDef cctor) {
			int index = 0;
			if (!FindCallGetFrame(cctor, ref index))
				return FindIntsCctor2(cctor);

			int tmp1, tmp2, tmp3 = 0;
			var constantsReader = new EfConstantsReader(cctor);
			if (!constantsReader.GetNextInt32(ref index, out tmp1))
				return false;
			if (tmp1 == 0 && !constantsReader.GetNextInt32(ref index, out tmp1))
				return false;
			if (!constantsReader.GetNextInt32(ref index, out tmp2))
				return false;
			if (tmp2 == 0 && !constantsReader.GetNextInt32(ref index, out tmp2))
				return false;

			index = 0;
			var instrs = cctor.Body.Instructions;
			while (index < instrs.Count) {
				int tmp4;
				if (!constantsReader.GetNextInt32(ref index, out tmp4))
					break;
				if (index < instrs.Count && instrs[index].IsLdloc())
					tmp3 = tmp4;
			}

			i1 = tmp1 ^ tmp2 ^ tmp3;
			return true;
		}
示例#7
0
		static List<int> GetConstants(MethodDef method) {
			var list = new List<int>();

			if (method == null)
				return list;

			int index = 0;
			var instrs = method.Body.Instructions;
			var constantsReader = new EfConstantsReader(method);
			while (true) {
				int val;
				if (!constantsReader.GetNextInt32(ref index, out val))
					break;

				if (index < instrs.Count && instrs[index].OpCode.Code != Code.Ret)
					list.Add(val);
			}

			return list;
		}