Skip to content

Commit b1c548b

Browse files
committed
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.
1 parent 8e93b47 commit b1c548b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Confuser.Core/Services/TraceService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,16 @@ public int[] TraceArguments(Instruction instr) {
219219
int index = working.Dequeue();
220220
while (index >= 0) {
221221
if (BeforeStackDepths[index] == targetStack) {
222-
var currentInstr = method.Body.Instructions[index];
222+
var currentInstr = Instructions[index];
223223
currentInstr.CalculateStackUsage(Method.HasReturnType, out int push, out pop);
224224
if (push == 0 && pop == 0) {
225225
// This instruction isn't doing anything to the stack. Could be a nop or some prefix.
226226
// Ignore it and move on to the next.
227-
} else if (method.Body.Instructions[index].OpCode.Code != Code.Dup) {
227+
} else if (Instructions[index].OpCode.Code != Code.Dup) {
228228
// It's not a duplicate instruction, this is an acceptable start point.
229229
break;
230230
} else {
231-
var prevInstr = method.Body.Instructions[index - 1];
231+
var prevInstr = Instructions[index - 1];
232232
prevInstr.CalculateStackUsage(Method.HasReturnType, out push, out _);
233233
if (push > 0) {
234234
// A duplicate instruction is an acceptable start point in case the preceeding instruction
@@ -256,7 +256,7 @@ public int[] TraceArguments(Instruction instr) {
256256
return null;
257257
}
258258

259-
while (method.Body.Instructions[beginInstrIndex].OpCode.Code == Code.Dup)
259+
while (Instructions[beginInstrIndex].OpCode.Code == Code.Dup)
260260
beginInstrIndex--;
261261

262262
// Trace the index of arguments
@@ -270,7 +270,7 @@ public int[] TraceArguments(Instruction instr) {
270270
int index = tuple.Item1;
271271
Stack<int> evalStack = tuple.Item2;
272272

273-
while (index != instrIndex && index < method.Body.Instructions.Count) {
273+
while (index != instrIndex && index < Instructions.Length) {
274274
Instruction currentInstr = Instructions[index];
275275
currentInstr.CalculateStackUsage(Method.HasReturnType, out int push, out pop);
276276
if (currentInstr.OpCode.Code == Code.Dup) {

0 commit comments

Comments
 (0)