Fix problem with dup, and don't include nops
This commit is contained in:
parent
d7c61c65fe
commit
28f95d386e
|
@ -321,7 +321,7 @@ namespace de4dot.blocks.cflow {
|
|||
|
||||
var startInstr = block.Instructions[index];
|
||||
int startInstrPushes, startInstrPops;
|
||||
DotNetUtils.calculateStackUsage(startInstr.Instruction, false, out startInstrPushes, out startInstrPops);
|
||||
calculateStackUsage(startInstr.Instruction, false, out startInstrPushes, out startInstrPops);
|
||||
|
||||
if (startInstrPops == 0)
|
||||
return true;
|
||||
|
@ -335,7 +335,7 @@ namespace de4dot.blocks.cflow {
|
|||
index--;
|
||||
|
||||
int pushes, pops;
|
||||
DotNetUtils.calculateStackUsage(instr.Instruction, methodHasReturnValue, out pushes, out pops);
|
||||
calculateStackUsage(instr.Instruction, methodHasReturnValue, out pushes, out pops);
|
||||
if (pops < 0)
|
||||
return false; // eg. leave
|
||||
|
||||
|
@ -344,7 +344,7 @@ namespace de4dot.blocks.cflow {
|
|||
if (!find(ref index, addIt && !otherExpr))
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
else if (pushes != 0 || pops != 0) {
|
||||
if (addIt)
|
||||
addIndex(index);
|
||||
}
|
||||
|
@ -362,5 +362,14 @@ namespace de4dot.blocks.cflow {
|
|||
deadInstructions.Add(index);
|
||||
}
|
||||
}
|
||||
|
||||
static void calculateStackUsage(Instruction instr, bool methodHasReturnValue, out int pushes, out int pops) {
|
||||
if (instr.OpCode.Code == Code.Dup) {
|
||||
pushes = 1;
|
||||
pops = 0;
|
||||
}
|
||||
else
|
||||
DotNetUtils.calculateStackUsage(instr, false, out pushes, out pops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user