Пример #1
0
        // Token: 0x06002164 RID: 8548 RVA: 0x00093278 File Offset: 0x00092278
        public static void Main2(string[] args)
        {
            StackEmulator.InitStack();
            StackEmulator.PushValue(1);
            StackEmulator.Dup();
            int num = StackEmulator.PopValue();

            StackEmulator.PushValue(2);
            int num2 = StackEmulator.PopValue();
            int num3 = StackEmulator.PopValue();

            Console.WriteLine("Hello World!");
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Пример #2
0
 public void InstructionParse2(int ins_index, int local_value1, int local_value2)
 {
     for (int i = ins_index; i < this.instructions.Count; i++)
     {
         if (!this.placeintindexes.Contains(i))
         {
             if (this.instructions[i].IsBr())
             {
                 Instruction item = this.instructions[i].Operand as Instruction;
                 if (!this.brinstructions.Contains(item) && !this.realbrinstructions.Contains(item))
                 {
                     this.realbrinstructions.Add(item);
                     int ins_index2 = this.instructions.IndexOf(item);
                     this.InstructionParse2(ins_index2, local_value1, local_value2);
                 }
                 break;
             }
             if (this.instructions[i].IsConditionalBranch() || this.instructions[i].IsLeave())
             {
                 Instruction item = this.instructions[i].Operand as Instruction;
                 if (!this.conditionalinstructions.Contains(item))
                 {
                     this.conditionalinstructions.Add(item);
                     int ins_index3 = this.instructions.IndexOf(item);
                     this.InstructionParse2(ins_index3, local_value1, local_value2);
                     if (i + 1 < this.instructions.Count)
                     {
                         int ins_index4 = i + 1;
                         this.InstructionParse2(ins_index4, local_value1, local_value2);
                         break;
                     }
                 }
             }
             else
             {
                 if (this.instructions[i].OpCode == OpCodes.Ret)
                 {
                     break;
                 }
                 if (i + 1 < this.instructions.Count && (this.instructions[i].IsLdcI4() || this.instructions[i].IsLdloc()) && (this.instructions[i + 1].IsStloc() || this.instructions[i + 1].IsLdcI4() || this.instructions[i + 1].IsLdloc() || this.instructions[i + 1].IsBr()))
                 {
                     int num = 0;
                     if (this.instructions[i].IsLdcI4())
                     {
                         num = this.instructions[i].GetLdcI4Value();
                     }
                     if (this.instructions[i].IsLdloc())
                     {
                         Local local = this.instructions[i].GetLocal(this.method.Body.Variables);
                         if (local == this.local_variable1)
                         {
                             num = local_value1;
                         }
                         if (local == this.local_variable2)
                         {
                             num = local_value2;
                         }
                     }
                     int num2 = i + 1;
                     if (this.instructions[i + 1].IsBr() && this.instructions[i + 1].Operand is Instruction)
                     {
                         num2 = this.instructions.IndexOf(this.instructions[i + 1].Operand as Instruction);
                     }
                     int value;
                     int num5;
                     if (num2 + 3 < this.instructions.Count && (this.instructions[num2].IsLdcI4() || this.instructions[num2].IsLdloc()) && (this.instructions[num2 + 1].IsLdcI4() || this.instructions[num2 + 1].IsLdloc() || this.instructions[num2 + 1].OpCode == OpCodes.Mul) && (this.instructions[num2 + 2].IsLdcI4() || this.instructions[num2 + 2].IsLdloc() || this.instructions[num2 + 2].OpCode == OpCodes.Mul) && this.instructions[num2 + 3].OpCode == OpCodes.Xor)
                     {
                         int num3 = 0;
                         if (this.instructions[num2].IsLdcI4())
                         {
                             num3 = this.instructions[num2].GetLdcI4Value();
                         }
                         if (this.instructions[num2].IsLdloc())
                         {
                             Local local = this.instructions[num2].GetLocal(this.method.Body.Variables);
                             if (local == this.local_variable1)
                             {
                                 num3 = local_value1;
                             }
                             if (local == this.local_variable2)
                             {
                                 num3 = local_value2;
                             }
                         }
                         int num4 = 0;
                         if (this.instructions[num2 + 1].OpCode == OpCodes.Mul)
                         {
                             if (this.instructions[num2 + 2].IsLdcI4())
                             {
                                 num4 = this.instructions[num2 + 2].GetLdcI4Value();
                             }
                             if (this.instructions[num2 + 2].IsLdloc())
                             {
                                 Local local = this.instructions[num2 + 2].GetLocal(this.method.Body.Variables);
                                 if (local == this.local_variable1)
                                 {
                                     num4 = local_value1;
                                 }
                                 if (local == this.local_variable2)
                                 {
                                     num4 = local_value2;
                                 }
                             }
                         }
                         else
                         {
                             if (this.instructions[num2 + 1].IsLdcI4())
                             {
                                 num4 = this.instructions[num2 + 1].GetLdcI4Value();
                             }
                             if (this.instructions[num2 + 1].IsLdloc())
                             {
                                 Local local = this.instructions[num2 + 1].GetLocal(this.method.Body.Variables);
                                 if (local == this.local_variable1)
                                 {
                                     num4 = local_value1;
                                 }
                                 if (local == this.local_variable2)
                                 {
                                     num4 = local_value2;
                                 }
                             }
                         }
                         if (this.instructions[num2 + 1].OpCode == OpCodes.Mul)
                         {
                             value = (num * num3 ^ num4);
                         }
                         else
                         {
                             value = (num4 * num3 ^ num);
                         }
                         num5 = num2 + 4;
                     }
                     else
                     {
                         value = num;
                         num5  = i + 1;
                     }
                     Instruction instruction;
                     if (this.instructions[num5].IsBr())
                     {
                         instruction = (this.instructions[num5].Operand as Instruction);
                     }
                     else
                     {
                         instruction = this.instructions[num5];
                     }
                     int num6 = -1;
                     for (int j = 0; j < this.wheretojump.Count; j++)
                     {
                         if (this.wheretojump[j] == instruction)
                         {
                             num6 = j;
                             break;
                         }
                     }
                     if (num6 != -1)
                     {
                         StackEmulator.InitStack();
                         StackEmulator.PushValue(value);
                         int           num7  = this.EmulateExpression(this.instructions.IndexOf(instruction), ref local_value1, ref local_value2);
                         Instruction[] array = this.switchinstructions[num6].Operand as Instruction[];
                         Instruction   item2 = array[num7];
                         this.placeintindexes.Add(i);
                         this.intvalues.Add(num7);
                         if (!this.instructions[i + 1].IsBr())
                         {
                             int num8  = i + 1;
                             int item3 = num5 - num8;
                             this.tobenooped_start.Add(num8);
                             this.tobenooped_len.Add(item3);
                         }
                         if (!this.brinstructions.Contains(item2))
                         {
                             this.brinstructions.Add(item2);
                             this.InstructionParse2(this.instructions.IndexOf(item2), local_value1, local_value2);
                             break;
                         }
                     }
                 }
                 else if (this.instructions[i].OpCode == OpCodes.Switch)
                 {
                     Instruction instruction2 = this.instructions[i];
                     bool        flag         = false;
                     for (int j = 0; j < this.switchinstructions.Count; j++)
                     {
                         if (this.switchinstructions[j] == this.instructions[i])
                         {
                             flag = true;
                             break;
                         }
                     }
                     if (!flag)
                     {
                         foreach (Instruction item4 in this.instructions[i].Operand as Instruction[])
                         {
                             this.InstructionParse2(this.instructions.IndexOf(item4), local_value1, local_value2);
                         }
                     }
                 }
             }
         }
     }
 }