More multi fixes. Spinning is back with multiplication deobfuscator..

This commit is contained in:
Adam
2015-09-25 14:17:15 -04:00
parent 5be7604ee9
commit 5cc12d0228
4 changed files with 26 additions and 18 deletions

View File

@@ -84,9 +84,9 @@ public class Deob
//new ModArith().run(group); //new ModArith().run(group);
//new MultiplicationDeobfuscator().run(group); //new MultiplicationDeobfuscator().run(group); // this causes spinning?
//new MultiplyOneDeobfuscator().run(group); new MultiplyOneDeobfuscator().run(group);
new MultiplyZeroDeobfuscator().run(group); new MultiplyZeroDeobfuscator().run(group);

View File

@@ -10,6 +10,7 @@ import net.runelite.deob.attributes.code.Instruction;
import net.runelite.deob.attributes.code.Instructions; import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction; import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
import net.runelite.deob.attributes.code.instructions.IMul; import net.runelite.deob.attributes.code.instructions.IMul;
import net.runelite.deob.attributes.code.instructions.SiPush;
import net.runelite.deob.execution.Execution; import net.runelite.deob.execution.Execution;
import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.Frame;
import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.InstructionContext;
@@ -57,6 +58,21 @@ public class MultiplicationDeobfuscator implements Deobfuscator
return l; return l;
} }
private boolean isOnlyPath(Execution execution, Frame frame, InstructionContext ctx)
{
for (Frame f : execution.processedFrames)
if (f.getMethod() == frame.getMethod())
for (InstructionContext i : f.getInstructions())
if (i.getInstruction() == ctx.getInstruction())
{
if (!i.equals(ctx))
{
return false;
}
}
return true;
}
private int runOnce() private int runOnce()
{ {
group.buildClassGraph(); group.buildClassGraph();
@@ -77,7 +93,7 @@ public class MultiplicationDeobfuscator implements Deobfuscator
if (!(instruction instanceof IMul)) if (!(instruction instanceof IMul))
continue; continue;
List<InstructionContext> ins = getConstants(ictx); List<InstructionContext> ins = getConstants(ictx);
if (ins.size() == 1) if (ins.size() == 1)
@@ -91,6 +107,10 @@ public class MultiplicationDeobfuscator implements Deobfuscator
} }
} }
// there can only be one path to here, or else combinging would change code logic
if (!isOnlyPath(e, frame, ictx))
continue;
int result = 1; int result = 1;
// calculate result // calculate result

View File

@@ -7,6 +7,7 @@ import net.runelite.deob.attributes.code.Instruction;
import net.runelite.deob.attributes.code.Instructions; import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction; import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
import net.runelite.deob.attributes.code.instructions.IMul; import net.runelite.deob.attributes.code.instructions.IMul;
import net.runelite.deob.attributes.code.instructions.NOP;
import net.runelite.deob.execution.Execution; import net.runelite.deob.execution.Execution;
import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.Frame;
import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.InstructionContext;
@@ -58,7 +59,8 @@ public class MultiplyOneDeobfuscator implements Deobfuscator
continue; continue;
ictx.removeStack(removeIdx); ictx.removeStack(removeIdx);
ins.remove(ictx.getInstruction()); ins.replace(ictx.getInstruction(), new NOP(ins));
//ins.remove(ictx.getInstruction());
++count; ++count;
} }

View File

@@ -32,12 +32,6 @@ public class MultiplyZeroDeobfuscator implements Deobfuscator
Instruction instruction = ictx.getInstruction(); Instruction instruction = ictx.getInstruction();
Instructions ins = instruction.getInstructions(); Instructions ins = instruction.getInstructions();
if (frame.getMethod().getName().equals("method3678"))
//if (ins.getCode().getAttributes().getMethod().getName().equals("method3678"))
{
int i = 5;
}
if (!(instruction instanceof IMul)) if (!(instruction instanceof IMul))
continue; continue;
@@ -57,10 +51,6 @@ public class MultiplyZeroDeobfuscator implements Deobfuscator
if (value == 0) if (value == 0)
remove = true; remove = true;
if (value == -1408052237)
{
int i = 5;
}
} }
if (itwo instanceof PushConstantInstruction) if (itwo instanceof PushConstantInstruction)
{ {
@@ -69,10 +59,6 @@ public class MultiplyZeroDeobfuscator implements Deobfuscator
if (value == 0) if (value == 0)
remove = true; remove = true;
if (value == -1408052237)
{
int i = 5;
}
} }
if (remove == false) if (remove == false)