use of net.runelite.asm.Method in project runelite by runelite.
the class MenuActionDeobfuscator method run.
private void run(Method method) {
if (method.getCode() == null) {
return;
}
Execution execution = new Execution(method.getClassFile().getGroup());
execution.addMethod(method);
execution.noInvoke = true;
Multimap<Integer, Comparison> comps = HashMultimap.create();
execution.addExecutionVisitor((InstructionContext ictx) -> {
Instruction i = ictx.getInstruction();
Frame frame = ictx.getFrame();
if (i instanceof If) {
// constant
InstructionContext ctx1 = ictx.getPops().get(0).getPushed();
// lvt
InstructionContext ctx2 = ictx.getPops().get(1).getPushed();
if (ctx1.getInstruction() instanceof PushConstantInstruction && ctx2.getInstruction() instanceof LVTInstruction) {
Comparison comparison = new Comparison();
comparison.cmp = i;
comparison.ldc = ctx1.getInstruction();
comparison.lvt = (LVTInstruction) ctx2.getInstruction();
comps.put(comparison.lvt.getVariableIndex(), comparison);
}
}
});
execution.run();
for (int i : comps.keySet()) {
Collection<Comparison> get = comps.get(i);
long l = get.stream().filter(c -> c.cmp.getType() == IF_ICMPGE || c.cmp.getType() == IF_ICMPGT || c.cmp.getType() == IF_ICMPLE || c.cmp.getType() == IF_ICMPLT).count();
List<Comparison> eqcmp = get.stream().filter(c -> c.cmp.getType() == IF_ICMPEQ || c.cmp.getType() == IF_ICMPNE).collect(Collectors.toList());
if (get.size() > THRESHOLD_EQ && l <= THRESHOLD_LT) {
logger.info("Sorting {} comparisons in {}", eqcmp.size(), method);
insert(method, eqcmp);
}
}
}
use of net.runelite.asm.Method in project runelite by runelite.
the class PacketTypeFinder method find.
public void find() {
for (ClassFile cf : group.getClasses()) {
for (Method method : cf.getMethods()) {
run(method.getCode());
}
}
packetType = sets.entrySet().stream().max((entry1, entry2) -> Integer.compare(entry1.getValue(), entry2.getValue())).get().getKey();
logger.info("Identified {} as packetType", packetType);
}
use of net.runelite.asm.Method in project runelite by runelite.
the class AnnotationCopier method copy.
public void copy() {
for (ClassFile cf1 : group1.getClasses()) {
ClassFile cf2 = group2.findClass(cf1.getName());
assert cf2 != null;
copy(cf1.getAnnotations(), cf2.getAnnotations());
for (Field f : cf1.getFields()) {
Field f2 = cf2.findField(f.getName(), f.getType());
assert f2 != null || f.getAnnotations() == null;
if (f2 == null)
continue;
copy(f.getAnnotations(), f2.getAnnotations());
}
for (Method m : cf1.getMethods()) {
Method m2 = cf2.findMethod(m.getName(), m.getDescriptor());
assert m2 != null || m.getAnnotations() == null;
if (m2 == null)
continue;
copy(m.getAnnotations(), m2.getAnnotations());
}
}
}
use of net.runelite.asm.Method in project runelite by runelite.
the class HandlerFinder method prepareFrame.
private void prepareFrame(Execution e, PacketHandlers handlers) {
List<Method> methods = handlers.getHandlers().stream().map(handler -> handler.getMethod()).distinct().collect(Collectors.toList());
for (Method method : methods) {
List<PacketHandler> phandlers = handlers.getHandlers().stream().filter(handler -> handler.getMethod() == method).collect(Collectors.toList());
prepareFrame(e, method, phandlers);
}
}
use of net.runelite.asm.Method in project runelite by runelite.
the class HandlerFinder method findHandlers.
public PacketHandlers findHandlers() {
// Some of the packet handlers are if (type == 1 || type == 2) func()
// and func() checks the type... so search all functions for packet handlers
List<PacketHandler> handlers = new ArrayList<>();
for (ClassFile cf : group.getClasses()) {
for (Method method : cf.getMethods()) {
if (method.getCode() == null) {
continue;
}
List<PacketHandler> h = findHandlers(method, packetType);
handlers.addAll(h);
}
}
PacketHandlers packetHandlers = new PacketHandlers(group, packetType, handlers);
removeDuplicates(packetHandlers);
prepareFrame(execution, packetHandlers);
return packetHandlers;
}
Aggregations