From fb4ee1ac9ba168fbbb0fdeb505751eb046349bae Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Feb 2016 12:58:44 -0500 Subject: [PATCH] Store return stack pop with stack context instead of what I was trying to do before --- .../rename/MappingExecutorUtil.java | 8 ++++ .../execution/ParallellMappingExecutor.java | 47 ++++++++++--------- .../runelite/deob/execution/StackContext.java | 1 + .../deobfuscators/rename/MapStaticTest.java | 8 ++++ 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/main/java/net/runelite/deob/deobfuscators/rename/MappingExecutorUtil.java b/src/main/java/net/runelite/deob/deobfuscators/rename/MappingExecutorUtil.java index 6171018984..a5f7fa2c92 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/rename/MappingExecutorUtil.java +++ b/src/main/java/net/runelite/deob/deobfuscators/rename/MappingExecutorUtil.java @@ -301,6 +301,14 @@ public class MappingExecutorUtil return resolve(storedCtx, null); } } + + if (ctx.getInstruction() instanceof InvokeStatic) + { + if (from.returnSource != null) + { + return resolve(from.returnSource.getPushed(), from.returnSource); + } + } return ctx; } diff --git a/src/main/java/net/runelite/deob/execution/ParallellMappingExecutor.java b/src/main/java/net/runelite/deob/execution/ParallellMappingExecutor.java index 3742ade3c0..b7bde30684 100644 --- a/src/main/java/net/runelite/deob/execution/ParallellMappingExecutor.java +++ b/src/main/java/net/runelite/deob/execution/ParallellMappingExecutor.java @@ -297,7 +297,7 @@ public class ParallellMappingExecutor return f2; } - public static boolean enable = false; + public static boolean enable = true; public static List returnStacks = new ArrayList<>(); private Frame popStack(Frame f) { @@ -335,27 +335,30 @@ public class ParallellMappingExecutor StackContext invokePushed = i2.getPushes().get(0); - if (invokePushed.getPushed().getInstruction() != i2.getInstruction()) - //if (!(invokePushed.getPushed().getInstruction() instanceof InvokeStatic)) - { - return r; - } - - //returnStacks.add(invokePushed); - returnStacks.add(returnValue); - boolean b = returnStacks.contains(invokePushed); - assert invokePushed.getPopped().isEmpty(); - - // replace invokePushed with returnValue? - i2.getPushes().remove(invokePushed); - i2.getPushes().add(returnValue); - - //invokePushed.setpushed = null - - Stack stack = r.getStack(); - StackContext s = stack.pop(); - assert s == invokePushed; - stack.push(returnValue); + //assert invokePushed.returnSource == null; + invokePushed.returnSource = returnValue; +// +// if (invokePushed.getPushed().getInstruction() != i2.getInstruction()) +// //if (!(invokePushed.getPushed().getInstruction() instanceof InvokeStatic)) +// { +// return r; +// } +// +// //returnStacks.add(invokePushed); +// returnStacks.add(returnValue); +// boolean b = returnStacks.contains(invokePushed); +// assert invokePushed.getPopped().isEmpty(); +// +// // replace invokePushed with returnValue? +// i2.getPushes().remove(invokePushed); +// i2.getPushes().add(returnValue); +// +// //invokePushed.setpushed = null +// +// Stack stack = r.getStack(); +// StackContext s = stack.pop(); +// assert s == invokePushed; +// stack.push(returnValue); //assert invokePushed.getPushed().getPushes().contains(invokePushed); //invokePushed.getpu diff --git a/src/main/java/net/runelite/deob/execution/StackContext.java b/src/main/java/net/runelite/deob/execution/StackContext.java index 7e5bb25c2d..0b95a56e68 100644 --- a/src/main/java/net/runelite/deob/execution/StackContext.java +++ b/src/main/java/net/runelite/deob/execution/StackContext.java @@ -11,6 +11,7 @@ public class StackContext public Type type; // type of this private Value value; public boolean removed; + public StackContext returnSource; // if this is the return value of an invokestatic, returnSource is the stack popped by the Return instruction public StackContext(InstructionContext pushed, Type type, Value value) { diff --git a/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java b/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java index d08aacaa24..2d8a151068 100644 --- a/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java +++ b/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java @@ -522,6 +522,14 @@ public class MapStaticTest } return list; } + + @Test + public void testPackets() throws IOException + { + ClassGroup group1 = JarUtil.loadJar(new File(JAR1)); + ClassGroup group2 = JarUtil.loadJar(new File(JAR2)); + testPackets(group1, group2); + } //@Test public ParallelExecutorMapping testPackets(ClassGroup group1, ClassGroup group2) throws IOException