From f50c6523c0f8f5976ee43900fcea1f30558b7688 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 29 Jan 2016 21:24:07 -0500 Subject: [PATCH] hm --- .../attributes/code/instructions/IfICmpEq.java | 6 +++++- .../attributes/code/instructions/IfICmpNe.java | 16 +++++++++++++++- .../deob/deobfuscators/rename/MapStaticTest.java | 15 +++++++++++---- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IfICmpEq.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IfICmpEq.java index a93583e20d..0f75242989 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IfICmpEq.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IfICmpEq.java @@ -43,6 +43,10 @@ public class IfICmpEq extends If if (isZero(s1) || isZero(s2)) return true; } + else if (otherIc.getInstruction() instanceof IfICmpNe) + { + return true; + } return false; } @@ -50,7 +54,7 @@ public class IfICmpEq extends If @Override public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other) { - if (other.getInstruction() instanceof IfNe) + if (other.getInstruction() instanceof IfNe || other.getInstruction() instanceof IfICmpNe) { super.mapOtherBranch(mapping, ctx, other); } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IfICmpNe.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IfICmpNe.java index 8c89485512..bc19564106 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IfICmpNe.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IfICmpNe.java @@ -3,6 +3,7 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction; +import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.StackContext; @@ -34,7 +35,7 @@ public class IfICmpNe extends If return true; // check for other being ifne and this has a constant 0 - if (otherIc.getInstruction() instanceof IfNe) + if (otherIc.getInstruction() instanceof IfNe || otherIc.getInstruction() instanceof IfEq) { StackContext s1 = thisIc.getPops().get(0), s2 = thisIc.getPops().get(1); @@ -45,4 +46,17 @@ public class IfICmpNe extends If return false; } + + @Override + public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other) + { + if (other.getInstruction() instanceof IfEq) + { + super.mapOtherBranch(mapping, ctx, other); + } + else + { + super.map(mapping, ctx, other); + } + } } 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 064057cbca..219154f789 100644 --- a/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java +++ b/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java @@ -37,6 +37,7 @@ public class MapStaticTest { "class72.run", "class72.run" }, { "class64.vmethod3787", "class64.vmethod3664" }, { "class207.method3965", "class207.method3846" }, + { "class183.method3685", "class183.method3560" }, }; // @Test @@ -81,8 +82,8 @@ public class MapStaticTest ClassGroup group1 = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar")); ClassGroup group2 = JarUtil.loadJar(new File("d:/rs/07/adamin2.jar")); - Method m1 = group1.findClass("class207").findMethod("method3965"); - Method m2 = group2.findClass("class207").findMethod("method3846"); + Method m1 = group1.findClass("class183").findMethod("method3685"); + Method m2 = group2.findClass("class183").findMethod("method3560"); ParallelExecutorMapping mappings = MappingExecutorUtil.map(m1, m2); @@ -93,14 +94,18 @@ public class MapStaticTest } } + private static boolean test; + @Test public void testDeep() throws IOException { + //test = true; + ClassGroup group1 = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar")); ClassGroup group2 = JarUtil.loadJar(new File("d:/rs/07/adamin2.jar")); - Method m1 = group1.findClass("class207").findMethod("method3965"); - Method m2 = group2.findClass("class207").findMethod("method3846"); + Method m1 = group1.findClass("class183").findMethod("method3685"); + Method m2 = group2.findClass("class183").findMethod("method3560"); HashMap all = new HashMap(); map(all, new HashSet(), m1, m2); @@ -206,6 +211,8 @@ public class MapStaticTest catch (Throwable ex) { System.err.println("Error mapping " + m1 + " to " + m2); + if (test) + throw ex; return; }