beginning work on removing *1
This commit is contained in:
@@ -27,15 +27,9 @@ import net.runelite.deob.deobfuscators.UnusedMethods;
|
||||
import net.runelite.deob.deobfuscators.UnusedParameters;
|
||||
import net.runelite.deob.deobfuscators.arithmetic.ModArith;
|
||||
import net.runelite.deob.deobfuscators.arithmetic.MultiplicationDeobfuscator;
|
||||
import net.runelite.deob.deobfuscators.arithmetic.MultiplyOneDeobfuscator;
|
||||
import net.runelite.deob.execution.Execution;
|
||||
|
||||
//move static methods
|
||||
//move static fields
|
||||
//math deob
|
||||
//remove dead classes
|
||||
//inline constant fields
|
||||
//compare old and new
|
||||
|
||||
public class Deob
|
||||
{
|
||||
public static void main(String[] args) throws IOException
|
||||
@@ -89,7 +83,9 @@ public class Deob
|
||||
|
||||
//new ModArith().run(group);
|
||||
|
||||
new MultiplicationDeobfuscator().run(group);
|
||||
//new MultiplicationDeobfuscator().run(group);
|
||||
|
||||
new MultiplyOneDeobfuscator().run(group);
|
||||
|
||||
saveJar(group, args[1]);
|
||||
|
||||
|
||||
@@ -115,33 +115,6 @@ public class MultiplicationDeobfuscator implements Deobfuscator
|
||||
|
||||
for (InstructionContext i : ins)
|
||||
done.add(i.getInstruction());
|
||||
|
||||
// Instructions ins = ictx.getInstruction().getInstructions();
|
||||
// List<Instruction> ilist = ins.getInstructions();
|
||||
//
|
||||
// if (!ilist.contains(ictx.getInstruction()))
|
||||
// continue; // already done
|
||||
//
|
||||
// StackContext one = ictx.getPops().get(0);
|
||||
// StackContext two = ictx.getPops().get(1);
|
||||
//
|
||||
// if (one.getPushed().getInstruction() instanceof PushConstantInstruction
|
||||
// && two.getPushed().getInstruction() instanceof PushConstantInstruction)
|
||||
// {
|
||||
// PushConstantInstruction pci1 = (PushConstantInstruction) one.getPushed().getInstruction(),
|
||||
// pci2 = (PushConstantInstruction) two.getPushed().getInstruction();
|
||||
//
|
||||
// int i1 = (int) pci1.getConstant().getObject(),
|
||||
// i2 = (int) pci2.getConstant().getObject();
|
||||
//
|
||||
// int result = i1 * i2;
|
||||
//
|
||||
// ictx.removeStack(1);
|
||||
// ictx.removeStack(0);
|
||||
//
|
||||
// ins.replace(ictx.getInstruction(), new LDC_W(ins, new net.runelite.deob.pool.Integer(result)));
|
||||
// ++count;
|
||||
// }
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package net.runelite.deob.deobfuscators.arithmetic;
|
||||
|
||||
import java.util.List;
|
||||
import net.runelite.deob.ClassGroup;
|
||||
import net.runelite.deob.Deobfuscator;
|
||||
import net.runelite.deob.attributes.code.Instruction;
|
||||
import net.runelite.deob.attributes.code.Instructions;
|
||||
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
|
||||
import net.runelite.deob.attributes.code.instructions.IMul;
|
||||
import net.runelite.deob.execution.Execution;
|
||||
import net.runelite.deob.execution.Frame;
|
||||
import net.runelite.deob.execution.InstructionContext;
|
||||
import net.runelite.deob.execution.StackContext;
|
||||
|
||||
public class MultiplyOneDeobfuscator implements Deobfuscator
|
||||
{
|
||||
@Override
|
||||
public void run(ClassGroup group)
|
||||
{
|
||||
Execution e = new Execution(group);
|
||||
e.populateInitialMethods();
|
||||
e.run();
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (Frame frame : e.processedFrames)
|
||||
for (InstructionContext ictx : frame.getInstructions())
|
||||
{
|
||||
Instruction instruction = ictx.getInstruction();
|
||||
|
||||
if (!(instruction instanceof IMul))
|
||||
continue;
|
||||
|
||||
Instructions ins = ictx.getInstruction().getInstructions();
|
||||
List<Instruction> ilist = ins.getInstructions();
|
||||
|
||||
if (!ilist.contains(ictx.getInstruction()))
|
||||
continue; // already done
|
||||
|
||||
StackContext one = ictx.getPops().get(0);
|
||||
StackContext two = ictx.getPops().get(1);
|
||||
|
||||
int removeIdx = -1;
|
||||
if (one.getPushed().getInstruction() instanceof PushConstantInstruction
|
||||
&& (int) ((PushConstantInstruction) one.getPushed().getInstruction()).getConstant().getObject() == 1)
|
||||
{
|
||||
removeIdx = 0;
|
||||
}
|
||||
else if (two.getPushed().getInstruction() instanceof PushConstantInstruction
|
||||
&& (int) ((PushConstantInstruction) two.getPushed().getInstruction()).getConstant().getObject() == 1)
|
||||
{
|
||||
removeIdx = 1;
|
||||
}
|
||||
|
||||
if (removeIdx == -1)
|
||||
continue;
|
||||
|
||||
ictx.removeStack(removeIdx);
|
||||
ins.remove(ictx.getInstruction());
|
||||
|
||||
++count;
|
||||
}
|
||||
|
||||
System.out.println("Removed " + count + " multiplications");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user