711 vs 742 but not the same

This commit is contained in:
Adam
2016-01-25 13:44:08 -05:00
parent a0a2054187
commit 951a6699c8
6 changed files with 116 additions and 20 deletions

View File

@@ -33,7 +33,24 @@ public class IfACmpNe extends If
return true; return true;
} }
} }
else if (otherIc.getInstruction() instanceof IfACmpEq)
{
return true;
}
return false; return false;
} }
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other)
{
if (other.getInstruction() instanceof IfACmpEq)
{
super.mapOtherBranch(mapping, ctx, other);
}
else
{
super.map(mapping, ctx, other);
}
}
} }

View File

@@ -2,8 +2,10 @@ package net.runelite.deob.attributes.code.instructions;
import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.InstructionType;
import net.runelite.deob.attributes.code.Instructions; import net.runelite.deob.attributes.code.Instructions;
import static net.runelite.deob.attributes.code.instructions.IfICmpEq.isZero;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping; import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.InstructionContext;
import net.runelite.deob.execution.StackContext;
public class IfEq extends If0 public class IfEq extends If0
{ {
@@ -22,6 +24,14 @@ public class IfEq extends If0
{ {
return true; return true;
} }
else if (otherIc.getInstruction() instanceof IfICmpNe)
{
StackContext s1 = otherIc.getPops().get(0),
s2 = otherIc.getPops().get(1);
if (isZero(s1) || isZero(s2))
return true;
}
return false; return false;
} }
@@ -29,7 +39,7 @@ public class IfEq extends If0
@Override @Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other) 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); super.mapOtherBranch(mapping, ctx, other);
} }

View File

@@ -2,6 +2,8 @@ package net.runelite.deob.attributes.code.instructions;
import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.InstructionType;
import net.runelite.deob.attributes.code.Instructions; import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
import net.runelite.deob.execution.InstructionContext;
public class IfGt extends If0 public class IfGt extends If0
{ {
@@ -10,4 +12,30 @@ public class IfGt extends If0
super(instructions, type, pc); super(instructions, type, pc);
} }
@Override
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
if (super.isSame(thisIc, otherIc))
return true;
if (otherIc.getInstruction() instanceof IfLe)
{
return true;
}
return false;
}
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other)
{
if (other.getInstruction() instanceof IfLe)
{
super.mapOtherBranch(mapping, ctx, other);
}
else
{
super.map(mapping, ctx, other);
}
}
} }

View File

@@ -14,7 +14,7 @@ public class IfICmpEq extends If
super(instructions, type, pc); super(instructions, type, pc);
} }
private static boolean isZero(StackContext s) static boolean isZero(StackContext s)
{ {
if (s.getPushed().getInstruction() instanceof PushConstantInstruction) if (s.getPushed().getInstruction() instanceof PushConstantInstruction)
{ {

View File

@@ -2,6 +2,7 @@ package net.runelite.deob.attributes.code.instructions;
import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.InstructionType;
import net.runelite.deob.attributes.code.Instructions; import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.InstructionContext;
import net.runelite.deob.execution.StackContext; import net.runelite.deob.execution.StackContext;
@@ -18,7 +19,7 @@ public class IfNull extends If0
if (super.isSame(thisIc, otherIc)) if (super.isSame(thisIc, otherIc))
return true; return true;
if (otherIc.getInstruction() instanceof IfACmpEq) if (otherIc.getInstruction() instanceof IfACmpEq || otherIc.getInstruction() instanceof IfACmpNe)
{ {
StackContext s1 = otherIc.getPops().get(0), StackContext s1 = otherIc.getPops().get(0),
s2 = otherIc.getPops().get(1); s2 = otherIc.getPops().get(1);
@@ -32,7 +33,24 @@ public class IfNull extends If0
return true; return true;
} }
} }
else if (otherIc.getInstruction() instanceof IfNull)
{
return true;
}
return false; return false;
} }
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other)
{
if (other.getInstruction() instanceof IfACmpNe || other.getInstruction() instanceof IfNull)
{
super.mapOtherBranch(mapping, ctx, other);
}
else
{
super.map(mapping, ctx, other);
}
}
} }

View File

@@ -57,23 +57,23 @@ public class MapStaticTest
// } // }
//@Test //@Test
public void testAll() throws IOException // public void testAll() throws IOException
{ // {
ClassGroup group1 = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar")); // ClassGroup group1 = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar"));
ClassGroup group2 = JarUtil.loadJar(new File("d:/rs/07/adamin2.jar")); // ClassGroup group2 = JarUtil.loadJar(new File("d:/rs/07/adamin2.jar"));
//
// for (String[] s : methods)
// {
// String[] one = s[0].split("\\."), two = s[1].split("\\.");
//
// Method m1 = group1.findClass(one[0]).findMethod(one[1]);
// Method m2 = group2.findClass(two[0]).findMethod(two[1]);
//
// ParallelExecutorMapping mappings = MappingExecutorUtil.map(m1, m2);
// }
// }
for (String[] s : methods) //@Test
{
String[] one = s[0].split("\\."), two = s[1].split("\\.");
Method m1 = group1.findClass(one[0]).findMethod(one[1]);
Method m2 = group2.findClass(two[0]).findMethod(two[1]);
ParallelExecutorMapping mappings = MappingExecutorUtil.map(m1, m2);
}
}
@Test
public void test() throws IOException public void test() throws IOException
{ {
ClassGroup group1 = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar")); ClassGroup group1 = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar"));
@@ -91,6 +91,19 @@ public class MapStaticTest
} }
} }
@Test
public void testDeep() throws IOException
{
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("class72").findMethod("run");
Method m2 = group2.findClass("class72").findMethod("run");
HashMap<Object, Object> all = new HashMap();
map(all, new HashSet(), m1, m2);
}
//@Test //@Test
public void testAllMap() throws Exception public void testAllMap() throws Exception
{ {
@@ -160,6 +173,11 @@ public class MapStaticTest
return; return;
all.put(m1, m2); all.put(m1, m2);
assert (m1.getCode() == null) == (m2.getCode() == null);
if (m1.getCode() == null)
return;
ParallelExecutorMapping mappings; ParallelExecutorMapping mappings;
try try
{ {
@@ -174,7 +192,12 @@ public class MapStaticTest
for (Entry<Object, Object> e : mappings.getMap().entrySet()) for (Entry<Object, Object> e : mappings.getMap().entrySet())
{ {
if (e.getKey() instanceof Method) if (e.getKey() instanceof Method)
map(all, invalid, (Method) e.getKey(), (Method) e.getValue()); {
Method n1 = (Method) e.getKey(),
n2 = (Method) e.getValue();
map(all, invalid, n1, n2);
}
else else
all.put(e.getKey(), e.getValue()); all.put(e.getKey(), e.getValue());
//assert all //assert all