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 2ac9718e21..eb30c49237 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/rename/Rename2.java +++ b/src/main/java/net/runelite/deob/deobfuscators/rename/Rename2.java @@ -28,6 +28,7 @@ import net.runelite.deob.deobfuscators.rename.graph.Edge; import net.runelite.deob.deobfuscators.rename.graph.EdgeType; import net.runelite.deob.deobfuscators.rename.graph.FieldEdge; import net.runelite.deob.deobfuscators.rename.graph.Graph; +import net.runelite.deob.deobfuscators.rename.graph.GraphBuilder; import net.runelite.deob.deobfuscators.rename.graph.Vertex; import net.runelite.deob.deobfuscators.rename.graph.VertexType; import net.runelite.deob.execution.Execution; @@ -309,20 +310,20 @@ public class Rename2 public NameMappings run(ClassGroup one, ClassGroup two) { Execution eone = new Execution(one); - eone.setBuildGraph(true); + //eone.setBuildGraph(true); eone.populateInitialMethods(); eone.run(); Execution etwo = new Execution(two); - etwo.setBuildGraph(true); + //etwo.setBuildGraph(true); etwo.populateInitialMethods(); etwo.run(); - g1 = eone.getGraph(); - g2 = etwo.getGraph(); + g1 = GraphBuilder.build(one); + g2 = GraphBuilder.build(two); - System.out.println(eone.getGraph()); - System.out.println(etwo.getGraph()); +// System.out.println(eone.getGraph()); +// System.out.println(etwo.getGraph()); for (int i = 0; i < 250; ++i) { 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 82537049a6..2d40c3de4f 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 @@ -121,10 +121,10 @@ public class Edge if (this.type == EdgeType.SETFIELD)// || this.type == EdgeType.SETFIELD_FROM) { - if (!compareSetField(getGraph(), other.getGraph(), - (Field) this.getTo().getObject(), (Field) other.getTo().getObject(), - other.getIns())) - return false; +// if (!compareSetField(getGraph(), other.getGraph(), +// (Field) this.getTo().getObject(), (Field) other.getTo().getObject(), +// other.getIns())) +// return false; } // if (this.weight != other.weight) // return false; diff --git a/src/main/java/net/runelite/deob/execution/Execution.java b/src/main/java/net/runelite/deob/execution/Execution.java index a23775cff6..09a8de4402 100644 --- a/src/main/java/net/runelite/deob/execution/Execution.java +++ b/src/main/java/net/runelite/deob/execution/Execution.java @@ -37,6 +37,8 @@ public class Execution public Set executed = new HashSet<>(); // executed instructions private MultiValueMap invokes = new MultiValueMap<>(); public MultiValueMap contexts = new MultiValueMap<>(); + public boolean paused; + public boolean step = true; public Execution(ClassGroup group) { @@ -105,6 +107,7 @@ public class Execution public Frame invoke(InstructionContext from, Method to) { + if(!step) return null;//THIS BREAKS THIS if (hasInvoked(from, to)) return null; @@ -123,6 +126,7 @@ public class Execution public void run() { + assert !paused; int fcount = 0; while (!frames.isEmpty()) @@ -144,10 +148,17 @@ public class Execution System.out.println("Processed " + fcount + " frames"); } - { - - } +// public InstructionContext getPaused() +// { +// if (frames.isEmpty()) +// return null; +// +// Frame f = frames.get(0); +// return f.getInstructions().get(f.getInstructions().size() - 1); +// } + public Collection getInstructonContexts(Instruction i) { + return contexts.getCollection(i); } } diff --git a/src/main/java/net/runelite/deob/execution/Frame.java b/src/main/java/net/runelite/deob/execution/Frame.java index be61168d1b..3c15159ba0 100644 --- a/src/main/java/net/runelite/deob/execution/Frame.java +++ b/src/main/java/net/runelite/deob/execution/Frame.java @@ -228,7 +228,7 @@ public class Frame /* jump */ } - if (oldCur instanceof MappableInstruction) + if (!execution.step && oldCur instanceof MappableInstruction) { execution.paused = true; return; diff --git a/src/main/java/net/runelite/deob/execution/InstructionContext.java b/src/main/java/net/runelite/deob/execution/InstructionContext.java index 7089ddb991..e7bffbd26d 100644 --- a/src/main/java/net/runelite/deob/execution/InstructionContext.java +++ b/src/main/java/net/runelite/deob/execution/InstructionContext.java @@ -6,6 +6,9 @@ import java.util.List; import net.runelite.deob.Method; import net.runelite.deob.attributes.code.Instruction; import java.util.Objects; +import net.runelite.deob.attributes.code.instruction.types.DupInstruction; +import net.runelite.deob.attributes.code.instruction.types.LVTInstruction; +import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction; public class InstructionContext { @@ -158,4 +161,52 @@ public class InstructionContext { return "InstructionContext{" + "ins=" + ins + '}'; } + + public InstructionContext resolve( + StackContext from // pushed from this + ) + { + InstructionContext ctx = this; + + if (ctx.getInstruction() instanceof SetFieldInstruction) + { + StackContext s = ctx.getPops().get(0); + return s.getPushed().resolve(s); + } + + if (ctx.getInstruction() instanceof DupInstruction) + { + DupInstruction d = (DupInstruction) ctx.getInstruction(); + StackContext s = d.getOriginal(from); + return s.getPushed().resolve(s); + } + + if (ctx.getInstruction() instanceof LVTInstruction) + { + LVTInstruction lvt = (LVTInstruction) ctx.getInstruction(); + Variables variables = ctx.getVariables(); + + if (lvt.store()) + { + StackContext s = ctx.getPops().get(0); // is this right? + return s.getPushed().resolve(s); + } + else + { + VariableContext vctx = variables.get(lvt.getVariableIndex()); // variable being loaded + assert vctx != null; + + InstructionContext storedCtx = vctx.getInstructionWhichStored(); + if (storedCtx == null) + return ctx; // initial parameter + + if (vctx.isIsParameter()) + return ctx; // parameter (storedCtx is invoking instruction in another frame). this lvt index is fixed. + + return storedCtx.resolve(null); + } + } + + return ctx; + } }