From 765b5d7467a8d2fdf7d0674f661e96d2a9df41ee Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 19 Nov 2015 20:31:27 -0500 Subject: [PATCH] Cleanup --- .../runelite/deob/execution/Execution.java | 24 +--- .../net/runelite/deob/execution/Frame.java | 39 +------ .../deob/execution/MethodContext.java | 104 ------------------ 3 files changed, 4 insertions(+), 163 deletions(-) diff --git a/src/main/java/net/runelite/deob/execution/Execution.java b/src/main/java/net/runelite/deob/execution/Execution.java index 7baae880b7..d976e6774e 100644 --- a/src/main/java/net/runelite/deob/execution/Execution.java +++ b/src/main/java/net/runelite/deob/execution/Execution.java @@ -7,7 +7,6 @@ import net.runelite.deob.Method; import net.runelite.deob.attributes.code.Instruction; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -20,7 +19,6 @@ import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction; import net.runelite.deob.attributes.code.instructions.InvokeStatic; import net.runelite.deob.deobfuscators.arithmetic.Encryption; -import net.runelite.deob.deobfuscators.rename.Rename2; import net.runelite.deob.deobfuscators.rename.graph.EdgeType; import net.runelite.deob.deobfuscators.rename.graph.Graph; import org.apache.commons.collections4.map.MultiValueMap; @@ -110,25 +108,16 @@ public class Execution private void addFrame(Frame frame) { frames.add(frame); - //frames.add(0, frame); } public void invoke(InstructionContext from, Method to) { - Frame frame = from.getFrame(); - -// if (!this.isFollowInvokes() && !to.isStatic()) -// return; - if (hasInvoked(from, to)) return; Frame f = new Frame(this, to); f.initialize(from); this.addFrame(f); - - // if (!this.followInvokes && to.isStatic()) - // frame.stop(); // frames continue from the method } public void addMethod(Method to) @@ -158,16 +147,9 @@ public class Execution assert frame.isExecuting(); frame.execute(); -// if (!frame.isExecuting()) -// { - assert frames.get(0) == frame; - frames.remove(frame); - processedFrames.add(frame); -// } -// else -// { -// // another frame takes priority -// } + assert frames.get(0) == frame; + frames.remove(0); + processedFrames.add(frame); } System.out.println("Processed " + fcount + " frames"); diff --git a/src/main/java/net/runelite/deob/execution/Frame.java b/src/main/java/net/runelite/deob/execution/Frame.java index 56ecb60247..d00a01e391 100644 --- a/src/main/java/net/runelite/deob/execution/Frame.java +++ b/src/main/java/net/runelite/deob/execution/Frame.java @@ -60,15 +60,9 @@ public class Frame // initialize frame from invoking context assert ctx.getInstruction() instanceof InvokeInstruction; - //if (!this.getExecution().isFollowInvokes() && this.getMethod().isStatic()) if (this.getMethod().isStatic()) { - //assert this.nonStatic == null; this.nonStatic = ctx.getFrame().nonStatic; - //assert from == null; - //from = ctx.getFrame(); - //this.ctx = ctx.getFrame().ctx; // share ctx if this method is static - //this.prevVertex = ctx.getFrame().prevVertex; } // initialize LVT. the last argument is popped first, and is at arguments[0] @@ -104,10 +98,7 @@ public class Frame this.stack = new Stack(other.stack); this.variables = new Variables(other.variables); this.ctx = other.ctx; - //this.prevVertex = new MutableInt(other.prevVertex); - //this.prevInvokes = other.prevInvokes; - nonStatic = other.nonStatic; -// from = other.from; + this.nonStatic = other.nonStatic; } public Frame dup() @@ -220,13 +211,6 @@ public class Frame { /* jump */ } - -// if (!execution.frames.isEmpty() && execution.frames.get(0) != this) -// { -// stop(); // the prev frame must be an invokestatic? -// assert execution.frames.get(0).getMethod().isStatic(); -// break; -// } } } @@ -272,25 +256,4 @@ public class Frame cur = to; } - -// private boolean processReturn() -// { -// if (this.getExecution().isFollowInvokes() || !this.getMethod().isStatic()) -// return false; -// -// if (from == null) -// return false; -// -// assert !from.isExecuting(); -// -// // update method, cur, stack, variables, from outermost method -// this.method = from.method; -// //this.executing = from.executing; -// this.cur = from.cur; -// this.stack = new Stack(from.stack); -// this.variables = new Variables(from.variables); -// -// //stop(); // now that weve switched this should still be running -// return true; // this stops frame execution -// } } diff --git a/src/main/java/net/runelite/deob/execution/MethodContext.java b/src/main/java/net/runelite/deob/execution/MethodContext.java index 74035f566d..99dbe328fe 100644 --- a/src/main/java/net/runelite/deob/execution/MethodContext.java +++ b/src/main/java/net/runelite/deob/execution/MethodContext.java @@ -1,37 +1,19 @@ package net.runelite.deob.execution; -import java.util.Arrays; import java.util.Collection; -import java.util.List; -import net.runelite.deob.Method; import net.runelite.deob.attributes.code.Instruction; -import net.runelite.deob.attributes.code.instruction.types.FieldInstruction; -import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction; -import net.runelite.deob.attributes.code.instructions.InvokeStatic; -import net.runelite.deob.deobfuscators.rename.graph.Graph; import org.apache.commons.collections4.map.MultiValueMap; public class MethodContext { private Execution execution; private MultiValueMap visited = new MultiValueMap<>(); - //private IdGen ids = new IdGen(); - //private Map> idMap = new HashMap<>(); - //private Map, Integer> insMap = new HashMap<>(); -// private Graph graph = new Graph(); public MethodContext(Execution execution) { this.execution = execution; } -// public Map> getIdMap() -// { -// return idMap; -// } - - - protected boolean hasJumped(InstructionContext from, Instruction to) { Collection i = visited.getCollection(from); @@ -41,90 +23,4 @@ public class MethodContext visited.put(from, to); return false; } - -// private int getIdFor(List i) -// { -// if (insMap.containsKey(i)) -// return insMap.get(i); -// -// assert idMap.values().contains(i) == false; -// -// int id = ids.get(); -// -// //graph.add(id); -// -// this.idMap.put(id, i); -// this.insMap.put(i, id); -// -// return id; -// } - -// protected void buildGraph(Frame frame, Instruction i) -// { -// if (!execution.isBuildGraph()) -// return; -// -// List to; -// //List methods; -// if (i instanceof InvokeInstruction) -// { -// if (i instanceof InvokeStatic) -// return; -// -// InvokeInstruction ii = (InvokeInstruction) i; -// -// List methods = ii.getMethods(); -// if (methods.isEmpty()) -// return; -// -// to = (List) methods; -// } -// else if (i instanceof FieldInstruction) -// { -// FieldInstruction fi = (FieldInstruction) i; -// -// if (fi.getMyField() == null) -// return; -// -// to = Arrays.asList(fi.getMyField()); -// } -// else -// { -// return; -// } -// -// to.stream().forEach(o -> graph.addEdge(frame.getMethod(), o)); -// -//// if (frame.prevVertex.intValue() == -1) -//// { -//// int id = getIdFor(methods); -//// //int id = ids.get(); -//// //graph.add(id); -//// frame.prevVertex.setValue(id); -//// //this.idMap.put(id, i); -//// return; -//// } -//// -//// int id = getIdFor(methods); -//// //int id = ids.get(); -//// //graph.add(id); -//// //idMap.put(id, i); -//// -//// if (frame.prevVertex.intValue() == id) -//// return; -//// -//// DirectedEdge edge = new SimpleDirectedEdge(frame.prevVertex.intValue(), id); -//// -//// if (graph.contains(edge) == false) -//// { -//// List from = this.idMap.get(frame.prevVertex.intValue()), to = this.idMap.get(id); -//// System.out.println("Added edge " + from.get(0).getMethods().getClassFile().getName() + "." + from.get(0).getName() + -//// " to " + to.get(0).getMethods().getClassFile().getName() + "." + to.get(0).getName() + -//// " (" + frame.prevVertex.intValue() + " -> " + id + ")"); -//// -//// graph.add(edge); -//// } -//// -//// frame.prevVertex.setValue(id); -// } }