Rewrite rename unique to work much different. Seems to run ok.
This commit is contained in:
@@ -167,6 +167,11 @@ public class ClassFile
|
|||||||
return fields.findField(name);
|
return fields.findField(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class getPoolClass()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public Field findFieldDeep(NameAndType nat)
|
public Field findFieldDeep(NameAndType nat)
|
||||||
{
|
{
|
||||||
Field f = fields.findField(nat);
|
Field f = fields.findField(nat);
|
||||||
@@ -201,7 +206,7 @@ public class ClassFile
|
|||||||
|
|
||||||
ClassFile parent = getParent();
|
ClassFile parent = getParent();
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
return parent.findMethodDeep(nat);
|
return parent.findMethodDeepStatic(nat);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,40 +39,40 @@ public class Deob
|
|||||||
|
|
||||||
ClassGroup group = loadJar(args[0]);
|
ClassGroup group = loadJar(args[0]);
|
||||||
|
|
||||||
//run(group, new RenameUnique());
|
run(group, new RenameUnique());
|
||||||
|
|
||||||
|
// remove except RuntimeException
|
||||||
|
run(group, new RuntimeExceptions());
|
||||||
|
|
||||||
|
// remove unused methods
|
||||||
|
run(group, new UnusedMethods());
|
||||||
|
|
||||||
|
run(group, new UnreachedCode());
|
||||||
|
|
||||||
|
// remove illegal state exceptions, frees up some parameters
|
||||||
|
run(group, new IllegalStateExceptions());
|
||||||
|
|
||||||
|
// remove constant logically dead parameters
|
||||||
|
run(group, new ConstantParameter());
|
||||||
|
|
||||||
|
// remove unhit blocks
|
||||||
|
run(group, new UnreachedCode());
|
||||||
|
|
||||||
// // remove except RuntimeException
|
|
||||||
// run(group, new RuntimeExceptions());
|
|
||||||
//
|
|
||||||
// // remove unused methods
|
|
||||||
// run(group, new UnusedMethods());
|
|
||||||
//
|
|
||||||
// run(group, new UnreachedCode());
|
|
||||||
//
|
|
||||||
// // remove illegal state exceptions, frees up some parameters
|
|
||||||
// run(group, new IllegalStateExceptions());
|
|
||||||
//
|
|
||||||
// // remove constant logically dead parameters
|
|
||||||
// run(group, new ConstantParameter());
|
|
||||||
//
|
|
||||||
// // remove unhit blocks
|
|
||||||
// run(group, new UnreachedCode());
|
|
||||||
//
|
|
||||||
// // remove unused parameters
|
// // remove unused parameters
|
||||||
// run(group, new UnusedParameters());
|
// run(group, new UnusedParameters());
|
||||||
//
|
//
|
||||||
// // remove jump obfuscation
|
// // remove jump obfuscation
|
||||||
// //new Jumps().run(group);
|
// //new Jumps().run(group);
|
||||||
//
|
//
|
||||||
// // remove unused fields
|
// remove unused fields
|
||||||
// run(group, new UnusedFields());
|
run(group, new UnusedFields());
|
||||||
//
|
|
||||||
// // remove unused methods, again?
|
// remove unused methods, again?
|
||||||
// run(group, new UnusedMethods());
|
run(group, new UnusedMethods());
|
||||||
//
|
//
|
||||||
// run(group, new MethodInliner());
|
// run(group, new MethodInliner());
|
||||||
//
|
//
|
||||||
// run(group, new MethodMover());
|
// //run(group, new MethodMover());
|
||||||
//
|
//
|
||||||
// run(group, new FieldInliner());
|
// run(group, new FieldInliner());
|
||||||
//
|
//
|
||||||
@@ -82,27 +82,27 @@ public class Deob
|
|||||||
//
|
//
|
||||||
// run(group, new UnusedClass());
|
// run(group, new UnusedClass());
|
||||||
|
|
||||||
ModArith mod = new ModArith();
|
// ModArith mod = new ModArith();
|
||||||
mod.run(group);
|
// mod.run(group);
|
||||||
|
//
|
||||||
int last = -1, cur;
|
// int last = -1, cur;
|
||||||
while ((cur = mod.runOnce()) > 0)
|
// while ((cur = mod.runOnce()) > 0)
|
||||||
{
|
// {
|
||||||
new MultiplicationDeobfuscator().run(group);
|
// new MultiplicationDeobfuscator().run(group);
|
||||||
|
//
|
||||||
new MultiplyOneDeobfuscator().run(group);
|
// new MultiplyOneDeobfuscator().run(group);
|
||||||
|
//
|
||||||
new MultiplyZeroDeobfuscator().run(group);
|
// new MultiplyZeroDeobfuscator().run(group);
|
||||||
|
//
|
||||||
if (last == cur)
|
// if (last == cur)
|
||||||
{
|
// {
|
||||||
System.out.println("break");
|
// System.out.println("break");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
last = cur;
|
// last = cur;
|
||||||
//break;
|
// //break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
saveJar(group, args[1]);
|
saveJar(group, args[1]);
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,15 @@ public class Method
|
|||||||
{
|
{
|
||||||
return new net.runelite.deob.pool.Method(
|
return new net.runelite.deob.pool.Method(
|
||||||
new net.runelite.deob.pool.Class(this.getMethods().getClassFile().getName()),
|
new net.runelite.deob.pool.Class(this.getMethods().getClassFile().getName()),
|
||||||
new NameAndType(this.getName(), this.getDescriptor())
|
new NameAndType(this.getName(), new Signature(this.getDescriptor()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public net.runelite.deob.pool.InterfaceMethod getPoolInterfaceMethod()
|
||||||
|
{
|
||||||
|
return new net.runelite.deob.pool.InterfaceMethod(
|
||||||
|
new net.runelite.deob.pool.Class(this.getMethods().getClassFile().getName()),
|
||||||
|
new NameAndType(this.getName(), new Signature(this.getDescriptor()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package net.runelite.deob.attributes.code;
|
package net.runelite.deob.attributes.code;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import net.runelite.deob.ClassFile;
|
|
||||||
import net.runelite.deob.ConstantPool;
|
import net.runelite.deob.ConstantPool;
|
||||||
import net.runelite.deob.Field;
|
|
||||||
import net.runelite.deob.Method;
|
|
||||||
import net.runelite.deob.block.Block;
|
import net.runelite.deob.block.Block;
|
||||||
import net.runelite.deob.execution.Frame;
|
import net.runelite.deob.execution.Frame;
|
||||||
|
|
||||||
@@ -12,6 +9,7 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public abstract class Instruction
|
public abstract class Instruction
|
||||||
{
|
{
|
||||||
@@ -222,15 +220,12 @@ public abstract class Instruction
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renameClass(ClassFile cf, String name)
|
// look up symbols from pool
|
||||||
|
public void lookup2()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renameField(Field f, net.runelite.deob.pool.Field name)
|
public void regeneratePool()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renameMethod(Method oldMethod, net.runelite.deob.pool.Method newMethod)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class Instructions
|
public class Instructions
|
||||||
{
|
{
|
||||||
@@ -253,22 +254,16 @@ public class Instructions
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup()
|
||||||
{
|
{
|
||||||
for (Instruction i : instructions)
|
for (Instruction i : instructions)
|
||||||
i.renameClass(cf, name);
|
i.lookup2();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renameField(Field f, net.runelite.deob.pool.Field newField)
|
public void regeneratePool()
|
||||||
{
|
{
|
||||||
for (Instruction i : instructions)
|
for (Instruction i : instructions)
|
||||||
i.renameField(f, newField);
|
i.regeneratePool();
|
||||||
}
|
|
||||||
|
|
||||||
public void renameMethod(Method oldMethod, net.runelite.deob.pool.Method newMethod)
|
|
||||||
{
|
|
||||||
for (Instruction i : instructions)
|
|
||||||
i.renameMethod(oldMethod, newMethod);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(Instruction oldi, Instruction newi)
|
public void replace(Instruction oldi, Instruction newi)
|
||||||
|
|||||||
@@ -14,10 +14,14 @@ import net.runelite.deob.pool.Class;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class ANewArray extends Instruction
|
public class ANewArray extends Instruction
|
||||||
{
|
{
|
||||||
private Class clazz;
|
private Class clazz;
|
||||||
|
private ClassFile myClass;
|
||||||
|
private int dimensions;
|
||||||
|
|
||||||
public ANewArray(Instructions instructions, InstructionType type, int pc)
|
public ANewArray(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -59,10 +63,27 @@ public class ANewArray extends Instruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
net.runelite.deob.signature.Type t = new net.runelite.deob.signature.Type(clazz.getName());
|
net.runelite.deob.signature.Type t = new net.runelite.deob.signature.Type(clazz.getName());
|
||||||
if (t.getType().equals("L" + cf.getName() + ";") || t.getType().equals(cf.getName()))
|
String name = t.getType();
|
||||||
clazz = new Class(name, t.getArrayDims());
|
if (name.startsWith("L") && name.endsWith(";"))
|
||||||
|
name = name.substring(1, name.length() - 1);
|
||||||
|
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
||||||
|
myClass = group.findClass(name);
|
||||||
|
dimensions = t.getArrayDims();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void regeneratePool()
|
||||||
|
{
|
||||||
|
if (myClass != null)
|
||||||
|
{
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (int i = 0; i < this.dimensions; ++i)
|
||||||
|
sb.append('[');
|
||||||
|
sb.append("L" + myClass.getName() + ";");
|
||||||
|
clazz = new Class(sb.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,13 @@ import net.runelite.deob.pool.Class;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class CheckCast extends Instruction
|
public class CheckCast extends Instruction
|
||||||
{
|
{
|
||||||
private Class clazz;
|
private Class clazz;
|
||||||
|
private ClassFile myClass;
|
||||||
|
|
||||||
public CheckCast(Instructions instructions, InstructionType type, int pc)
|
public CheckCast(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -57,9 +60,16 @@ public class CheckCast extends Instruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (clazz.getName().equals(cf.getName()))
|
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
||||||
clazz = new Class(name);
|
myClass = group.findClass(clazz.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void regeneratePool()
|
||||||
|
{
|
||||||
|
if (myClass != null)
|
||||||
|
clazz = myClass.getPoolClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,15 @@ import net.runelite.deob.pool.NameAndType;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
import net.runelite.deob.deobfuscators.arithmetic.Encryption;
|
import net.runelite.deob.deobfuscators.arithmetic.Encryption;
|
||||||
import net.runelite.deob.deobfuscators.arithmetic.Pair;
|
import net.runelite.deob.deobfuscators.arithmetic.Pair;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class GetField extends Instruction implements GetFieldInstruction
|
public class GetField extends Instruction implements GetFieldInstruction
|
||||||
{
|
{
|
||||||
private Field field;
|
private Field field;
|
||||||
|
private net.runelite.deob.Field myField;
|
||||||
|
|
||||||
public GetField(Instructions instructions, InstructionType type, int pc)
|
public GetField(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -81,21 +84,15 @@ public class GetField extends Instruction implements GetFieldInstruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (field.getClassEntry().getName().equals(cf.getName()))
|
myField = getMyField();
|
||||||
field = new Field(new Class(name), field.getNameAndType());
|
|
||||||
|
|
||||||
if (field.getNameAndType().getDescriptorType().getType().equals("L" + cf.getName() + ";"))
|
|
||||||
field = new Field(field.getClassEntry(), new NameAndType(field.getNameAndType().getName(), new net.runelite.deob.signature.Type("L" + name + ";", field.getNameAndType().getDescriptorType().getArrayDims())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameField(net.runelite.deob.Field f, Field newField)
|
public void regeneratePool()
|
||||||
{
|
{
|
||||||
net.runelite.deob.Field f2 = getMyField();
|
if (myField != null)
|
||||||
|
field = myField.getPoolField();
|
||||||
if (f2 == f)
|
|
||||||
field = newField;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,15 @@ import net.runelite.deob.pool.NameAndType;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
import net.runelite.deob.deobfuscators.arithmetic.Encryption;
|
import net.runelite.deob.deobfuscators.arithmetic.Encryption;
|
||||||
import net.runelite.deob.deobfuscators.arithmetic.Pair;
|
import net.runelite.deob.deobfuscators.arithmetic.Pair;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class GetStatic extends Instruction implements GetFieldInstruction
|
public class GetStatic extends Instruction implements GetFieldInstruction
|
||||||
{
|
{
|
||||||
private Field field;
|
private Field field;
|
||||||
|
private net.runelite.deob.Field myField;
|
||||||
|
|
||||||
public GetStatic(Instructions instructions, InstructionType type, int pc)
|
public GetStatic(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -85,23 +88,15 @@ public class GetStatic extends Instruction implements GetFieldInstruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (field.getClassEntry().getName().equals(cf.getName()))
|
myField = this.getMyField();
|
||||||
field = new Field(new Class(name), field.getNameAndType());
|
|
||||||
|
|
||||||
if (field.getNameAndType().getDescriptorType().getType().equals("L" + cf.getName() + ";"))
|
|
||||||
field = new Field(field.getClassEntry(), new NameAndType(field.getNameAndType().getName(), new net.runelite.deob.signature.Type("L" + name + ";", field.getNameAndType().getDescriptorType().getArrayDims())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameField(net.runelite.deob.Field f, Field newField)
|
public void regeneratePool()
|
||||||
{
|
{
|
||||||
net.runelite.deob.Field f2 = getMyField();
|
if (myField != null)
|
||||||
|
field = myField.getPoolField();
|
||||||
if (f2 == f)
|
|
||||||
{
|
|
||||||
field = newField;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,13 @@ import net.runelite.deob.pool.Class;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class InstanceOf extends Instruction
|
public class InstanceOf extends Instruction
|
||||||
{
|
{
|
||||||
private Class clazz;
|
private Class clazz;
|
||||||
|
private ClassFile myClass;
|
||||||
|
|
||||||
public InstanceOf(Instructions instructions, InstructionType type, int pc)
|
public InstanceOf(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -55,9 +58,16 @@ public class InstanceOf extends Instruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (clazz.getName().equals(cf.getName()))
|
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
||||||
clazz = new Class(name);
|
myClass = group.findClass(clazz.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void regeneratePool()
|
||||||
|
{
|
||||||
|
if (myClass != null)
|
||||||
|
clazz = myClass.getPoolClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,13 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.deob.execution.Execution;
|
import net.runelite.deob.execution.Execution;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class InvokeInterface extends Instruction implements InvokeInstruction
|
public class InvokeInterface extends Instruction implements InvokeInstruction
|
||||||
{
|
{
|
||||||
private InterfaceMethod method;
|
private InterfaceMethod method;
|
||||||
private int count;
|
private int count;
|
||||||
|
private List<net.runelite.deob.Method> myMethods;
|
||||||
|
|
||||||
public InvokeInterface(Instructions instructions, InstructionType type, int pc)
|
public InvokeInterface(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -142,30 +144,15 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (method.getClassEntry().getName().equals(cf.getName()))
|
myMethods = this.getMethods();
|
||||||
method = new InterfaceMethod(new Class(name), method.getNameAndType());
|
|
||||||
|
|
||||||
Signature signature = method.getNameAndType().getDescriptor();
|
|
||||||
for (int i = 0; i < signature.size(); ++i)
|
|
||||||
{
|
|
||||||
net.runelite.deob.signature.Type type = signature.getTypeOfArg(i);
|
|
||||||
|
|
||||||
if (type.getType().equals("L" + cf.getName() + ";"))
|
|
||||||
signature.setTypeOfArg(i, new net.runelite.deob.signature.Type("L" + name + ";", type.getArrayDims()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename return type
|
|
||||||
if (signature.getReturnValue().getType().equals("L" + cf.getName() + ";"))
|
|
||||||
signature.setTypeOfReturnValue(new net.runelite.deob.signature.Type("L" + name + ";", signature.getReturnValue().getArrayDims()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameMethod(net.runelite.deob.Method m, Method newMethod)
|
public void regeneratePool()
|
||||||
{
|
{
|
||||||
for (net.runelite.deob.Method m2 : getMethods())
|
if (!myMethods.isEmpty())
|
||||||
if (m2.equals(m))
|
method = myMethods.get(0).getPoolInterfaceMethod(); // is this right?
|
||||||
method = new InterfaceMethod(newMethod.getClassEntry(), newMethod.getNameAndType());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,13 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.deob.execution.Execution;
|
import net.runelite.deob.execution.Execution;
|
||||||
|
import net.runelite.deob.pool.InterfaceMethod;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class InvokeSpecial extends Instruction implements InvokeInstruction
|
public class InvokeSpecial extends Instruction implements InvokeInstruction
|
||||||
{
|
{
|
||||||
private Method method;
|
private Method method;
|
||||||
|
private List<net.runelite.deob.Method> myMethods;
|
||||||
|
|
||||||
public InvokeSpecial(Instructions instructions, InstructionType type, int pc)
|
public InvokeSpecial(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -134,30 +137,15 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (method.getClassEntry().getName().equals(cf.getName()))
|
myMethods = this.getMethods();
|
||||||
method = new Method(new Class(name), method.getNameAndType());
|
|
||||||
|
|
||||||
Signature signature = method.getNameAndType().getDescriptor();
|
|
||||||
for (int i = 0; i < signature.size(); ++i)
|
|
||||||
{
|
|
||||||
net.runelite.deob.signature.Type type = signature.getTypeOfArg(i);
|
|
||||||
|
|
||||||
if (type.getType().equals("L" + cf.getName() + ";"))
|
|
||||||
signature.setTypeOfArg(i, new net.runelite.deob.signature.Type("L" + name + ";", type.getArrayDims()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename return type
|
|
||||||
if (signature.getReturnValue().getType().equals("L" + cf.getName() + ";"))
|
|
||||||
signature.setTypeOfReturnValue(new net.runelite.deob.signature.Type("L" + name + ";", signature.getReturnValue().getArrayDims()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameMethod(net.runelite.deob.Method m, Method newMethod)
|
public void regeneratePool()
|
||||||
{
|
{
|
||||||
for (net.runelite.deob.Method m2 : getMethods())
|
if (!myMethods.isEmpty())
|
||||||
if (m2.equals(m))
|
method = myMethods.get(0).getPoolMethod();
|
||||||
method = newMethod;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.deob.execution.Execution;
|
import net.runelite.deob.execution.Execution;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class InvokeStatic extends Instruction implements InvokeInstruction
|
public class InvokeStatic extends Instruction implements InvokeInstruction
|
||||||
{
|
{
|
||||||
private Method method;
|
private Method method;
|
||||||
|
private List<net.runelite.deob.Method> myMethods;
|
||||||
|
|
||||||
public InvokeStatic(Instructions instructions, InstructionType type, int pc)
|
public InvokeStatic(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -138,37 +140,15 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (method.getClassEntry().getName().equals(cf.getName()))
|
myMethods = this.getMethods();
|
||||||
method = new Method(new Class(name), method.getNameAndType());
|
|
||||||
|
|
||||||
Signature signature = method.getNameAndType().getDescriptor();
|
|
||||||
for (int i = 0; i < signature.size(); ++i)
|
|
||||||
{
|
|
||||||
net.runelite.deob.signature.Type type = signature.getTypeOfArg(i);
|
|
||||||
|
|
||||||
if (type.getType().equals("L" + cf.getName() + ";"))
|
|
||||||
signature.setTypeOfArg(i, new net.runelite.deob.signature.Type("L" + name + ";", type.getArrayDims()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename return type
|
|
||||||
if (signature.getReturnValue().getType().equals("L" + cf.getName() + ";"))
|
|
||||||
signature.setTypeOfReturnValue(new net.runelite.deob.signature.Type("L" + name + ";", signature.getReturnValue().getArrayDims()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameMethod(net.runelite.deob.Method m, Method newMethod)
|
public void regeneratePool()
|
||||||
{
|
{
|
||||||
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
if (!myMethods.isEmpty())
|
||||||
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
|
method = myMethods.get(0).getPoolMethod();
|
||||||
if (otherClass == null)
|
|
||||||
return; // not our class
|
|
||||||
|
|
||||||
net.runelite.deob.Method other = otherClass.findMethodDeepStatic(method.getNameAndType());
|
|
||||||
assert other.isStatic();
|
|
||||||
|
|
||||||
if (other.equals(m))
|
|
||||||
method = newMethod;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.deob.execution.Execution;
|
import net.runelite.deob.execution.Execution;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class InvokeVirtual extends Instruction implements InvokeInstruction
|
public class InvokeVirtual extends Instruction implements InvokeInstruction
|
||||||
{
|
{
|
||||||
private Method method;
|
private Method method;
|
||||||
|
private List<net.runelite.deob.Method> myMethods;
|
||||||
|
|
||||||
public InvokeVirtual(Instructions instructions, InstructionType type, int pc)
|
public InvokeVirtual(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -139,30 +141,15 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (method.getClassEntry().getName().equals(cf.getName()))
|
myMethods = this.getMethods();
|
||||||
method = new Method(new Class(name), method.getNameAndType());
|
|
||||||
|
|
||||||
Signature signature = method.getNameAndType().getDescriptor();
|
|
||||||
for (int i = 0; i < signature.size(); ++i)
|
|
||||||
{
|
|
||||||
net.runelite.deob.signature.Type type = signature.getTypeOfArg(i);
|
|
||||||
|
|
||||||
if (type.getType().equals("L" + cf.getName() + ";"))
|
|
||||||
signature.setTypeOfArg(i, new net.runelite.deob.signature.Type("L" + name + ";", type.getArrayDims()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename return type
|
|
||||||
if (signature.getReturnValue().getType().equals("L" + cf.getName() + ";"))
|
|
||||||
signature.setTypeOfReturnValue(new net.runelite.deob.signature.Type("L" + name + ";", signature.getReturnValue().getArrayDims()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameMethod(net.runelite.deob.Method m, Method newMethod)
|
public void regeneratePool()
|
||||||
{
|
{
|
||||||
for (net.runelite.deob.Method m2 : getMethods())
|
if (!myMethods.isEmpty())
|
||||||
if (m2.equals(m))
|
method = myMethods.get(0).getPoolMethod(); // is this right?
|
||||||
method = newMethod;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,14 @@ import net.runelite.deob.pool.Class;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class MultiANewArray extends Instruction
|
public class MultiANewArray extends Instruction
|
||||||
{
|
{
|
||||||
private Class clazz;
|
private Class clazz;
|
||||||
private int dimensions;
|
private int dimensions;
|
||||||
|
private ClassFile myClass;
|
||||||
|
|
||||||
public MultiANewArray(Instructions instructions, InstructionType type, int pc) throws IOException
|
public MultiANewArray(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||||
{
|
{
|
||||||
@@ -63,11 +66,26 @@ public class MultiANewArray extends Instruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
// class is an array type, ugh.
|
|
||||||
net.runelite.deob.signature.Type t = new net.runelite.deob.signature.Type(clazz.getName());
|
net.runelite.deob.signature.Type t = new net.runelite.deob.signature.Type(clazz.getName());
|
||||||
if (t.getType().equals("L" + cf.getName() + ";"))
|
String name = t.getType();
|
||||||
clazz = new Class("L" + name + ";", t.getArrayDims());
|
if (name.startsWith("L") && name.endsWith(";"))
|
||||||
|
name = name.substring(1, name.length() - 1);
|
||||||
|
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
||||||
|
myClass = group.findClass(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void regeneratePool()
|
||||||
|
{
|
||||||
|
if (myClass != null)
|
||||||
|
{
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (int i = 0; i < this.dimensions; ++i)
|
||||||
|
sb.append('[');
|
||||||
|
sb.append("L" + myClass.getName() + ";");
|
||||||
|
clazz = new Class(sb.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,13 @@ import net.runelite.deob.pool.Class;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class New extends Instruction
|
public class New extends Instruction
|
||||||
{
|
{
|
||||||
private Class clazz;
|
private Class clazz;
|
||||||
|
private ClassFile myClass;
|
||||||
|
|
||||||
public New(Instructions instructions, InstructionType type, int pc)
|
public New(Instructions instructions, InstructionType type, int pc)
|
||||||
{
|
{
|
||||||
@@ -58,9 +61,16 @@ public class New extends Instruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (clazz.getName().equals(cf.getName()))
|
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
|
||||||
clazz = new Class(name);
|
myClass = group.findClass(clazz.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void regeneratePool()
|
||||||
|
{
|
||||||
|
if (myClass != null)
|
||||||
|
clazz = myClass.getPoolClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,15 @@ import net.runelite.deob.pool.NameAndType;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
import net.runelite.deob.deobfuscators.arithmetic.Encryption;
|
import net.runelite.deob.deobfuscators.arithmetic.Encryption;
|
||||||
import net.runelite.deob.deobfuscators.arithmetic.Pair;
|
import net.runelite.deob.deobfuscators.arithmetic.Pair;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class PutField extends Instruction implements SetFieldInstruction
|
public class PutField extends Instruction implements SetFieldInstruction
|
||||||
{
|
{
|
||||||
private Field field;
|
private Field field;
|
||||||
|
private net.runelite.deob.Field myField;
|
||||||
|
|
||||||
public PutField(Instructions instructions, InstructionType type, int pc) throws IOException
|
public PutField(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||||
{
|
{
|
||||||
@@ -76,30 +79,15 @@ public class PutField extends Instruction implements SetFieldInstruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (field.getClassEntry().getName().equals(cf.getName()))
|
myField = getMyField();
|
||||||
field = new Field(new Class(name), field.getNameAndType());
|
|
||||||
|
|
||||||
if (field.getNameAndType().getDescriptorType().getType().equals("L" + cf.getName() + ";"))
|
|
||||||
field = new Field(field.getClassEntry(), new NameAndType(field.getNameAndType().getName(), new net.runelite.deob.signature.Type("L" + name + ";", field.getNameAndType().getDescriptorType().getArrayDims())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameField(net.runelite.deob.Field f, Field newField)
|
public void regeneratePool()
|
||||||
{
|
{
|
||||||
Class clazz = field.getClassEntry();
|
if (myField != null)
|
||||||
NameAndType nat = field.getNameAndType();
|
field = myField.getPoolField();
|
||||||
|
|
||||||
ClassFile cf = this.getInstructions().getCode().getAttributes().getClassFile().getGroup().findClass(clazz.getName());
|
|
||||||
if (cf == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
net.runelite.deob.Field f2 = cf.findFieldDeep(nat);
|
|
||||||
|
|
||||||
if (f2 == f)
|
|
||||||
{
|
|
||||||
field = newField;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,13 @@ import net.runelite.deob.pool.NameAndType;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.ClassGroup;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class PutStatic extends Instruction implements SetFieldInstruction
|
public class PutStatic extends Instruction implements SetFieldInstruction
|
||||||
{
|
{
|
||||||
private Field field;
|
private Field field;
|
||||||
|
private net.runelite.deob.Field myField;
|
||||||
|
|
||||||
public PutStatic(Instructions instructions, InstructionType type, int pc) throws IOException
|
public PutStatic(Instructions instructions, InstructionType type, int pc) throws IOException
|
||||||
{
|
{
|
||||||
@@ -73,30 +76,15 @@ public class PutStatic extends Instruction implements SetFieldInstruction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameClass(ClassFile cf, String name)
|
public void lookup2()
|
||||||
{
|
{
|
||||||
if (field.getClassEntry().getName().equals(cf.getName()))
|
myField = getMyField();
|
||||||
field = new Field(new Class(name), field.getNameAndType());
|
|
||||||
|
|
||||||
if (field.getNameAndType().getDescriptorType().getType().equals("L" + cf.getName() + ";"))
|
|
||||||
field = new Field(field.getClassEntry(), new NameAndType(field.getNameAndType().getName(), new net.runelite.deob.signature.Type("L" + name + ";", field.getNameAndType().getDescriptorType().getArrayDims())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameField(net.runelite.deob.Field f, Field newField)
|
public void regeneratePool()
|
||||||
{
|
{
|
||||||
Class clazz = field.getClassEntry();
|
if (myField != null)
|
||||||
NameAndType nat = field.getNameAndType();
|
field = myField.getPoolField();
|
||||||
|
|
||||||
ClassFile cf = this.getInstructions().getCode().getAttributes().getClassFile().getGroup().findClass(clazz.getName());
|
|
||||||
if (cf == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
net.runelite.deob.Field f2 = cf.findFieldDeep(nat);
|
|
||||||
|
|
||||||
if (f2 == f)
|
|
||||||
{
|
|
||||||
field = newField;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import net.runelite.deob.signature.Signature;
|
|||||||
import net.runelite.deob.signature.Type;
|
import net.runelite.deob.signature.Type;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import net.runelite.deob.attributes.Code;
|
||||||
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
public class RenameUnique implements Deobfuscator
|
public class RenameUnique implements Deobfuscator
|
||||||
{
|
{
|
||||||
@@ -49,8 +51,8 @@ public class RenameUnique implements Deobfuscator
|
|||||||
// rename on instructions. this includes method calls and field accesses.
|
// rename on instructions. this includes method calls and field accesses.
|
||||||
if (method.getCode() != null)
|
if (method.getCode() != null)
|
||||||
{
|
{
|
||||||
Instructions instructions = method.getCode().getInstructions();
|
// Instructions instructions = method.getCode().getInstructions();
|
||||||
instructions.renameClass(cf, name);
|
// instructions.renameClass(cf, name);
|
||||||
|
|
||||||
// rename on exception handlers
|
// rename on exception handlers
|
||||||
Exceptions exceptions = method.getCode().getExceptions();
|
Exceptions exceptions = method.getCode().getExceptions();
|
||||||
@@ -99,7 +101,7 @@ public class RenameUnique implements Deobfuscator
|
|||||||
new net.runelite.deob.pool.Class(field.getFields().getClassFile().getName()),
|
new net.runelite.deob.pool.Class(field.getFields().getClassFile().getName()),
|
||||||
new NameAndType(name, field.getType())
|
new NameAndType(name, field.getType())
|
||||||
);
|
);
|
||||||
instructions.renameField(field, newField);
|
//instructions.renameField(field, newField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,7 +185,7 @@ public class RenameUnique implements Deobfuscator
|
|||||||
new net.runelite.deob.pool.Class(m.getMethods().getClassFile().getName()),
|
new net.runelite.deob.pool.Class(m.getMethods().getClassFile().getName()),
|
||||||
new NameAndType(name, m.getNameAndType().getDescriptor())
|
new NameAndType(name, m.getNameAndType().getDescriptor())
|
||||||
);
|
);
|
||||||
instructions.renameMethod(m, newMethod);
|
//instructions.renameMethod(m, newMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,35 +195,44 @@ public class RenameUnique implements Deobfuscator
|
|||||||
m.setName(name);
|
m.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private NameMappings generateClassNames(ClassGroup group)
|
||||||
public void run(ClassGroup group)
|
|
||||||
{
|
{
|
||||||
|
NameMappings map = new NameMappings();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int classes = 0, fields = 0, methods = 0;
|
|
||||||
|
|
||||||
group.buildClassGraph();
|
|
||||||
|
|
||||||
for (ClassFile cf : group.getClasses())
|
for (ClassFile cf : group.getClasses())
|
||||||
{
|
{
|
||||||
if (cf.getName().length() > 2)
|
if (cf.getName().length() > 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
renameClass(group, cf, "class" + i++);
|
map.map(cf.getPoolClass(), "class" + i++);
|
||||||
++classes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// rename fields
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NameMappings generatFieldNames(ClassGroup group)
|
||||||
|
{
|
||||||
|
NameMappings map = new NameMappings();
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
for (ClassFile cf : group.getClasses())
|
for (ClassFile cf : group.getClasses())
|
||||||
for (Field field : cf.getFields().getFields())
|
for (Field field : cf.getFields().getFields())
|
||||||
{
|
{
|
||||||
if (field.getName().length() > 2)
|
if (field.getName().length() > 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
renameField(group, field, "field" + i++);
|
map.map(field.getPoolField(), "field" + i++);
|
||||||
++fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// rename methods
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NameMappings generateMethodNames(ClassGroup group)
|
||||||
|
{
|
||||||
|
NameMappings map = new NameMappings();
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
for (ClassFile cf : group.getClasses())
|
for (ClassFile cf : group.getClasses())
|
||||||
for (Method method : cf.getMethods().getMethods())
|
for (Method method : cf.getMethods().getMethods())
|
||||||
{
|
{
|
||||||
@@ -237,10 +248,99 @@ public class RenameUnique implements Deobfuscator
|
|||||||
else
|
else
|
||||||
name = "vmethod" + i++;
|
name = "vmethod" + i++;
|
||||||
|
|
||||||
renameMethod(group, virtualMethods, name);
|
for (Method m : virtualMethods)
|
||||||
|
map.map(m.getPoolMethod(), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lookup(ClassGroup group)
|
||||||
|
{
|
||||||
|
for (ClassFile cf : group.getClasses())
|
||||||
|
for (Method m : cf.getMethods().getMethods())
|
||||||
|
{
|
||||||
|
Code c = m.getCode();
|
||||||
|
if (c == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
c.getInstructions().lookup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void regeneratePool(ClassGroup group)
|
||||||
|
{
|
||||||
|
for (ClassFile cf : group.getClasses())
|
||||||
|
for (Method m : cf.getMethods().getMethods())
|
||||||
|
{
|
||||||
|
Code c = m.getCode();
|
||||||
|
if (c == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
c.getInstructions().regeneratePool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ClassGroup group)
|
||||||
|
{
|
||||||
|
group.buildClassGraph();
|
||||||
|
lookup(group);
|
||||||
|
|
||||||
|
NameMappings mappings = this.generateClassNames(group);
|
||||||
|
|
||||||
|
//renameIns(group, mappings);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
int classes = 0, fields = 0, methods = 0;
|
||||||
|
|
||||||
|
for (ClassFile cf : group.getClasses())
|
||||||
|
{
|
||||||
|
String newName = mappings.get(cf.getPoolClass());
|
||||||
|
if (newName == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
renameClass(group, cf, newName);
|
||||||
|
++classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
mappings = this.generatFieldNames(group);
|
||||||
|
|
||||||
|
//renameIns(group, mappings);
|
||||||
|
|
||||||
|
// rename fields
|
||||||
|
for (ClassFile cf : group.getClasses())
|
||||||
|
for (Field field : cf.getFields().getFields())
|
||||||
|
{
|
||||||
|
String newName = mappings.get(field.getPoolField());
|
||||||
|
if (newName == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
renameField(group, field, newName);
|
||||||
|
++fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
mappings = this.generateMethodNames(group);
|
||||||
|
|
||||||
|
//renameIns(group, mappings);
|
||||||
|
|
||||||
|
// rename methods
|
||||||
|
for (ClassFile cf : group.getClasses())
|
||||||
|
for (Method method : cf.getMethods().getMethods())
|
||||||
|
{
|
||||||
|
String newName = mappings.get(method.getPoolMethod());
|
||||||
|
if (newName == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
List<Method> virtualMethods = getVirutalMethods(method);
|
||||||
|
assert !virtualMethods.isEmpty();
|
||||||
|
|
||||||
|
renameMethod(group, virtualMethods, newName);
|
||||||
methods += virtualMethods.size();
|
methods += virtualMethods.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.regeneratePool(group);
|
||||||
|
|
||||||
System.out.println("Uniquely renamed " + classes + " classes, " + fields + " fields, and " + methods + " methods");
|
System.out.println("Uniquely renamed " + classes + " classes, " + fields + " fields, and " + methods + " methods");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.runelite.deob.ConstantPool;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Method extends PoolEntry
|
public class Method extends PoolEntry
|
||||||
{
|
{
|
||||||
@@ -52,6 +53,15 @@ public class Method extends PoolEntry
|
|||||||
return clazz.equals(m.clazz) && nat.equals(m.nat);
|
return clazz.equals(m.clazz) && nat.equals(m.nat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int hash = 7;
|
||||||
|
hash = 67 * hash + Objects.hashCode(this.clazz);
|
||||||
|
hash = 67 * hash + Objects.hashCode(this.nat);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
public Class getClassEntry()
|
public Class getClassEntry()
|
||||||
{
|
{
|
||||||
return clazz;
|
return clazz;
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ public class Signature
|
|||||||
|
|
||||||
public Signature(Signature other)
|
public Signature(Signature other)
|
||||||
{
|
{
|
||||||
rv = other.rv;
|
rv = new Type(other.rv);
|
||||||
arguments.addAll(other.arguments);
|
for (Type t : other.arguments)
|
||||||
|
arguments.add(new Type(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ public class Type
|
|||||||
this.arrayDimms = dimms;
|
this.arrayDimms = dimms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Type(Type other)
|
||||||
|
{
|
||||||
|
type = other.type;
|
||||||
|
arrayDimms = other.arrayDimms;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType()
|
public String getType()
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
32
src/main/java/net/runelite/deob/util/NameMappings.java
Normal file
32
src/main/java/net/runelite/deob/util/NameMappings.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package net.runelite.deob.util;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import net.runelite.deob.pool.Class;
|
||||||
|
import net.runelite.deob.pool.Field;
|
||||||
|
import net.runelite.deob.pool.Method;
|
||||||
|
|
||||||
|
public class NameMappings
|
||||||
|
{
|
||||||
|
private final Map<Object, String> map = new HashMap<>();
|
||||||
|
|
||||||
|
public void map(Class cf, String name)
|
||||||
|
{
|
||||||
|
map.put(cf, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void map(Field field, String name)
|
||||||
|
{
|
||||||
|
map.put(field, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void map(Method method, String name)
|
||||||
|
{
|
||||||
|
map.put(method, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(Object object)
|
||||||
|
{
|
||||||
|
return map.get(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user