From 0e5f9c5d517a12e5aab247cc5a2d822ce7cd3a41 Mon Sep 17 00:00:00 2001 From: Martin Karing Date: Sun, 7 Mar 2021 12:42:17 +0100 Subject: [PATCH] Fixed used instruction set for trace service The trace service did use the wrong instructions in case the method is altered and the method trace is not recreated. --- Confuser.Core/Services/TraceService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Confuser.Core/Services/TraceService.cs b/Confuser.Core/Services/TraceService.cs index e43b6fbf5..bec151207 100644 --- a/Confuser.Core/Services/TraceService.cs +++ b/Confuser.Core/Services/TraceService.cs @@ -219,16 +219,16 @@ public int[] TraceArguments(Instruction instr) { int index = working.Dequeue(); while (index >= 0) { if (BeforeStackDepths[index] == targetStack) { - var currentInstr = method.Body.Instructions[index]; + var currentInstr = Instructions[index]; currentInstr.CalculateStackUsage(Method.HasReturnType, out int push, out pop); if (push == 0 && pop == 0) { // This instruction isn't doing anything to the stack. Could be a nop or some prefix. // Ignore it and move on to the next. - } else if (method.Body.Instructions[index].OpCode.Code != Code.Dup) { + } else if (Instructions[index].OpCode.Code != Code.Dup) { // It's not a duplicate instruction, this is an acceptable start point. break; } else { - var prevInstr = method.Body.Instructions[index - 1]; + var prevInstr = Instructions[index - 1]; prevInstr.CalculateStackUsage(Method.HasReturnType, out push, out _); if (push > 0) { // A duplicate instruction is an acceptable start point in case the preceeding instruction @@ -256,7 +256,7 @@ public int[] TraceArguments(Instruction instr) { return null; } - while (method.Body.Instructions[beginInstrIndex].OpCode.Code == Code.Dup) + while (Instructions[beginInstrIndex].OpCode.Code == Code.Dup) beginInstrIndex--; // Trace the index of arguments @@ -270,7 +270,7 @@ public int[] TraceArguments(Instruction instr) { int index = tuple.Item1; Stack evalStack = tuple.Item2; - while (index != instrIndex && index < method.Body.Instructions.Count) { + while (index != instrIndex && index < Instructions.Length) { Instruction currentInstr = Instructions[index]; currentInstr.CalculateStackUsage(Method.HasReturnType, out int push, out pop); if (currentInstr.OpCode.Code == Code.Dup) {