1/0 works once again, maybe.

This commit is contained in:
Adam
2015-10-22 11:01:43 -04:00
parent 2f5f9861ef
commit 5f6b01f4a0
4 changed files with 71 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ import org.junit.Test;
public class MultiplyOneDeobfuscatorTest
{
@Test
public void test()
public void testDir()
{
ClassGroup group = ClassGroupFactory.generateGroup();
Code code = group.findClass("test").findMethod("func").getCode();
@@ -77,4 +77,58 @@ public class MultiplyOneDeobfuscatorTest
Assert.assertTrue(one.getInstructions() != null);
}
@Test
public void test()
{
ClassGroup group = ClassGroupFactory.generateGroup();
Code code = group.findClass("test").findMethod("func").getCode();
Instructions ins = code.getInstructions();
code.setMaxStack(2);
// vars[0] = 3
Instruction[] prepareVariables = {
new IConst_3(ins),
new IStore_0(ins)
};
for (Instruction i : prepareVariables)
ins.addInstruction(i);
NOP label = new NOP(ins),
label2 = new NOP(ins);
IConst_1 one = new IConst_1(ins);
IMul mul = new IMul(ins);
Instruction body[] = {
new SiPush(ins, (short) 256),
new ILoad(ins, 0),
new If0(ins, label),
label,
one,
label2,
mul,
new VReturn(ins)
};
for (Instruction i : body)
ins.addInstruction(i);
// check execution runs ok
Execution e = new Execution(group);
e.populateInitialMethods();
e.run();
Deobfuscator d = new MultiplyOneDeobfuscator();
d.run(group);
Assert.assertTrue(one.getInstructions() == null);
Assert.assertTrue(mul.getInstructions() == null);
}
}