Skip to content

Commit

Permalink
Fixed used instruction set for trace service
Browse files Browse the repository at this point in the history
The trace service did use the wrong instructions in case the method is altered and the method trace is not recreated.
  • Loading branch information
mkaring committed Mar 7, 2021
1 parent 8e93b47 commit 0e5f9c5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Confuser.Core/Services/TraceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -270,7 +270,7 @@ public int[] TraceArguments(Instruction instr) {
int index = tuple.Item1;
Stack<int> 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) {
Expand Down

0 comments on commit 0e5f9c5

Please sign in to comment.