use of net.runelite.asm.attributes.Code in project runelite by runelite.
the class ControlFlowDeobfuscator method run.
@Override
public void run(ClassGroup group) {
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
Code code = m.getCode();
if (code == null || !code.getExceptions().getExceptions().isEmpty()) {
continue;
}
split(code);
run(code);
runJumpLabel(code);
}
}
logger.info("Inserted {} jumps, reordered {} blocks, and removed {} jumps. jump delta {}", insertedJump, placedBlocks, removedJumps, insertedJump - removedJumps);
}
use of net.runelite.asm.attributes.Code in project runelite by runelite.
the class FieldInliner method findFieldIns.
private void findFieldIns() {
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
Code code = m.getCode();
if (code == null)
continue;
for (Instruction i : code.getInstructions().getInstructions()) {
if (!(i instanceof FieldInstruction))
continue;
FieldInstruction sf = (FieldInstruction) i;
if (sf.getMyField() == null)
continue;
fieldInstructions.put(sf.getMyField(), sf);
}
}
}
}
use of net.runelite.asm.attributes.Code in project runelite by runelite.
the class IllegalStateExceptions method findInteresting.
/* find if, new, ..., athrow, replace with goto */
private void findInteresting(ClassGroup group) {
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
Code c = m.getCode();
if (c == null)
continue;
Instructions instructions = c.getInstructions();
List<Instruction> ilist = instructions.getInstructions();
for (int i = 0; i < ilist.size(); ++i) {
Instruction ins = ilist.get(i);
if (// the if
!(ins instanceof ComparisonInstruction))
continue;
Instruction ins2 = ilist.get(i + 1);
if (!(ins2 instanceof New))
continue;
New new2 = (New) ins2;
net.runelite.asm.pool.Class clazz = new2.getNewClass();
if (!clazz.getName().contains("java/lang/IllegalStateException"))
continue;
interesting.add(ins);
}
}
}
}
use of net.runelite.asm.attributes.Code in project runelite by runelite.
the class RuntimeExceptions method run.
@Override
public void run(ClassGroup group) {
boolean foundInit = false;
int i = 0;
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
Code c = m.getCode();
if (c == null)
continue;
// keeps the client error handling related methods
if (cf.getName().equals("client") && m.getName().equals("init")) {
foundInit = true;
continue;
}
for (net.runelite.asm.attributes.code.Exception e : new ArrayList<>(c.getExceptions().getExceptions())) {
if (e.getCatchType() != null && e.getCatchType().getName().equals("java/lang/RuntimeException")) {
c.getExceptions().remove(e);
++i;
}
}
}
}
if (!foundInit) {
throw new IllegalStateException("client.init(...) method seems to be missing!");
}
logger.info("Remove {} exception handlers", i);
}
use of net.runelite.asm.attributes.Code in project runelite by runelite.
the class UnusedMethods method run.
private void run(Method method) {
Code code = method.getCode();
if (code == null) {
return;
}
for (Instruction i : code.getInstructions().getInstructions()) {
if (!(i instanceof InvokeInstruction)) {
continue;
}
InvokeInstruction ii = (InvokeInstruction) i;
methods.addAll(ii.getMethods());
}
}
Aggregations