Annotate original classes/fields/methods with their obfuscated name
This commit is contained in:
@@ -122,6 +122,11 @@ public class ClassFile
|
|||||||
return methods;
|
return methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Attributes getAttributes()
|
||||||
|
{
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name.getName();
|
return name.getName();
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ public class Annotations extends Attribute
|
|||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAnnotation(Annotation annotation)
|
||||||
|
{
|
||||||
|
annotations.add(annotation);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadAttribute(DataInputStream is) throws IOException
|
public void loadAttribute(DataInputStream is) throws IOException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ public class Annotation
|
|||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setType(Type type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
@@ -35,6 +40,11 @@ public class Annotation
|
|||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addElement(Element element)
|
||||||
|
{
|
||||||
|
elements.add(element);
|
||||||
|
}
|
||||||
|
|
||||||
public void load(DataInputStream is) throws IOException
|
public void load(DataInputStream is) throws IOException
|
||||||
{
|
{
|
||||||
ConstantPool pool = annotations.getAttributes().getClassFile().getPool();
|
ConstantPool pool = annotations.getAttributes().getClassFile().getPool();
|
||||||
|
|||||||
@@ -27,10 +27,20 @@ public class Element
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setType(Type type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValue()
|
public String getValue()
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setValue(String value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
public void load(DataInputStream is) throws IOException
|
public void load(DataInputStream is) throws IOException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ import net.runelite.deob.Deobfuscator;
|
|||||||
import net.runelite.deob.Field;
|
import net.runelite.deob.Field;
|
||||||
import net.runelite.deob.Interfaces;
|
import net.runelite.deob.Interfaces;
|
||||||
import net.runelite.deob.Method;
|
import net.runelite.deob.Method;
|
||||||
|
import net.runelite.deob.attributes.Annotations;
|
||||||
|
import net.runelite.deob.attributes.AttributeType;
|
||||||
|
import net.runelite.deob.attributes.Attributes;
|
||||||
import net.runelite.deob.attributes.Code;
|
import net.runelite.deob.attributes.Code;
|
||||||
|
import net.runelite.deob.attributes.annotation.Annotation;
|
||||||
|
import net.runelite.deob.attributes.annotation.Element;
|
||||||
import net.runelite.deob.attributes.code.Exceptions;
|
import net.runelite.deob.attributes.code.Exceptions;
|
||||||
import net.runelite.deob.pool.NameAndType;
|
import net.runelite.deob.pool.NameAndType;
|
||||||
import net.runelite.deob.signature.Signature;
|
import net.runelite.deob.signature.Signature;
|
||||||
@@ -85,6 +90,7 @@ public class Renamer implements Deobfuscator
|
|||||||
field.setType(new Type("L" + name + ";", field.getType().getArrayDims()));
|
field.setType(new Type("L" + name + ";", field.getType().getArrayDims()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createOriginalNameAnnotation(cf.getAttributes(), cf.getName());
|
||||||
cf.setName(name);
|
cf.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +166,27 @@ public class Renamer implements Deobfuscator
|
|||||||
c.getInstructions().regeneratePool();
|
c.getInstructions().regeneratePool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Type OBFUSCATED_NAME_TYPE = new Type("Lnet/runelite/mapping/ObfuscatedName");
|
||||||
|
|
||||||
|
private void createOriginalNameAnnotation(Attributes attr, String name)
|
||||||
|
{
|
||||||
|
Annotations an = (Annotations) attr.findType(AttributeType.RUNTIMEVISIBLEANNOTATIONS);
|
||||||
|
if (an == null)
|
||||||
|
{
|
||||||
|
an = new Annotations(attr);
|
||||||
|
attr.addAttribute(an);
|
||||||
|
}
|
||||||
|
|
||||||
|
Annotation annotation = new Annotation(an);
|
||||||
|
annotation.setType(OBFUSCATED_NAME_TYPE);
|
||||||
|
an.addAnnotation(annotation);
|
||||||
|
|
||||||
|
Element element = new Element(annotation);
|
||||||
|
element.setType(new Type("value"));
|
||||||
|
element.setValue(name);
|
||||||
|
annotation.addElement(element);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ClassGroup group)
|
public void run(ClassGroup group)
|
||||||
@@ -177,6 +204,7 @@ public class Renamer implements Deobfuscator
|
|||||||
if (newName == null)
|
if (newName == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
createOriginalNameAnnotation(field.getAttributes(), field.getName());
|
||||||
field.setName(newName);
|
field.setName(newName);
|
||||||
++fields;
|
++fields;
|
||||||
}
|
}
|
||||||
@@ -193,7 +221,10 @@ public class Renamer implements Deobfuscator
|
|||||||
assert !virtualMethods.isEmpty();
|
assert !virtualMethods.isEmpty();
|
||||||
|
|
||||||
for (Method m : virtualMethods)
|
for (Method m : virtualMethods)
|
||||||
|
{
|
||||||
|
createOriginalNameAnnotation(m.getAttributes(), m.getName());
|
||||||
m.setName(newName);
|
m.setName(newName);
|
||||||
|
}
|
||||||
methods += virtualMethods.size();
|
methods += virtualMethods.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user