From 534623316ebcebd2d58f90e9889fc1e3361b4e57 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 6 Dec 2015 17:53:49 -0500 Subject: [PATCH] Solved methods 942, solved fields 1295, unsolved methods 171, unsolved fields 1000 --- .../deob/deobfuscators/rename/Rename2.java | 23 ++++++-- .../deob/deobfuscators/rename/graph/Edge.java | 59 ++++++++++++++++--- 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/runelite/deob/deobfuscators/rename/Rename2.java b/src/main/java/net/runelite/deob/deobfuscators/rename/Rename2.java index a35bf2ef85..f22698aa79 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/rename/Rename2.java +++ b/src/main/java/net/runelite/deob/deobfuscators/rename/Rename2.java @@ -251,16 +251,16 @@ public class Rename2 assert e.getFrom() == s; boolean b = false; - if (e.toString().equals("Edge{from=Vertex{object=class97.()V}, to=Vertex{object=I class97.field1653}, type=SETFIELD}")) - { - b = true; - } +// if (e.toString().equals("Edge{from=Vertex{object=class97.()V}, to=Vertex{object=I class97.field1653}, type=SETFIELD}")) +// { +// b = true; +// } if (e.getTo().getOther() != null) continue; // skip solved edges Vertex v = e.getTo(); // end of edge in g1 - if (v.toString().equals("Vertex{object=I class97.field1653}")) + if (v.toString().equals("Vertex{object=I class100.field1728}")) { b = true; } @@ -277,17 +277,28 @@ public class Rename2 continue; } - if (b) + if (b && e.getType() == EdgeType.SETFIELD && e2.getType() == EdgeType.SETFIELD) { int i = 5; } if (!e.couldBeEqual(e2)) { + //Edge{from=Vertex{object=class96.(IIIIIIIIIIIIIIIIIII)V}, to=Vertex{object=I[] class96.field1630}, type=SETFIELD} + //Edge{from=Vertex{object=class96.(IIIIIIIIIIIIIIIIIII)V}, to=Vertex{object=I[] class96.field1632}, type=GETFIELD} + + //if (e.getTo().toString().equals("Vertex{object=I[] class96.field1630}") && e.getType() == EdgeType.SETFIELD + // && e2.getTo().toString().equals("Vertex{object=I[] class96.field1632}") && e2.getType() == EdgeType.SETFIELD) + { + e.couldBeEqual(e2); + } + // System.out.println(e + " != " + e2); continue; } + e.couldBeEqual(e2); + Vertex v2 = e2.getTo(); l.add(v2); diff --git a/src/main/java/net/runelite/deob/deobfuscators/rename/graph/Edge.java b/src/main/java/net/runelite/deob/deobfuscators/rename/graph/Edge.java index 5dd06f07bb..82537049a6 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/rename/graph/Edge.java +++ b/src/main/java/net/runelite/deob/deobfuscators/rename/graph/Edge.java @@ -1,13 +1,14 @@ package net.runelite.deob.deobfuscators.rename.graph; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Objects; import net.runelite.deob.Field; import net.runelite.deob.Method; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.instruction.types.DupInstruction; +import net.runelite.deob.attributes.code.instruction.types.FieldInstruction; +import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction; import net.runelite.deob.attributes.code.instruction.types.LVTInstruction; import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction; @@ -120,7 +121,9 @@ public class Edge if (this.type == EdgeType.SETFIELD)// || this.type == EdgeType.SETFIELD_FROM) { - if (!compareSetField((Field) this.getTo().getObject(), (Field) other.getTo().getObject(), other.getIns())) + if (!compareSetField(getGraph(), other.getGraph(), + (Field) this.getTo().getObject(), (Field) other.getTo().getObject(), + other.getIns())) return false; } // if (this.weight != other.weight) @@ -230,15 +233,15 @@ public class Edge // return ctx; } - private boolean compareSetField(Field field1, Field field2, InstructionContext other) + private boolean compareSetField(Graph g1, Graph g2, Field field1, Field field2, InstructionContext other) { InstructionContext thisp = resolve(ins.getPops().get(0).getPushed(), ins.getPops().get(0)), otherp = resolve(other.getPops().get(0).getPushed(), other.getPops().get(0)); - return couldBeEqual(field1, field2, thisp, otherp, null); + return couldBeEqual(g1, g2, field1, field2, thisp, otherp, null); } - private boolean couldBeEqual(Field field1, Field field2, InstructionContext one, InstructionContext two, InstructionContext from) + private boolean couldBeEqual(Graph g1, Graph g2, Field field1, Field field2, InstructionContext one, InstructionContext two, InstructionContext from) { Instruction i1 = one.getInstruction(), i2 = two.getInstruction(); @@ -265,7 +268,8 @@ public class Edge if (i1 instanceof NewArray && i2 instanceof NewArray) { NewArray a1 = (NewArray) i1, a2 = (NewArray) i2; - return a1.getArrayType() == a2.getArrayType(); + if (a1.getArrayType() != a2.getArrayType()) + return false; } // XXX check for invokestatic vs. @@ -294,7 +298,41 @@ public class Edge else if (i1 instanceof InvokeStatic || i2 instanceof InvokeStatic) { return true; - //int i = 5; + } + + if (i1 instanceof FieldInstruction && i2 instanceof FieldInstruction) + { + assert i1 instanceof GetFieldInstruction; + assert i2 instanceof GetFieldInstruction; + + GetFieldInstruction gf1 = (GetFieldInstruction) i1, gf2 = (GetFieldInstruction) i2; + Field f1 = gf1.getMyField(), f2 = gf2.getMyField(); + + if ((f1 != null) != (f2 != null)) + return false; + + //if (f1 == null || f2 == null) + // return + + if (!f1.getType().equals(f2.getType())) + return false; + + // lookup already solved fields. + + Vertex v1 = g1.getVertexFor(f1), v2 = g2.getVertexFor(f2); // vertex of fields whose value is being set to + + // get solved field + v1 = v1.getOther(); + v2 = v2.getOther(); + + if ((v1 != null) != (v2 != null)) + return false; + + if (v1 != null || v2 != null) + { + if (v1.getObject() != f2 || v2.getObject() != f1) + return false; + } } if (i1 instanceof PushConstantInstruction && i2 instanceof PushConstantInstruction) @@ -319,6 +357,7 @@ public class Edge continue; if (!couldBeEqual( + g1, g2, field1, field2, resolve(s1.getPushed(), s1), resolve(s2.getPushed(), s2), @@ -359,4 +398,10 @@ public class Edge return true; } + + private Graph getGraph() + { + assert from.getGraph() == to.getGraph(); + return from.getGraph(); + } }