use of net.runelite.asm.ClassFile in project runelite by runelite.
the class IsaacCipherFinder method find.
public void find() {
Method highest = null;
int count = 0;
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
Code code = m.getCode();
int i = find(m, code);
if (i > count) {
count = i;
highest = m;
}
}
}
assert highest != null;
isaacCipher = highest.getClassFile();
// find nextInt
for (Method method : isaacCipher.getMethods()) {
if (method.getDescriptor().size() == 0 && method.getDescriptor().getReturnValue().equals(Type.INT)) {
getNext = method;
}
}
logger.debug("Found cipher {}, getNext {}", isaacCipher, getNext);
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class InvokeVirtual method map.
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other) {
InvokeVirtual otherIv = (InvokeVirtual) other.getInstruction();
List<net.runelite.asm.Method> myMethods = this.getMethods(), otherMethods = otherIv.getMethods();
assert MappingExecutorUtil.isMaybeEqual(method.getType(), otherIv.method.getType());
assert myMethods.size() == otherMethods.size();
for (int i = 0; i < myMethods.size(); ++i) {
net.runelite.asm.Method m1 = myMethods.get(i), otherMethod = null;
ClassFile c1 = m1.getClassFile();
if (myMethods.size() == 1) {
otherMethod = otherMethods.get(0);
} else {
for (int j = 0; j < myMethods.size(); ++j) {
net.runelite.asm.Method m2 = otherMethods.get(j);
ClassFile c2 = m2.getClassFile();
if (MappingExecutorUtil.isMaybeEqual(c1, c2)) {
if (otherMethod != null) {
otherMethod = null;
break;
}
otherMethod = m2;
}
}
}
if (otherMethod != null) {
mapping.map(this, m1, otherMethod);
}
}
/* map arguments */
assert ctx.getPops().size() == other.getPops().size();
for (int i = 0; i < ctx.getPops().size(); ++i) {
StackContext s1 = ctx.getPops().get(i), s2 = other.getPops().get(i);
InstructionContext base1 = MappingExecutorUtil.resolve(s1.getPushed(), s1);
InstructionContext base2 = MappingExecutorUtil.resolve(s2.getPushed(), s2);
if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction) {
GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(), gf2 = (GetFieldInstruction) base2.getInstruction();
Field f1 = gf1.getMyField(), f2 = gf2.getMyField();
if (f1 != null && f2 != null) {
mapping.map(this, f1, f2);
}
}
}
/* map field that was invoked on */
StackContext object1 = ctx.getPops().get(method.getType().size()), object2 = other.getPops().get(otherIv.method.getType().size());
InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1);
InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2);
if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction) {
GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(), gf2 = (GetFieldInstruction) base2.getInstruction();
Field f1 = gf1.getMyField(), f2 = gf2.getMyField();
if (f1 != null && f2 != null) {
mapping.map(this, f1, f2);
}
}
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class Execution method getInitialMethods.
public List<Method> getInitialMethods() {
List<Method> methods = new ArrayList<>();
// required when looking up methods
group.buildClassGraph();
// lookup methods
group.lookup();
for (ClassFile cf : group.getClasses()) {
boolean extendsApplet = extendsApplet(cf);
for (Method m : cf.getMethods()) {
if (!Deob.isObfuscated(m.getName()) && !m.getName().equals("<init>")) {
if (m.getCode() == null) {
methods.add(m);
continue;
}
// I guess this method name is overriding a jre interface (init, run, ?).
methods.add(m);
logger.debug("Adding initial method {}", m);
}
if (m.getName().equals("<init>") && extendsApplet) {
methods.add(m);
}
}
}
return methods;
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class NonloadingClassWriter method getCommonSuperClass.
@Override
protected String getCommonSuperClass(String type1, String type2) {
ClassFile cf1 = group.findClass(type1), cf2 = group.findClass(type2);
if (cf1 == null && cf2 == null) {
// not mine
try {
return super.getCommonSuperClass(type1, type2);
} catch (RuntimeException ex) {
// java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sun.deploy.appcontext.AppContext
return "java/lang/Object";
}
}
if (cf1 != null && cf2 != null) {
for (ClassFile c = cf1; c != null; c = c.getParent()) for (ClassFile c2 = cf2; c2 != null; c2 = c2.getParent()) if (c == c2)
return c.getName();
return "java/lang/Object";
}
ClassFile found;
String other;
if (cf1 == null) {
found = cf2;
other = type1;
} else {
assert cf2 == null;
found = cf1;
other = type2;
}
ClassFile prev = null;
for (ClassFile c = found; c != null; c = c.getParent()) {
prev = c;
if (c.getName().equals(other))
return other;
}
return super.getCommonSuperClass(prev.getSuperName(), other);
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class VirtualMethods method findMethodUp.
private static void findMethodUp(List<Method> methods, Set<ClassFile> visited, ClassFile cf, String name, Signature type) {
if (cf == null || visited.contains(cf))
return;
// can do diamond inheritance with interfaces
visited.add(cf);
Method m = cf.findMethod(name, type);
if (m != null && !m.isStatic())
methods.add(m);
for (ClassFile child : cf.getChildren()) findMethodUp(methods, visited, child, name, type);
}
Aggregations