// Token: 0x06002162 RID: 8546 RVA: 0x000931F4 File Offset: 0x000921F4 public static void Dup() { if (!StackEmulator.IsStackEmpty()) { int value = StackEmulator.stack[StackEmulator.pointer]; StackEmulator.PushValue(value); } }
// 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); }
// Token: 0x06002163 RID: 8547 RVA: 0x00093228 File Offset: 0x00092228 public static int PopValue() { int result; if (StackEmulator.IsStackEmpty()) { result = -1; } else { int num = StackEmulator.stack[StackEmulator.pointer]; StackEmulator.stack.RemoveAt(StackEmulator.pointer); StackEmulator.pointer--; result = num; } return(result); }
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); } } } } } } }
public int EmulateExpression(int ins_index, ref int local_value1, ref int local_value2) { int result = -1; for (int i = ins_index; i < this.instructions.Count; i++) { if (this.instructions[i].IsStloc()) { Local local = this.instructions[i].GetLocal(this.method.Body.Variables); if (local == this.local_variable1) { local_value1 = StackEmulator.PopValue(); } if (local == this.local_variable2) { local_value2 = StackEmulator.PopValue(); } } if (this.instructions[i].IsLdloc()) { Local local = this.instructions[i].GetLocal(this.method.Body.Variables); if (local == this.local_variable1) { StackEmulator.PushValue(local_value1); } if (local == this.local_variable2) { StackEmulator.PushValue(local_value2); } } if (this.instructions[i].IsLdcI4()) { int num = this.instructions[i].GetLdcI4Value(); StackEmulator.PushValue(num); } if (this.IsArithmetic(this.instructions[i])) { int value = StackEmulator.PopValue(); int value2 = StackEmulator.PopValue(); int value3 = this.CalculateArithmetic(value2, value, this.instructions[i]); StackEmulator.PushValue(value3); } if (this.instructions[i].OpCode == OpCodes.Neg) { int num = StackEmulator.PopValue(); num = -num; StackEmulator.PushValue(num); } if (this.instructions[i].OpCode == OpCodes.Not) { int num = StackEmulator.PopValue(); num = ~num; StackEmulator.PushValue(num); } if (this.instructions[i].OpCode == OpCodes.Dup) { StackEmulator.Dup(); } if (this.instructions[i].OpCode == OpCodes.Switch) { result = StackEmulator.PopValue(); break; } } return(result); }