various fixes to graph building. I think there is a problem with how the execution runs, where it is not exploring all paths, because I have v13 class133.method2817 -> v14 class133 method2828 and there is no edge on the rhs for method4060->method4081. I think it is from two branches jumping to a place which jumps to the same place after, with invoke instructions on both sides.
This commit is contained in:
@@ -37,7 +37,7 @@ public class Deob
|
||||
{
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
//merge(); if(true) return;
|
||||
merge(); if(true) return;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.runelite.deob.deobfuscators.rename;
|
||||
import edu.ucla.sspace.graph.Graph;
|
||||
import edu.ucla.sspace.graph.isomorphism.IsomorphismTester;
|
||||
import edu.ucla.sspace.graph.isomorphism.TypedVF2IsomorphismTester;
|
||||
import edu.ucla.sspace.graph.isomorphism.VF2IsomorphismTester;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -34,7 +35,7 @@ public class Rename
|
||||
{
|
||||
Graph g1 = f1.getMethodCtx().getGraph(), g2 = f2.getMethodCtx().getGraph();
|
||||
|
||||
IsomorphismTester isoTest = new TypedVF2IsomorphismTester();
|
||||
IsomorphismTester isoTest = new /*Typed*/VF2IsomorphismTester();
|
||||
if (!isoTest.areIsomorphic(g1, g2))
|
||||
{
|
||||
System.out.println("Not isomorphic " + g1.size() + " " + g2.size());
|
||||
@@ -152,7 +153,7 @@ public class Rename
|
||||
Method m = (Method) next.get();
|
||||
Method m2 = (Method) objMap.get(m);
|
||||
|
||||
System.out.println("Scanning " + m.getName() + " -> " + m2.getName());
|
||||
System.out.println("Scanning " + m.getMethods().getClassFile().getName() + "." + m.getName() + " -> " + m2.getMethods().getClassFile().getName() + "." + m2.getName());
|
||||
process(m, m2);
|
||||
processed.add(m);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class Execution
|
||||
if (c != null)
|
||||
return c;
|
||||
|
||||
c = new MethodContext(m);
|
||||
c = new MethodContext();
|
||||
methodContexts.put(m, c);
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class Frame
|
||||
private Variables variables;
|
||||
private List<InstructionContext> instructions = new ArrayList<>(); // instructions executed in this frame
|
||||
private MethodContext ctx;
|
||||
protected int prevVertex = -1;
|
||||
|
||||
public Frame(Execution execution, Method method)
|
||||
{
|
||||
@@ -99,6 +100,7 @@ public class Frame
|
||||
this.stack = new Stack(other.stack);
|
||||
this.variables = new Variables(other.variables);
|
||||
this.ctx = other.ctx;
|
||||
this.prevVertex = other.prevVertex;
|
||||
}
|
||||
|
||||
public Frame dup()
|
||||
@@ -194,7 +196,7 @@ public class Frame
|
||||
if (!executing)
|
||||
break;
|
||||
|
||||
ctx.buildGraph(oldCur);
|
||||
ctx.buildGraph(this, oldCur);
|
||||
|
||||
if (oldCur == cur)
|
||||
{
|
||||
|
||||
@@ -16,20 +16,12 @@ import org.apache.commons.collections4.map.MultiValueMap;
|
||||
|
||||
public class MethodContext
|
||||
{
|
||||
private Method method;
|
||||
|
||||
private MultiValueMap<InstructionContext, Instruction> visited = new MultiValueMap<>();
|
||||
private IdGen ids = new IdGen();
|
||||
private Map<Integer, Instruction> idMap = new HashMap<>();
|
||||
private Map<Instruction, Integer> insMap = new HashMap<>();
|
||||
private Graph graph = new SparseDirectedGraph();
|
||||
private int prevVertex = -1;
|
||||
|
||||
public MethodContext(Method method)
|
||||
{
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public Map<Integer, Instruction> getIdMap()
|
||||
{
|
||||
return idMap;
|
||||
@@ -57,7 +49,7 @@ public class MethodContext
|
||||
|
||||
int id = ids.get();
|
||||
|
||||
graph.add(id);
|
||||
//graph.add(id);
|
||||
|
||||
this.idMap.put(id, i);
|
||||
this.insMap.put(i, id);
|
||||
@@ -65,7 +57,7 @@ public class MethodContext
|
||||
return id;
|
||||
}
|
||||
|
||||
protected void buildGraph(Instruction i)
|
||||
protected void buildGraph(Frame frame, Instruction i)
|
||||
{
|
||||
if (i instanceof InvokeInstruction)
|
||||
{
|
||||
@@ -87,12 +79,12 @@ public class MethodContext
|
||||
return;
|
||||
}
|
||||
|
||||
if (prevVertex == -1)
|
||||
if (frame.prevVertex == -1)
|
||||
{
|
||||
int id = getIdFor(i);
|
||||
//int id = ids.get();
|
||||
//graph.add(id);
|
||||
prevVertex = id;
|
||||
frame.prevVertex = id;
|
||||
//this.idMap.put(id, i);
|
||||
return;
|
||||
}
|
||||
@@ -102,12 +94,12 @@ public class MethodContext
|
||||
//graph.add(id);
|
||||
//idMap.put(id, i);
|
||||
|
||||
if (id == prevVertex)
|
||||
if (id == frame.prevVertex)
|
||||
return;
|
||||
|
||||
DirectedEdge edge = new SimpleDirectedEdge(prevVertex, id);
|
||||
DirectedEdge edge = new SimpleDirectedEdge(frame.prevVertex, id);
|
||||
graph.add(edge);
|
||||
|
||||
prevVertex = id;
|
||||
frame.prevVertex = id;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user