use of net.runelite.asm.Method in project runelite by runelite.
the class ModArith method insertGetterSetterMuls.
private void insertGetterSetterMuls(Encryption encr) {
// before setfield insert imul * getter
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
Code code = m.getCode();
if (code == null) {
continue;
}
Instructions ins = code.getInstructions();
List<Instruction> ilist = ins.getInstructions();
for (int i = 0; i < ilist.size(); ++i) {
Instruction in = ilist.get(i);
if (in instanceof SetFieldInstruction) {
SetFieldInstruction sfi = (SetFieldInstruction) in;
Field f = sfi.getMyField();
if (f == null) {
continue;
}
Pair p = encr.getField(f.getPoolField());
if (p == null) {
continue;
}
// insert imul
if (p.getType() == Integer.class) {
ilist.add(i++, new LDC(ins, (int) p.getter));
ilist.add(i++, new IMul(ins));
} else if (p.getType() == Long.class) {
ilist.add(i++, new LDC(ins, (long) p.getter));
ilist.add(i++, new LMul(ins));
} else {
throw new IllegalStateException();
}
} else if (in instanceof GetFieldInstruction) {
GetFieldInstruction sfi = (GetFieldInstruction) in;
Field f = sfi.getMyField();
if (f == null) {
continue;
}
Pair p = encr.getField(f.getPoolField());
if (p == null) {
continue;
}
// imul
if (p.getType() == Integer.class) {
ilist.add(++i, new LDC(ins, (int) p.setter));
ilist.add(++i, new IMul(ins));
} else if (p.getType() == Long.class) {
ilist.add(++i, new LDC(ins, (long) p.setter));
ilist.add(++i, new LMul(ins));
} else {
throw new IllegalStateException();
}
}
}
}
}
}
use of net.runelite.asm.Method 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.Method 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.Method 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.Method 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);
}
Aggregations