Use less memory in constant param. Seems to run with -Xmx512m
This commit is contained in:
@@ -28,57 +28,57 @@ public class Deob
|
|||||||
|
|
||||||
ClassGroup group = JarUtil.loadJar(new File(args[0]));
|
ClassGroup group = JarUtil.loadJar(new File(args[0]));
|
||||||
|
|
||||||
// run(group, new RenameUnique());
|
run(group, new RenameUnique());
|
||||||
//
|
|
||||||
// // remove except RuntimeException
|
// remove except RuntimeException
|
||||||
// run(group, new RuntimeExceptions());
|
run(group, new RuntimeExceptions());
|
||||||
//
|
|
||||||
// // remove unused methods
|
// remove unused methods
|
||||||
// run(group, new UnreachedCode());
|
run(group, new UnreachedCode());
|
||||||
// run(group, new UnusedMethods());
|
run(group, new UnusedMethods());
|
||||||
//
|
|
||||||
// // remove illegal state exceptions, frees up some parameters
|
// remove illegal state exceptions, frees up some parameters
|
||||||
// run(group, new IllegalStateExceptions());
|
run(group, new IllegalStateExceptions());
|
||||||
//
|
|
||||||
// // remove constant logically dead parameters
|
// remove constant logically dead parameters
|
||||||
// run(group, new ConstantParameter());
|
run(group, new ConstantParameter());
|
||||||
//
|
|
||||||
// // remove unhit blocks
|
// remove unhit blocks
|
||||||
// run(group, new UnreachedCode());
|
run(group, new UnreachedCode());
|
||||||
// run(group, new UnusedMethods());
|
run(group, new UnusedMethods());
|
||||||
|
|
||||||
// remove unused parameters
|
// remove unused parameters
|
||||||
run(group, new UnusedParameters());
|
run(group, new UnusedParameters());
|
||||||
//
|
|
||||||
// // remove unused fields
|
// remove unused fields
|
||||||
// run(group, new UnusedFields());
|
run(group, new UnusedFields());
|
||||||
//
|
|
||||||
// // remove unused methods, again?
|
// remove unused methods, again?
|
||||||
// run(group, new UnusedMethods());
|
run(group, new UnusedMethods());
|
||||||
//
|
|
||||||
// run(group, new FieldInliner());
|
run(group, new FieldInliner());
|
||||||
//
|
|
||||||
// run(group, new UnusedClass());
|
run(group, new UnusedClass());
|
||||||
//
|
|
||||||
// ModArith mod = new ModArith();
|
ModArith mod = new ModArith();
|
||||||
// mod.run(group);
|
mod.run(group);
|
||||||
//
|
|
||||||
// int last = -1, cur;
|
int last = -1, cur;
|
||||||
// while ((cur = mod.runOnce()) > 0)
|
while ((cur = mod.runOnce()) > 0)
|
||||||
// {
|
{
|
||||||
// new MultiplicationDeobfuscator().run(group);
|
new MultiplicationDeobfuscator().run(group);
|
||||||
//
|
|
||||||
// new MultiplyOneDeobfuscator().run(group);
|
new MultiplyOneDeobfuscator().run(group);
|
||||||
//
|
|
||||||
// new MultiplyZeroDeobfuscator().run(group);
|
new MultiplyZeroDeobfuscator().run(group);
|
||||||
//
|
|
||||||
// if (last == cur)
|
if (last == cur)
|
||||||
// break;
|
break;
|
||||||
//
|
|
||||||
// last = cur;
|
last = cur;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// mod.annotateEncryption();
|
mod.annotateEncryption();
|
||||||
|
|
||||||
JarUtil.saveJar(group, new File(args[1]));
|
JarUtil.saveJar(group, new File(args[1]));
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import net.runelite.asm.attributes.Annotations;
|
|||||||
import net.runelite.asm.attributes.Attributes;
|
import net.runelite.asm.attributes.Attributes;
|
||||||
import net.runelite.asm.attributes.annotation.Annotation;
|
import net.runelite.asm.attributes.annotation.Annotation;
|
||||||
import net.runelite.asm.attributes.annotation.Element;
|
import net.runelite.asm.attributes.annotation.Element;
|
||||||
|
import net.runelite.asm.execution.MethodContext;
|
||||||
import net.runelite.asm.signature.Type;
|
import net.runelite.asm.signature.Type;
|
||||||
import org.apache.commons.collections4.map.MultiValueMap;
|
import org.apache.commons.collections4.map.MultiValueMap;
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ class ConstantMethodParameter
|
|||||||
public int paramIndex;
|
public int paramIndex;
|
||||||
public int lvtIndex;
|
public int lvtIndex;
|
||||||
public Object value;
|
public Object value;
|
||||||
List<InstructionContext> operations = new ArrayList<>();
|
List<Instruction> operations = new ArrayList<>();
|
||||||
Boolean result;
|
Boolean result;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -269,12 +270,17 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parameter.operations.add(ins);
|
parameter.operations.add(ins.getInstruction());
|
||||||
parameter.result = result;
|
parameter.result = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buildContexts(InstructionContext context)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
private boolean doLogicalComparison(Object value, ComparisonInstruction comparison, Object otherValue)
|
private boolean doLogicalComparison(Object value, ComparisonInstruction comparison, Object otherValue)
|
||||||
{
|
{
|
||||||
Instruction ins = (Instruction) comparison;
|
Instruction ins = (Instruction) comparison;
|
||||||
@@ -314,16 +320,22 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove logically dead comparisons
|
// remove logically dead comparisons
|
||||||
private int removeDeadOperations()
|
private int removeDeadOperations(MethodContext mctx)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (ConstantMethodParameter cmp : parameters)
|
for (ConstantMethodParameter cmp : parameters)
|
||||||
{
|
{
|
||||||
|
if (!cmp.methods.contains(mctx.getMethod()))
|
||||||
|
continue;
|
||||||
|
|
||||||
annotateObfuscatedSignature(cmp);
|
annotateObfuscatedSignature(cmp);
|
||||||
|
|
||||||
for (InstructionContext ctx : cmp.operations) // comparisons
|
for (Instruction ins : cmp.operations) // comparisons
|
||||||
{
|
{
|
||||||
Instruction ins = ctx.getInstruction();
|
if (ins.getInstructions() == null || ins.getInstructions().getCode().getAttributes().getMethod() != mctx.getMethod())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
InstructionContext ctx = mctx.getInstructonContexts(ins).toArray(new InstructionContext[0])[0];
|
||||||
boolean branch = cmp.result; // branch that is always taken
|
boolean branch = cmp.result; // branch that is always taken
|
||||||
|
|
||||||
if (ins.getInstructions() == null)
|
if (ins.getInstructions() == null)
|
||||||
@@ -403,17 +415,22 @@ public class ConstantParameter implements Deobfuscator
|
|||||||
annotation.addElement(element);
|
annotation.addElement(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int count;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ClassGroup group)
|
public void run(ClassGroup group)
|
||||||
{
|
{
|
||||||
Execution execution = new Execution(group);
|
Execution execution = new Execution(group);
|
||||||
execution.addExecutionVisitor((i) -> findParameters(i));
|
execution.addExecutionVisitor(i -> findParameters(i));
|
||||||
execution.addExecutionVisitor((i) -> findDeadParameters(i));
|
execution.addExecutionVisitor(i -> findDeadParameters(i));
|
||||||
execution.populateInitialMethods();
|
execution.populateInitialMethods();
|
||||||
execution.run();
|
execution.run();
|
||||||
|
|
||||||
int count = removeDeadOperations();
|
execution = new Execution(group);
|
||||||
|
execution.addMethodContextVisitor(m -> count += removeDeadOperations(m));
|
||||||
|
execution.populateInitialMethods();
|
||||||
|
execution.run();
|
||||||
|
|
||||||
System.out.println("Removed " + count + " logically dead conditional jumps");
|
System.out.println("Removed " + count + " logically dead conditional jumps");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user