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 58df149994..8c89485512 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 @@ -2,6 +2,9 @@ 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.execution.InstructionContext; +import net.runelite.deob.execution.StackContext; public class IfICmpNe extends If { @@ -10,4 +13,36 @@ public class IfICmpNe extends If super(instructions, type, pc); } + private static boolean isZero(StackContext s) + { + if (s.getPushed().getInstruction() instanceof PushConstantInstruction) + { + PushConstantInstruction pc = (PushConstantInstruction) s.getPushed().getInstruction(); + Object o = pc.getConstant().getObject(); + + if (o instanceof Integer && (int) o == 0) + return true; + } + + return false; + } + + @Override + public boolean isSame(InstructionContext thisIc, InstructionContext otherIc) + { + if (super.isSame(thisIc, otherIc)) + return true; + + // check for other being ifne and this has a constant 0 + if (otherIc.getInstruction() instanceof IfNe) + { + StackContext s1 = thisIc.getPops().get(0), + s2 = thisIc.getPops().get(1); + + if (isZero(s1) || isZero(s2)) + return true; + } + + return false; + } } 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 aa4063f925..efd3183fb0 100644 --- a/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java +++ b/src/test/java/net/runelite/deob/deobfuscators/rename/MapStaticTest.java @@ -22,6 +22,8 @@ public class MapStaticTest { "client.method585", "class44.method930" }, { "class222.method4086", "class222.method3957" }, { "class40.method851", "class40.method803" }, + { "class55.method1187", "class55.method1140" }, + { "class107.method2427", "class107.method2344" }, }; // @Test @@ -66,8 +68,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("class55").findMethod("method1187"); - Method m2 = group2.findClass("class55").findMethod("method1140"); + Method m1 = group1.findClass("class107").findMethod("method2427"); + Method m2 = group2.findClass("class107").findMethod("method2344"); ParallelExecutorMapping mappings = MappingExecutorUtil.map(m1, m2); }