A lot of fields still can't be mapped. I am not able to map all fields
exported from RL at all. Might try and get more specific stuff from fields like: Other fields used in expressions Assigning values to fields from LVT (parameters)? Passed to methods, and at what index
This commit is contained in:
@@ -115,16 +115,10 @@ public class Field
|
|||||||
new NameAndType(this.getName(), this.getType())
|
new NameAndType(this.getName(), this.getType())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
return name.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return this.type + " " + this.getFields().getClassFile().getName() + "." + this.getName();
|
return (this.isStatic() ? "static " : "") + this.type + " " + this.getFields().getClassFile().getName() + "." + this.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,10 @@ import net.runelite.deob.ClassGroup;
|
|||||||
import net.runelite.deob.Deob;
|
import net.runelite.deob.Deob;
|
||||||
import net.runelite.deob.Field;
|
import net.runelite.deob.Field;
|
||||||
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.annotation.Annotation;
|
||||||
import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction;
|
import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction;
|
||||||
import net.runelite.deob.deobfuscators.Renamer;
|
import net.runelite.deob.deobfuscators.Renamer;
|
||||||
import net.runelite.deob.deobfuscators.rename.graph.Edge;
|
import net.runelite.deob.deobfuscators.rename.graph.Edge;
|
||||||
@@ -28,6 +32,7 @@ import net.runelite.deob.execution.Execution;
|
|||||||
import net.runelite.deob.execution.Frame;
|
import net.runelite.deob.execution.Frame;
|
||||||
import net.runelite.deob.execution.InstructionContext;
|
import net.runelite.deob.execution.InstructionContext;
|
||||||
import net.runelite.deob.signature.Signature;
|
import net.runelite.deob.signature.Signature;
|
||||||
|
import net.runelite.deob.signature.Type;
|
||||||
import net.runelite.deob.util.JarUtil;
|
import net.runelite.deob.util.JarUtil;
|
||||||
import net.runelite.deob.util.NameMappings;
|
import net.runelite.deob.util.NameMappings;
|
||||||
|
|
||||||
@@ -86,6 +91,28 @@ public class Rename2
|
|||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<Type, Field> findField(ClassFile cf)
|
||||||
|
{
|
||||||
|
Map<Type, Field> set = new HashMap<>();
|
||||||
|
Set collided = new HashSet();
|
||||||
|
for (Field f : cf.getFields().getFields())
|
||||||
|
{
|
||||||
|
if (f.isStatic())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Type t = f.getType();
|
||||||
|
|
||||||
|
if (set.containsKey(t) || collided.contains(t))
|
||||||
|
{
|
||||||
|
collided.add(t);
|
||||||
|
set.remove(t);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
set.put(t, f);
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
private void mapClassMethods(Map<Signature, Method> one, Map<Signature, Method> two)
|
private void mapClassMethods(Map<Signature, Method> one, Map<Signature, Method> two)
|
||||||
{
|
{
|
||||||
if (!one.keySet().equals(two.keySet()))
|
if (!one.keySet().equals(two.keySet()))
|
||||||
@@ -106,6 +133,24 @@ public class Rename2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mapClassFields(Map<Type, Field> one, Map<Type, Field> two)
|
||||||
|
{
|
||||||
|
if (!one.keySet().equals(two.keySet()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Type t : one.keySet())
|
||||||
|
{
|
||||||
|
Field f1 = one.get(t), f2 = two.get(t);
|
||||||
|
|
||||||
|
Vertex v1 = g1.getVertexFor(f1), v2 = g2.getVertexFor(f2);
|
||||||
|
|
||||||
|
v1.is(v2);
|
||||||
|
v2.is(v1);
|
||||||
|
|
||||||
|
System.out.println(fname(f1) + " is " + fname(f2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void mapDeobfuscatedMethods(ClassFile cf1, ClassFile cf2)
|
private void mapDeobfuscatedMethods(ClassFile cf1, ClassFile cf2)
|
||||||
{
|
{
|
||||||
List<Method> m1 = cf1.getMethods().getMethods().stream().filter(m -> !Deob.isObfuscated(m.getName())).collect(Collectors.toList()),
|
List<Method> m1 = cf1.getMethods().getMethods().stream().filter(m -> !Deob.isObfuscated(m.getName())).collect(Collectors.toList()),
|
||||||
@@ -243,12 +288,17 @@ public class Rename2
|
|||||||
if (c1 == null || c2 == null)
|
if (c1 == null || c2 == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Map m1 = this.find(c1);
|
Map m1 = this.find(c1);
|
||||||
//Map m2 = this.find(c2);
|
Map m2 = this.find(c2);
|
||||||
|
|
||||||
// mapClassMethods(m1, m2);
|
mapClassMethods(m1, m2);
|
||||||
|
|
||||||
mapDeobfuscatedMethods(c1, c2);
|
mapDeobfuscatedMethods(c1, c2);
|
||||||
|
|
||||||
|
m1 = findField(c1);
|
||||||
|
m2 = findField(c2);
|
||||||
|
|
||||||
|
mapClassFields(m1, m2);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassFile cf1 = one.findClass("client"), cf2 = two.findClass("client");
|
ClassFile cf1 = one.findClass("client"), cf2 = two.findClass("client");
|
||||||
@@ -307,11 +357,10 @@ public class Rename2
|
|||||||
if (v.getOther() == null)
|
if (v.getOther() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!v.toString().equals("Vertex{object=class0.<init>()V}"))
|
if (v.getObject() instanceof Method) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
assert stored == null;
|
//assert stored == null;
|
||||||
stored = v;
|
//stored = v;
|
||||||
|
|
||||||
for (Edge e : v.getEdges())
|
for (Edge e : v.getEdges())
|
||||||
{
|
{
|
||||||
@@ -342,6 +391,8 @@ public class Rename2
|
|||||||
Logger.getLogger(Rename2.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Rename2.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkExports(one);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,4 +526,57 @@ public class Rename2
|
|||||||
Renamer renamer = new Renamer(mappings);
|
Renamer renamer = new Renamer(mappings);
|
||||||
renamer.run(group);
|
renamer.run(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Type EXPORT = new Type("Lnet/runelite/mapping/Export;");
|
||||||
|
|
||||||
|
private boolean isExported(Attributes attr)
|
||||||
|
{
|
||||||
|
Annotations an = (Annotations) attr.findType(AttributeType.RUNTIMEVISIBLEANNOTATIONS);
|
||||||
|
if (an == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (Annotation a : an.getAnnotations())
|
||||||
|
{
|
||||||
|
if (a.getType().equals(EXPORT))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkExports(ClassGroup one)
|
||||||
|
{
|
||||||
|
for (ClassFile cf : one.getClasses())
|
||||||
|
{
|
||||||
|
for (Field f : cf.getFields().getFields())
|
||||||
|
{
|
||||||
|
if (!isExported(f.getAttributes()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Vertex v = g1.getVertexFor(f);
|
||||||
|
assert v != null;
|
||||||
|
|
||||||
|
if (v.getOther() == null)
|
||||||
|
{
|
||||||
|
System.out.println("Unsolved exported field " + f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Method m : cf.getMethods().getMethods())
|
||||||
|
{
|
||||||
|
if (!isExported(m.getAttributes()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Vertex v = g1.getVertexFor(m);
|
||||||
|
assert v != null;
|
||||||
|
|
||||||
|
if (v.getOther() == null)
|
||||||
|
{
|
||||||
|
System.out.println("Unsolved exported method " + m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class Edge
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "Edge{" + "from=" + from + ", to=" + to + '}';
|
return "Edge{" + "from=" + from + ", to=" + to + ", type=" + type + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -332,8 +332,8 @@ public class Vertex
|
|||||||
ConstantValue cf1 = (ConstantValue) f1.getAttributes().findType(AttributeType.CONSTANT_VALUE);
|
ConstantValue cf1 = (ConstantValue) f1.getAttributes().findType(AttributeType.CONSTANT_VALUE);
|
||||||
ConstantValue cf2 = (ConstantValue) f2.getAttributes().findType(AttributeType.CONSTANT_VALUE);
|
ConstantValue cf2 = (ConstantValue) f2.getAttributes().findType(AttributeType.CONSTANT_VALUE);
|
||||||
|
|
||||||
if (!Objects.equal(cf1, cf2))
|
//if (!Objects.equal(cf1, cf2))
|
||||||
return false;
|
// return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assert false;
|
assert false;
|
||||||
|
|||||||
Reference in New Issue
Block a user