Deob changes for injector and general usability
This commit is contained in:
@@ -95,7 +95,7 @@ public class DeobAnnotations
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return (Number) an.getElement().getValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -193,6 +193,7 @@ public class Renamer implements Deobfuscator
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void run(ClassGroup group)
|
||||
{
|
||||
group.buildClassGraph();
|
||||
|
||||
@@ -37,6 +37,7 @@ import net.runelite.asm.Method;
|
||||
import net.runelite.asm.attributes.Annotations;
|
||||
import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
import net.runelite.asm.attributes.annotation.SimpleElement;
|
||||
import net.runelite.asm.attributes.code.Instruction;
|
||||
import net.runelite.asm.attributes.code.InstructionType;
|
||||
import net.runelite.asm.attributes.code.Instructions;
|
||||
@@ -113,7 +114,6 @@ public class ConstantParameter implements Deobfuscator
|
||||
|
||||
List<StackContext> pops = invokeCtx.getPops();
|
||||
|
||||
outer:
|
||||
// object is popped first, then param 1, 2, 3, etc. double and long take two slots.
|
||||
for (int lvtOffset = offset, parameterIndex = 0;
|
||||
parameterIndex < method.getDescriptor().size();
|
||||
@@ -451,9 +451,7 @@ public class ConstantParameter implements Deobfuscator
|
||||
}
|
||||
|
||||
// Add garbage value
|
||||
Element element = new Element(obfuscatedSignature);
|
||||
element.setName("garbageValue");
|
||||
element.setValue(value.toString());
|
||||
Element element = new SimpleElement("garbageValue", value.toString());
|
||||
obfuscatedSignature.addElement(element);
|
||||
}
|
||||
}
|
||||
@@ -464,12 +462,12 @@ public class ConstantParameter implements Deobfuscator
|
||||
public void run(ClassGroup group)
|
||||
{
|
||||
Execution execution = new Execution(group);
|
||||
execution.addExecutionVisitor(i -> findParameters(i));
|
||||
execution.addExecutionVisitor(this::findParameters);
|
||||
execution.populateInitialMethods();
|
||||
execution.run();
|
||||
|
||||
execution = new Execution(group);
|
||||
execution.addMethodContextVisitor(mc -> findDeadParameters(mc));
|
||||
execution.addMethodContextVisitor(this::findDeadParameters);
|
||||
execution.populateInitialMethods();
|
||||
execution.run();
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.runelite.asm.Method;
|
||||
import net.runelite.asm.attributes.Annotations;
|
||||
import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
import net.runelite.asm.attributes.annotation.SimpleElement;
|
||||
import net.runelite.deob.DeobAnnotations;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -39,7 +40,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class AnnotationMapper
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(AnnotationMapper.class);
|
||||
|
||||
|
||||
private final ClassGroup source, target;
|
||||
private final ParallelExecutorMapping mapping;
|
||||
|
||||
@@ -119,20 +120,17 @@ public class AnnotationMapper
|
||||
|
||||
if (from.getAnnotations() == null)
|
||||
return count;
|
||||
|
||||
|
||||
for (Annotation a : from.getAnnotations())
|
||||
{
|
||||
if (isCopyable(a))
|
||||
{
|
||||
Annotation annotation = new Annotation(to);
|
||||
annotation.setType(a.getType());
|
||||
Annotation annotation = new Annotation(a.getType());
|
||||
to.addAnnotation(annotation);
|
||||
|
||||
for (Element e : a.getElements())
|
||||
{
|
||||
Element element = new Element(annotation);
|
||||
element.setName(e.getName());
|
||||
element.setValue(e.getValue());
|
||||
Element element = new SimpleElement(e.getName(), e.getValue());
|
||||
annotation.addElement(element);
|
||||
}
|
||||
|
||||
@@ -155,7 +153,6 @@ public class AnnotationMapper
|
||||
private boolean isCopyable(Annotation a)
|
||||
{
|
||||
return a.getType().equals(DeobAnnotations.EXPORT)
|
||||
|| a.getType().equals(DeobAnnotations.IMPLEMENTS)
|
||||
|| a.getType().equals(DeobAnnotations.HOOK);
|
||||
|| a.getType().equals(DeobAnnotations.IMPLEMENTS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.runelite.asm.Method;
|
||||
import net.runelite.asm.attributes.Annotations;
|
||||
import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
import net.runelite.asm.attributes.annotation.SimpleElement;
|
||||
import net.runelite.deob.Deob;
|
||||
import net.runelite.deob.DeobAnnotations;
|
||||
import org.slf4j.Logger;
|
||||
@@ -23,6 +24,7 @@ public class AnnotationAdder
|
||||
private final ClassGroup group;
|
||||
private final Logger log = LoggerFactory.getLogger(AnnotationAdder.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void run()
|
||||
{
|
||||
int impl = 0;
|
||||
@@ -50,12 +52,9 @@ public class AnnotationAdder
|
||||
{
|
||||
Annotations an = c.getAnnotations();
|
||||
|
||||
Annotation implAn = new Annotation(an);
|
||||
implAn.setType(DeobAnnotations.IMPLEMENTS);
|
||||
Annotation implAn = new Annotation(DeobAnnotations.IMPLEMENTS);
|
||||
|
||||
Element value = new Element(implAn);
|
||||
value.setValue(c.getClassName());
|
||||
value.setName("value");
|
||||
Element value = new SimpleElement(c.getClassName());
|
||||
|
||||
implAn.addElement(value);
|
||||
an.addAnnotation(implAn);
|
||||
@@ -81,12 +80,9 @@ public class AnnotationAdder
|
||||
Annotation a = an.find(DeobAnnotations.EXPORT);
|
||||
if (a == null)
|
||||
{
|
||||
a = new Annotation(an);
|
||||
a.setType(DeobAnnotations.EXPORT);
|
||||
a = new Annotation(DeobAnnotations.EXPORT);
|
||||
|
||||
Element value = new Element(a);
|
||||
value.setValue(fieldName);
|
||||
value.setName("value");
|
||||
Element value = new SimpleElement(fieldName);
|
||||
a.addElement(value);
|
||||
an.addAnnotation(a);
|
||||
|
||||
@@ -114,12 +110,9 @@ public class AnnotationAdder
|
||||
Annotation a = an.find(DeobAnnotations.EXPORT);
|
||||
if (a == null)
|
||||
{
|
||||
a = new Annotation(an);
|
||||
a.setType(DeobAnnotations.EXPORT);
|
||||
a = new Annotation(DeobAnnotations.EXPORT);
|
||||
|
||||
Element value = new Element(a);
|
||||
value.setValue(methodName);
|
||||
value.setName("value");
|
||||
Element value = new SimpleElement(methodName);
|
||||
a.addElement(value);
|
||||
an.addAnnotation(a);
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import net.runelite.asm.Type;
|
||||
import net.runelite.asm.attributes.Annotations;
|
||||
import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
import net.runelite.asm.attributes.annotation.SimpleElement;
|
||||
|
||||
public class AnnotationCopier
|
||||
{
|
||||
@@ -97,15 +98,12 @@ public class AnnotationCopier
|
||||
{
|
||||
if (!isType(a.getType()))
|
||||
continue;
|
||||
|
||||
Annotation a2 = new Annotation(an2);
|
||||
a2.setType(a.getType());
|
||||
|
||||
Annotation a2 = new Annotation(a.getType());
|
||||
|
||||
for (Element element : a.getElements())
|
||||
{
|
||||
Element element2 = new Element(a2);
|
||||
element2.setName(element.getName());
|
||||
element2.setValue(element.getValue());
|
||||
Element element2 = new SimpleElement(element.getName(), element.getValue());
|
||||
a2.addElement(element2);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,9 @@ import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.deob.DeobAnnotations;
|
||||
import net.runelite.deob.deobfuscators.Renamer;
|
||||
import net.runelite.deob.util.NameMappings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AnnotationRenamer
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(AnnotationRenamer.class);
|
||||
|
||||
private ClassGroup group;
|
||||
|
||||
public AnnotationRenamer(ClassGroup group)
|
||||
|
||||
@@ -25,9 +25,11 @@
|
||||
package net.runelite.deob.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
@@ -79,6 +81,41 @@ public class JarUtil
|
||||
return group;
|
||||
}
|
||||
|
||||
public static ClassFile loadClass(byte[] bytes)
|
||||
{
|
||||
ClassReader reader = new ClassReader(bytes);
|
||||
ClassFileVisitor cv = new ClassFileVisitor();
|
||||
reader.accept(cv, ClassReader.SKIP_FRAMES);
|
||||
return cv.getClassFile();
|
||||
}
|
||||
|
||||
public static ClassGroup loadClasses(Collection<File> files) throws IOException
|
||||
{
|
||||
final ClassGroup group = new ClassGroup();
|
||||
|
||||
for (File file : files)
|
||||
{
|
||||
if (!file.getName().endsWith(".class"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try (InputStream is = new FileInputStream(file))
|
||||
{
|
||||
ClassReader reader = new ClassReader(is);
|
||||
ClassFileVisitor cv = new ClassFileVisitor();
|
||||
|
||||
reader.accept(cv, ClassReader.SKIP_FRAMES);
|
||||
|
||||
group.addClass(cv.getClassFile());
|
||||
}
|
||||
}
|
||||
|
||||
group.initialize();
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
public static void saveJar(ClassGroup group, File jarfile) throws IOException
|
||||
{
|
||||
try (JarOutputStream jout = new JarOutputStream(new FileOutputStream(jarfile), new Manifest()))
|
||||
|
||||
Reference in New Issue
Block a user