use of net.runelite.asm.attributes.code.instruction.types.DupInstruction in project runelite by runelite.
the class DupDeobfuscator method visit.
private void visit(InstructionContext i) {
if (!(i.getInstruction() instanceof DupInstruction)) {
return;
}
DupInstruction di = (DupInstruction) i.getInstruction();
// stack values being duplicated
List<StackContext> sctxs = di.getDuplicated(i);
for (StackContext sctx : sctxs) {
InstructionContext ic = sctx.getPushed();
if (ic.getInstruction() instanceof IMul) {
if (i.getInstruction() instanceof Dup) {
logger.debug("Dup instruction {} duplicates multiplication result {}", i, ic);
undup(i);
++count;
return;
}
if (i.getInstruction() instanceof Dup_X1) {
logger.debug("Dup_X1 instruction {} duplicates multiplication result {}", i, ic);
undup_x1(i);
++count;
return;
}
logger.warn("Dup instruction {} pops imul", i);
} else if (ic.getInstruction() instanceof LMul) {
if (i.getInstruction() instanceof Dup2_X1) {
logger.debug("Dup_X2 instruction {} duplicates multiplication result {}", i, ic);
undup2_x1(i);
++count;
return;
}
logger.warn("Dup instruction {} pops lmul", i);
}
}
// find if mul pops anything duplicated
sctxs = di.getCopies(i);
for (StackContext sctx : sctxs) {
for (InstructionContext ic : sctx.getPopped()) {
if (ic.getInstruction() instanceof IMul) {
if (i.getInstruction() instanceof Dup) {
logger.debug("imul {} pops dup instruction {}", ic, i);
undup(i);
++count;
return;
}
if (i.getInstruction() instanceof Dup_X1) {
logger.debug("imul {} pops dup x1 instruction {}", ic, i);
undup_x1(i);
++count;
return;
}
logger.warn("imul pops dup instruction {}", i);
} else if (ic.getInstruction() instanceof LMul) {
if (i.getInstruction() instanceof Dup2_X1) {
logger.debug("imul {} pops dup2 x1 instruction {}", ic, i);
undup2_x1(i);
++count;
return;
}
logger.warn("lmul pops dup instruction {}", i);
}
}
}
}
Aggregations