Optimize imports
This commit is contained in:
@@ -28,7 +28,6 @@ package net.runelite.asm.attributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.runelite.asm.Type;
|
||||
import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
|
||||
@@ -40,7 +40,6 @@ import net.runelite.asm.execution.InstructionContext;
|
||||
import net.runelite.asm.execution.Stack;
|
||||
import net.runelite.asm.execution.StackContext;
|
||||
import static net.runelite.asm.execution.StaticStep.stepInto;
|
||||
|
||||
import net.runelite.asm.execution.Value;
|
||||
import net.runelite.asm.pool.Method;
|
||||
import net.runelite.asm.signature.Signature;
|
||||
|
||||
@@ -25,11 +25,10 @@
|
||||
|
||||
package net.runelite.asm.execution;
|
||||
|
||||
import net.runelite.asm.Type;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.runelite.asm.Method;
|
||||
import net.runelite.asm.Type;
|
||||
|
||||
public class Stack
|
||||
{
|
||||
@@ -40,13 +39,13 @@ public class Stack
|
||||
{
|
||||
stack = new StackContext[sz * 2]; // XXX FIXME
|
||||
}
|
||||
|
||||
|
||||
public Stack(Stack other)
|
||||
{
|
||||
this.size = other.size;
|
||||
this.stack = other.stack.clone();
|
||||
}
|
||||
|
||||
|
||||
private void printStack(StackContext ctx, int level)
|
||||
{
|
||||
for (int i = 0; i < level; ++i)
|
||||
@@ -66,7 +65,7 @@ public class Stack
|
||||
printStack(stack[c], 0);
|
||||
throw new RuntimeException("Stack overflow");
|
||||
}
|
||||
|
||||
|
||||
assert !i.getType().equals(Type.VOID);
|
||||
|
||||
stack[size] = i;
|
||||
@@ -80,12 +79,12 @@ public class Stack
|
||||
|
||||
return stack[--size];
|
||||
}
|
||||
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
public List<StackContext> getStack()
|
||||
{
|
||||
return Arrays.asList(stack);
|
||||
|
||||
@@ -25,10 +25,9 @@
|
||||
|
||||
package net.runelite.asm.execution;
|
||||
|
||||
import net.runelite.asm.Type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.runelite.asm.Type;
|
||||
|
||||
public class VariableContext
|
||||
{
|
||||
@@ -46,13 +45,13 @@ public class VariableContext
|
||||
type = ctx.getType();
|
||||
value = ctx.getValue();
|
||||
}
|
||||
|
||||
|
||||
public VariableContext(Type type) // for entrypoints
|
||||
{
|
||||
this.type = type;
|
||||
value = Value.UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
public VariableContext(InstructionContext i, VariableContext other)
|
||||
{
|
||||
ic = i;
|
||||
@@ -60,24 +59,24 @@ public class VariableContext
|
||||
type = other.type;
|
||||
value = other.value;
|
||||
}
|
||||
|
||||
|
||||
public VariableContext(InstructionContext i, Type type, Value value)
|
||||
{
|
||||
ic = i;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public StackContext getStackContext()
|
||||
{
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
public InstructionContext getInstructionWhichStored()
|
||||
{
|
||||
return ic;
|
||||
}
|
||||
|
||||
|
||||
public Type getType()
|
||||
{
|
||||
return type;
|
||||
@@ -87,7 +86,7 @@ public class VariableContext
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public void addRead(InstructionContext ctx)
|
||||
{
|
||||
if (!read.contains(ctx))
|
||||
@@ -103,7 +102,7 @@ public class VariableContext
|
||||
{
|
||||
return isParameter;
|
||||
}
|
||||
|
||||
|
||||
public VariableContext markParameter()
|
||||
{
|
||||
isParameter = true;
|
||||
|
||||
@@ -25,9 +25,8 @@
|
||||
|
||||
package net.runelite.asm.pool;
|
||||
|
||||
import net.runelite.asm.Type;
|
||||
|
||||
import java.util.Objects;
|
||||
import net.runelite.asm.Type;
|
||||
|
||||
public class Field
|
||||
{
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
*/
|
||||
package net.runelite.asm.signature;
|
||||
|
||||
import net.runelite.asm.Type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -33,6 +31,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import net.runelite.asm.Type;
|
||||
|
||||
public class Signature
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.deob;
|
||||
|
||||
import java.util.List;
|
||||
import net.runelite.asm.ClassFile;
|
||||
import net.runelite.asm.Field;
|
||||
import net.runelite.asm.Method;
|
||||
@@ -33,8 +34,6 @@ import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
import net.runelite.asm.signature.Signature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeobAnnotations
|
||||
{
|
||||
public static final Type OBFUSCATED_NAME = new Type("Lnet/runelite/mapping/ObfuscatedName;");
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
package net.runelite.deob.deobfuscators;
|
||||
|
||||
import java.util.List;
|
||||
import net.runelite.asm.ClassFile;
|
||||
import net.runelite.asm.ClassGroup;
|
||||
import net.runelite.asm.Field;
|
||||
@@ -35,31 +36,29 @@ import net.runelite.deob.DeobAnnotations;
|
||||
import net.runelite.deob.Deobfuscator;
|
||||
import net.runelite.deob.util.NameMappings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RenameUnique implements Deobfuscator
|
||||
{
|
||||
private Renamer renamer;
|
||||
|
||||
|
||||
private void generateClassNames(NameMappings map, ClassGroup group)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
||||
for (ClassFile cf : group.getClasses())
|
||||
{
|
||||
if (cf.getName().length() > Deob.OBFUSCATED_NAME_MAX_LEN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
map.map(cf.getPoolClass(), "class" + i++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void generateFieldNames(NameMappings map, ClassGroup group)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
||||
for (ClassFile cf : group.getClasses())
|
||||
for (Field field : cf.getFields())
|
||||
{
|
||||
@@ -67,7 +66,7 @@ public class RenameUnique implements Deobfuscator
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
map.map(field.getPoolField(), "field" + i++);
|
||||
}
|
||||
}
|
||||
@@ -75,7 +74,7 @@ public class RenameUnique implements Deobfuscator
|
||||
private void generateMethodNames(NameMappings map, ClassGroup group)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
||||
for (ClassFile cf : group.getClasses())
|
||||
for (Method method : cf.getMethods())
|
||||
{
|
||||
@@ -83,16 +82,16 @@ public class RenameUnique implements Deobfuscator
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
List<Method> virtualMethods = VirtualMethods.getVirtualMethods(method);
|
||||
assert !virtualMethods.isEmpty();
|
||||
|
||||
|
||||
String name;
|
||||
if (virtualMethods.size() == 1)
|
||||
name = "method" + i++;
|
||||
else
|
||||
name = "vmethod" + i++;
|
||||
|
||||
|
||||
for (Method m : virtualMethods)
|
||||
map.map(m.getPoolMethod(), name);
|
||||
}
|
||||
@@ -103,13 +102,13 @@ public class RenameUnique implements Deobfuscator
|
||||
{
|
||||
group.buildClassGraph();
|
||||
group.lookup();
|
||||
|
||||
|
||||
NameMappings mappings = new NameMappings();
|
||||
|
||||
|
||||
this.generateClassNames(mappings, group);
|
||||
this.generateFieldNames(mappings, group);
|
||||
this.generateMethodNames(mappings, group);
|
||||
|
||||
|
||||
renamer = new Renamer(mappings);
|
||||
renamer.run(group);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
package net.runelite.deob.deobfuscators.packethandler;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.runelite.asm.Type;
|
||||
import net.runelite.asm.attributes.code.Instruction;
|
||||
import net.runelite.asm.execution.InstructionContext;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.runelite.gamepack;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
Reference in New Issue
Block a user