use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class MultiplyOneDeobfuscator method run.
@Override
public void run(ClassGroup group) {
Execution e = new Execution(group);
e.addMethodContextVisitor(i -> visit(i));
e.populateInitialMethods();
e.run();
logger.info("Removed " + count + " 1 multiplications");
}
use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class UnreachedCode method run.
@Override
public void run(ClassGroup group) {
group.buildClassGraph();
execution = new Execution(group);
execution.populateInitialMethods();
execution.run();
int count = 0;
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
if (m.getCode() == null)
continue;
count += removeUnused(m);
}
}
logger.info("Removed {} unused instructions", count);
}
use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class UnusedParameters method removeParameter.
public void removeParameter(ClassGroup group, List<Method> methods, Signature signature, Execution execution, int paramIndex, int lvtIndex) {
int slots = signature.getTypeOfArg(paramIndex).getSize();
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
Code c = m.getCode();
if (c == null) {
continue;
}
for (Instruction i : new ArrayList<>(c.getInstructions().getInstructions())) {
if (!(i instanceof InvokeInstruction)) {
continue;
}
InvokeInstruction ii = (InvokeInstruction) i;
if (!ii.getMethods().stream().anyMatch(me -> methods.contains(me))) {
continue;
}
// remove parameter from instruction
ii.removeParameter(paramIndex);
Collection<InstructionContext> ics = invokes.get(i);
assert ics != null;
if (ics != null) {
for (InstructionContext ins : ics) {
// index from top of stack of parameter. 0 is the last parameter
int pops = signature.size() - paramIndex - 1;
StackContext sctx = ins.getPops().get(pops);
if (sctx.getPushed().getInstruction().getInstructions() == null) {
continue;
}
// remove parameter from stack
ins.removeStack(pops);
}
}
}
}
}
for (Method method : methods) {
if (method.getCode() != null) // adjust lvt indexes to get rid of idx in the method
{
for (Instruction ins : method.getCode().getInstructions().getInstructions()) {
if (ins instanceof LVTInstruction) {
LVTInstruction lins = (LVTInstruction) ins;
int i = lins.getVariableIndex();
// current unused variable detection just looks for no accesses
assert i != lvtIndex;
// reassign
if (i > lvtIndex) {
assert i > 0;
assert i >= lvtIndex + slots;
Instruction newIns = lins.setVariableIndex(i - slots);
assert ins == newIns;
}
}
}
}
}
for (Method method : methods) {
method.getDescriptor().remove(paramIndex);
}
}
use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class UnusedParameters method run.
@Override
public void run(ClassGroup group) {
int i;
int pnum = 1;
do {
group.buildClassGraph();
invokes.clear();
this.buildUnused(group);
Execution execution = new Execution(group);
execution.addExecutionVisitor(ictx -> visit(ictx));
execution.populateInitialMethods();
execution.run();
i = this.processUnused(execution, group);
count += i;
break;
} while (i > 0);
logger.info("Removed {} unused parameters", count);
}
use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class DupDeobfuscator method run.
@Override
public void run(ClassGroup group) {
Execution e = new Execution(group);
e.addMethodContextVisitor(m -> visit(m));
e.populateInitialMethods();
e.run();
logger.info("Replaced {} dup instructions", count);
}
Aggregations