save
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package net.runelite.deob.deobfuscators.arithmetic;
|
package net.runelite.deob.deobfuscators.arithmetic;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.deob.ClassGroup;
|
import net.runelite.deob.ClassGroup;
|
||||||
import net.runelite.deob.Deobfuscator;
|
import net.runelite.deob.Deobfuscator;
|
||||||
@@ -17,6 +18,8 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
|||||||
{
|
{
|
||||||
private ClassGroup group;
|
private ClassGroup group;
|
||||||
|
|
||||||
|
// find a chain of multiplication instructions, evaluate and set one to the constant and the others to 1
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ClassGroup group)
|
public void run(ClassGroup group)
|
||||||
{
|
{
|
||||||
@@ -27,6 +30,16 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
|||||||
System.out.println("Simplified " + i + " multiplication");
|
System.out.println("Simplified " + i + " multiplication");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<InstructionContext> getConstants(InstructionContext ctx)
|
||||||
|
{
|
||||||
|
List<InstructionContext> l = new ArrayList<>();
|
||||||
|
|
||||||
|
for (StackContext sctx : ctx.getPops())
|
||||||
|
{
|
||||||
|
InstructionContext i = sctx.getPushed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int runOnce()
|
private int runOnce()
|
||||||
{
|
{
|
||||||
Execution e = new Execution(group);
|
Execution e = new Execution(group);
|
||||||
@@ -41,32 +54,32 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
|||||||
if (!(ictx.getInstruction() instanceof IMul))
|
if (!(ictx.getInstruction() instanceof IMul))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Instructions ins = ictx.getInstruction().getInstructions();
|
// Instructions ins = ictx.getInstruction().getInstructions();
|
||||||
List<Instruction> ilist = ins.getInstructions();
|
// List<Instruction> ilist = ins.getInstructions();
|
||||||
|
//
|
||||||
if (!ilist.contains(ictx.getInstruction()))
|
// if (!ilist.contains(ictx.getInstruction()))
|
||||||
continue; // already done
|
// continue; // already done
|
||||||
|
//
|
||||||
StackContext one = ictx.getPops().get(0);
|
// StackContext one = ictx.getPops().get(0);
|
||||||
StackContext two = ictx.getPops().get(1);
|
// StackContext two = ictx.getPops().get(1);
|
||||||
|
//
|
||||||
if (one.getPushed().getInstruction() instanceof PushConstantInstruction
|
// if (one.getPushed().getInstruction() instanceof PushConstantInstruction
|
||||||
&& two.getPushed().getInstruction() instanceof PushConstantInstruction)
|
// && two.getPushed().getInstruction() instanceof PushConstantInstruction)
|
||||||
{
|
// {
|
||||||
PushConstantInstruction pci1 = (PushConstantInstruction) one.getPushed().getInstruction(),
|
// PushConstantInstruction pci1 = (PushConstantInstruction) one.getPushed().getInstruction(),
|
||||||
pci2 = (PushConstantInstruction) two.getPushed().getInstruction();
|
// pci2 = (PushConstantInstruction) two.getPushed().getInstruction();
|
||||||
|
//
|
||||||
int i1 = (int) pci1.getConstant().getObject(),
|
// int i1 = (int) pci1.getConstant().getObject(),
|
||||||
i2 = (int) pci2.getConstant().getObject();
|
// i2 = (int) pci2.getConstant().getObject();
|
||||||
|
//
|
||||||
int result = i1 * i2;
|
// int result = i1 * i2;
|
||||||
|
//
|
||||||
ictx.removeStack(1);
|
// ictx.removeStack(1);
|
||||||
ictx.removeStack(0);
|
// ictx.removeStack(0);
|
||||||
|
//
|
||||||
ins.replace(ictx.getInstruction(), new LDC_W(ins, new net.runelite.deob.pool.Integer(result)));
|
// ins.replace(ictx.getInstruction(), new LDC_W(ins, new net.runelite.deob.pool.Integer(result)));
|
||||||
++count;
|
// ++count;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
Reference in New Issue
Block a user