// 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 findInts(out bool initializedAll)
        {
            int index = findInitIntsIndex(stringMethod, out initializedAll);

            if (index < 0)
            {
                return(false);
            }

            i2 = 0;
            bool returnValue = false;
            var  instrs      = stringMethod.Body.Instructions;

            for (int i = index; i < instrs.Count - 2; i++)
            {
                var instr = instrs[i];

                if (instr.OpCode.Code == Code.Ldsfld &&
                    instrs[i + 1].OpCode.Code == Code.Ldc_I4 &&
                    (int)instrs[i + 1].Operand == 268435314)
                {
                    break;
                }
                if (instr.OpCode.Code != Code.Call && instr.OpCode.FlowControl != FlowControl.Next)
                {
                    break;
                }

                if (!stringMethodConsts.isLoadConstantInt32(instr))
                {
                    continue;
                }

                int tmp;
                if (!stringMethodConsts.getNextInt32(ref i, out tmp))
                {
                    continue;
                }
                if ((instrs[i - 1].OpCode.Code == Code.Xor && DotNetUtils.isStloc(instrs[i])) ||
                    (instrs[i].OpCode.Code == Code.Xor && DotNetUtils.isStloc(instrs[i + 1])) ||
                    DotNetUtils.isLdloc(instrs[i]))
                {
                    i2         ^= tmp;
                    returnValue = true;
                }
                i--;
            }

            return(returnValue);
        }
Пример #3
0
        bool findIntsCctor(MethodDefinition 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 && DotNetUtils.isLdloc(instrs[index]))
                {
                    tmp3 = tmp4;
                }
            }

            i1 = tmp1 ^ tmp2 ^ tmp3;
            return(true);
        }
Пример #4
0
        static List <int> getConstants(MethodDefinition 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);
        }
Пример #5
0
        // Compact Framework doesn't have StackFrame
        bool findIntsCctor2(MethodDefinition 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
        static List<int> getConstants(MethodDefinition 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;
        }
Пример #7
0
        // Compact Framework doesn't have StackFrame
        bool findIntsCctor2(MethodDefinition 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;
        }
Пример #8
0
        bool findIntsCctor(MethodDefinition 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 && DotNetUtils.isLdloc(instrs[index]))
                    tmp3 = tmp4;
            }

            i1 = tmp1 ^ tmp2 ^ tmp3;
            return true;
        }