Injector, deob, mixins

This commit is contained in:
Lucas
2019-06-08 09:33:50 +02:00
parent 276ff1995d
commit 49afdf7dc7
599 changed files with 84012 additions and 1821 deletions

View File

@@ -0,0 +1,420 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.pool.Class;
import net.runelite.asm.signature.Signature;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ClassFile
{
private ClassGroup group;
private ClassFile parent; // super class
private final List<ClassFile> children = new ArrayList<>(); // classes which inherit from this
private int version;
private int access;
private Class name;
private Class super_class;
private String source;
private final Interfaces interfaces;
private final List<Field> fields = new ArrayList<>();
private final List<Method> methods = new ArrayList<>();
private final Annotations annotations;
public ClassFile(ClassGroup group)
{
this.group = group;
interfaces = new Interfaces(this);
annotations = new Annotations();
}
public ClassFile()
{
this(null);
}
@Override
public String toString()
{
return "ClassFile{" + "name=" + name + '}';
}
public int getVersion()
{
return version;
}
public void setVersion(int version)
{
this.version = version;
}
public int getAccess()
{
return access;
}
public void setAccess(int access)
{
this.access = access;
}
public void accept(ClassVisitor visitor)
{
String[] ints = interfaces.getInterfaces().stream().map(i -> i.getName()).toArray(String[]::new);
visitor.visit(version, access, name.getName(), null, super_class.getName(), ints);
visitor.visitSource(source, null);
for (Annotation annotation : annotations.getAnnotations())
{
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
}
for (Field field : fields)
{
FieldVisitor fv = visitor.visitField(field.getAccessFlags(), field.getName(), field.getType().toString(), null, field.getValue());
field.accept(fv);
}
for (Method method : methods)
{
String[] exceptions = method.getExceptions().getExceptions().stream().map(cl -> cl.getName()).toArray(String[]::new);
if (exceptions.length == 0)
{
exceptions = null;
}
MethodVisitor mv = visitor.visitMethod(method.getAccessFlags(), method.getName(), method.getDescriptor().toString(), null, exceptions);
method.accept(mv);
}
visitor.visitEnd();
}
public ClassGroup getGroup()
{
return group;
}
public void setGroup(ClassGroup group)
{
this.group = group;
}
public Interfaces getInterfaces()
{
return interfaces;
}
public List<Field> getFields()
{
return fields;
}
public void addField(Field field)
{
fields.add(field);
}
public void removeField(Field field)
{
fields.remove(field);
}
public List<Method> getMethods()
{
return methods;
}
public void addMethod(Method method)
{
methods.add(method);
}
public void removeMethod(Method method)
{
methods.remove(method);
}
public Annotations getAnnotations()
{
return annotations;
}
public String getName()
{
return name.getName();
}
public void setName(String name)
{
// Must be removed from the class group map first
assert group == null || this.name == null || group.findClass(this.name.getName()) == null;
this.name = new Class(name);
}
public String getClassName()
{
String n = getName();
int i = n.lastIndexOf('/');
return n.substring(i + 1);
}
public String getSuperName()
{
return super_class.getName();
}
public void setSuperName(String name)
{
super_class = new Class(name);
}
public String getSource()
{
return source;
}
public void setSource(String source)
{
this.source = source;
}
public Class getParentClass()
{
return this.super_class;
}
public void setParentClass(Class c)
{
super_class = c;
}
public ClassFile getParent()
{
return parent;
}
public List<ClassFile> getChildren()
{
return children;
}
public Field findField(String name, Type type)
{
for (Field f : fields)
{
if (f.getName().equals(name) && f.getType().equals(type))
{
return f;
}
}
return null;
}
public Field findField(String name)
{
for (Field f : fields)
{
if (f.getName().equals(name))
{
return f;
}
}
return null;
}
public Class getPoolClass()
{
return name;
}
public Field findFieldDeep(String name, Type type)
{
Field f = findField(name, type);
if (f != null)
{
return f;
}
ClassFile parent = getParent();
if (parent != null)
{
return parent.findFieldDeep(name, type);
}
return null;
}
public Method findMethod(String name, Signature type)
{
for (Method m : methods)
{
if (m.getName().equals(name) && m.getDescriptor().equals(type))
{
return m;
}
}
return null;
}
public Method findMethod(String name)
{
for (Method m : methods)
{
if (m.getName().equals(name))
{
return m;
}
}
return null;
}
public Method findMethodDeep(String name, Signature type)
{
Method m = findMethod(name, type);
if (m != null)
{
return m;
}
ClassFile parent = getParent();
if (parent != null)
{
return parent.findMethodDeep(name, type);
}
return null;
}
public Method findMethodDeepStatic(String name, Signature type)
{
Method m = findMethod(name, type);
if (m != null && m.isStatic())
{
return m;
}
ClassFile parent = getParent();
if (parent != null)
{
return parent.findMethodDeepStatic(name, type);
}
return null;
}
public Method findMethodDeep(String name)
{
Method m = findMethod(name);
if (m != null)
{
return m;
}
ClassFile parent = getParent();
if (parent != null)
{
return parent.findMethodDeep(name);
}
return null;
}
public void clearClassGraph()
{
parent = null;
children.clear();
}
public void buildClassGraph()
{
ClassFile other = group.findClass(super_class.getName());
if (other != null)
{
this.parent = other;
parent.children.add(this);
}
for (ClassFile i : interfaces.getMyInterfaces())
{
i.children.add(this);
}
}
public boolean instanceOf(ClassFile other)
{
return this == other || interfaces.instanceOf(other) || (getParent() != null && getParent().instanceOf(other));
}
public boolean isAbstract()
{
return (this.access & Opcodes.ACC_ABSTRACT) != 0;
}
public boolean isFinal()
{
return (this.access & Opcodes.ACC_FINAL) != 0;
}
public boolean isInterface()
{
return (this.access & Opcodes.ACC_INTERFACE) != 0;
}
public boolean isEnum()
{
return (this.access & Opcodes.ACC_ENUM) != 0;
}
public void setEnum()
{
this.access |= Opcodes.ACC_ENUM;
}
public void clearFinal()
{
this.access &= ~Opcodes.ACC_FINAL;
}
public void clearAbstract()
{
this.access &= ~Opcodes.ACC_ABSTRACT;
}
}

View File

@@ -0,0 +1,110 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.runelite.asm.attributes.Code;
public class ClassGroup
{
private final List<ClassFile> classes = new ArrayList<>(); // to keep order
private final Map<String, ClassFile> classMap = new HashMap<>();
public void addClass(ClassFile cf)
{
assert cf.getGroup() == this || cf.getGroup() == null;
cf.setGroup(this);
classes.add(cf);
classMap.put(cf.getName(), cf);
}
public void removeClass(ClassFile cf)
{
classes.remove(cf);
classMap.remove(cf.getName());
}
public void renameClass(ClassFile cf, String newName)
{
assert classes.contains(cf);
assert classMap.get(cf.getName()) == cf;
classMap.remove(cf.getName());
cf.setName(newName);
classMap.put(cf.getName(), cf);
}
public List<ClassFile> getClasses()
{
return Collections.unmodifiableList(classes);
}
public ClassFile findClass(String name)
{
return classMap.get(name);
}
public void initialize()
{
buildClassGraph();
lookup();
}
public void buildClassGraph()
{
for (ClassFile c : classes)
{
c.clearClassGraph();
}
for (ClassFile c : classes)
{
c.buildClassGraph();
}
}
public void lookup()
{
for (ClassFile cf : this.getClasses())
{
for (Method m : cf.getMethods())
{
Code code = m.getCode();
if (code == null)
{
continue;
}
code.getInstructions().lookup();
}
}
}
}

View File

@@ -0,0 +1,163 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.annotation.Annotation;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.objectweb.asm.Opcodes.ACC_PROTECTED;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
public class Field
{
public static final int ACCESS_MODIFIERS = ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED;
private final ClassFile classFile;
private int accessFlags;
private String name;
private Type type;
private Object value; // ConstantValue
private final Annotations annotations;
public Field(ClassFile classFile, String name, Type type)
{
this.classFile = classFile;
this.name = name;
this.type = type;
annotations = new Annotations();
}
public void accept(FieldVisitor visitor)
{
for (Annotation annotation : annotations.getAnnotations())
{
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
}
visitor.visitEnd();
}
public ClassFile getClassFile()
{
return classFile;
}
public int getAccessFlags()
{
return accessFlags;
}
public void setAccessFlags(int accessFlags)
{
this.accessFlags = accessFlags;
}
public boolean isPublic()
{
return (accessFlags & Opcodes.ACC_PUBLIC) != 0;
}
public void setPublic()
{
accessFlags = (short) ((accessFlags & ~ACCESS_MODIFIERS) | ACC_PUBLIC);
}
public boolean isStatic()
{
return (accessFlags & Opcodes.ACC_STATIC) != 0;
}
public void setStatic()
{
accessFlags |= Opcodes.ACC_STATIC;
}
public boolean isSynthetic()
{
return (accessFlags & Opcodes.ACC_SYNTHETIC) != 0;
}
public void setEnum()
{
accessFlags |= Opcodes.ACC_ENUM;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Type getType()
{
return type;
}
public void setType(Type type)
{
this.type = type;
}
public Object getValue()
{
return value;
}
public void setValue(Object value)
{
this.value = value;
}
public Annotations getAnnotations()
{
return annotations;
}
public net.runelite.asm.pool.Field getPoolField()
{
return new net.runelite.asm.pool.Field(
new net.runelite.asm.pool.Class(classFile.getName()),
this.getName(),
this.getType()
);
}
@Override
public String toString()
{
return (this.isStatic() ? "static " : "") + this.type + " " + classFile.getName() + "." + this.getName();
}
}

View File

@@ -0,0 +1,92 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import net.runelite.asm.pool.Class;
public class Interfaces
{
private final ClassFile classFile;
private final List<Class> interfaces = new ArrayList<>();
Interfaces(ClassFile c)
{
classFile = c;
}
public void addInterface(Class clazz)
{
if (!interfaces.contains(clazz))
{
interfaces.add(clazz);
}
}
public List<Class> getInterfaces()
{
return interfaces;
}
public void clear()
{
interfaces.clear();
}
public List<ClassFile> getMyInterfaces()
{
List<ClassFile> l = new ArrayList<>();
for (Class clazz : interfaces)
{
ClassFile iface = classFile.getGroup().findClass(clazz.getName());
if (iface != null)
{
l.add(iface);
}
}
return l;
}
public List<Class> getNonMyInterfaces()
{
return interfaces.stream().filter(clazz -> classFile.getGroup().findClass(clazz.getName()) == null).collect(Collectors.toList());
}
public boolean instanceOf(ClassFile cf)
{
for (Class clazz : interfaces)
{
ClassFile iface = classFile.getGroup().findClass(clazz.getName());
if (iface.instanceOf(cf))
{
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,314 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.Code;
import net.runelite.asm.attributes.Exceptions;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.LocalVariable;
import net.runelite.asm.attributes.code.Parameter;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.signature.Signature;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import static org.objectweb.asm.Opcodes.ACC_FINAL;
import static org.objectweb.asm.Opcodes.ACC_NATIVE;
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.objectweb.asm.Opcodes.ACC_PROTECTED;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACC_STATIC;
import static org.objectweb.asm.Opcodes.ACC_SYNCHRONIZED;
public class Method
{
public static final int ACCESS_MODIFIERS = ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED;
private final ClassFile classFile;
private int accessFlags;
private String name;
private Signature arguments;
private Exceptions exceptions;
private Annotations annotations;
private List<Parameter> parameters;
private Code code;
public Method(ClassFile classFile, String name, Signature signature)
{
this.classFile = classFile;
this.name = name;
this.arguments = signature;
exceptions = new Exceptions();
annotations = new Annotations();
parameters = new ArrayList<>();
}
public ClassFile getClassFile()
{
return classFile;
}
@Override
public String toString()
{
return (this.isStatic() ? "static " : "") + classFile.getName() + "." + this.name + this.arguments;
}
public void accept(MethodVisitor visitor)
{
//This is required to name unused parameters
for (Parameter p : parameters)
{
visitor.visitParameter(p.getName(), p.getAccess());
}
for (Annotation annotation : annotations.getAnnotations())
{
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
}
if (code != null)
{
code.getInstructions().rebuildLabels();
visitor.visitCode();
net.runelite.asm.attributes.code.Exceptions exceptions = code.getExceptions();
for (net.runelite.asm.attributes.code.Exception exception : exceptions.getExceptions())
{
assert exception.getStart().getLabel() != null;
assert exception.getEnd().getLabel() != null;
assert exception.getHandler().getLabel() != null;
int idxStart = code.getInstructions().getInstructions().indexOf(exception.getStart());
int idxEnd = code.getInstructions().getInstructions().indexOf(exception.getEnd());
assert idxStart != -1;
assert idxEnd != -1;
assert code.getInstructions().getInstructions().contains(exception.getHandler());
assert idxEnd > idxStart;
visitor.visitTryCatchBlock(
exception.getStart().getLabel(),
exception.getEnd().getLabel(),
exception.getHandler().getLabel(),
exception.getCatchType() != null ? exception.getCatchType().getName() : null
);
}
for (Instruction i : code.getInstructions().getInstructions())
{
i.accept(visitor);
}
//Find first and last label for this method
if (parameters.size() > 0)
{
Label startLabel = null;
Label endLabel = null;
for (Instruction i : code.getInstructions().getInstructions())
{
if (i instanceof net.runelite.asm.attributes.code.Label)
{
if (startLabel == null)
{
startLabel = ((net.runelite.asm.attributes.code.Label) i).getLabel();
}
endLabel = ((net.runelite.asm.attributes.code.Label) i).getLabel();
}
}
for (Parameter p : parameters)
{
LocalVariable lv = p.getLocalVariable();
if (lv != null)
{
visitor.visitLocalVariable(lv.getName(), lv.getDesc(), lv.getSignature(), startLabel, endLabel, lv.getIndex());
}
}
}
visitor.visitMaxs(code.getMaxStack(), code.getMaxLocals());
}
visitor.visitEnd();
}
public int getAccessFlags()
{
return accessFlags;
}
public void setAccessFlags(int accessFlags)
{
this.accessFlags = accessFlags;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Signature getDescriptor()
{
return arguments;
}
public void setDescriptor(Signature signature)
{
this.arguments = signature;
}
public boolean isNative()
{
return (accessFlags & ACC_NATIVE) != 0;
}
public boolean isStatic()
{
return (accessFlags & ACC_STATIC) != 0;
}
public void setStatic()
{
accessFlags |= ACC_STATIC;
}
public boolean isSynchronized()
{
return (accessFlags & ACC_SYNCHRONIZED) != 0;
}
public boolean isFinal()
{
return (accessFlags & ACC_FINAL) != 0;
}
public void setFinal(boolean f)
{
if (f)
{
accessFlags |= ACC_FINAL;
}
else
{
accessFlags &= ~ACC_FINAL;
}
}
public boolean isPrivate()
{
return (accessFlags & ACC_PRIVATE) != 0;
}
public void setPrivate()
{
accessFlags = (short) ((accessFlags & ~ACCESS_MODIFIERS) | ACC_PRIVATE);
}
public void setPublic()
{
accessFlags = (short) ((accessFlags & ~ACCESS_MODIFIERS) | ACC_PUBLIC);
}
public Exceptions getExceptions()
{
return exceptions;
}
public Code getCode()
{
return code;
}
public void setCode(Code code)
{
this.code = code;
}
public Annotations getAnnotations()
{
return annotations;
}
@SuppressWarnings("unchecked")
public <T extends Instruction & LVTInstruction> List<T> findLVTInstructionsForVariable(int index)
{
List<T> list = new ArrayList<>();
if (getCode() == null)
{
return null;
}
for (Instruction ins : getCode().getInstructions().getInstructions())
{
if (ins instanceof LVTInstruction)
{
LVTInstruction lv = (LVTInstruction) ins;
if (lv.getVariableIndex() != index)
{
continue;
}
list.add((T) ins);
}
}
return list;
}
public net.runelite.asm.pool.Method getPoolMethod()
{
return new net.runelite.asm.pool.Method(
new net.runelite.asm.pool.Class(classFile.getName()),
name,
arguments
);
}
public List<Parameter> getParameters()
{
return parameters;
}
public void setParameters(List<Parameter> parameters)
{
this.parameters = parameters;
}
}

View File

@@ -0,0 +1,228 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm;
import net.runelite.asm.pool.Class;
/**
* Created by Kyle Fricilone on 8/20/2017
*/
public class Type
{
public static final Type VOID = new Type("V");
public static final Type BOOLEAN = new Type("Z");
public static final Type CHAR = new Type("C");
public static final Type BYTE = new Type("B");
public static final Type SHORT = new Type("S");
public static final Type INT = new Type("I");
public static final Type FLOAT = new Type("F");
public static final Type LONG = new Type("J");
public static final Type DOUBLE = new Type("D");
public static final Type OBJECT = new Type("Ljava/lang/Object;");
public static final Type STRING = new Type("Ljava/lang/String;");
public static final Type THROWABLE = new Type("Ljava/lang/Throwable;");
public static final Type EXCEPTION = new Type("Ljava/lang/Exception;");
private final String type;
public Type(String type)
{
this.type = type;
}
public boolean isPrimitive()
{
return this.equals(BOOLEAN) || this.equals(BYTE) || this.equals(SHORT) || this.equals(CHAR) || this.equals(INT)
|| this.equals(VOID) || this.equals(LONG) || this.equals(FLOAT) || this.equals(DOUBLE);
}
public boolean isObject()
{
return this.equals(OBJECT);
}
public boolean isArray()
{
return getDimensions() > 0;
}
public boolean isStackInt()
{
return this.equals(BOOLEAN) || this.equals(BYTE) || this.equals(SHORT) || this.equals(CHAR) || this.equals(INT);
}
public int getSize()
{
if (this.equals(LONG) || this.equals(DOUBLE))
{
return 2;
}
if (this.equals(VOID))
{
return 0;
}
return 1;
}
public int getDimensions()
{
return getDimensions(type);
}
public Type getSubtype()
{
if (!type.startsWith("["))
{
throw new IllegalStateException(type + " is not an array");
}
return new Type(type.substring(1));
}
public String getInternalName()
{
String s = type;
while (s.startsWith("["))
{
s = s.substring(1);
}
if (s.startsWith("L"))
{
return s.substring(1, s.length() - 1);
}
else
{
return s;
}
}
@Override
public boolean equals(Object o)
{
if (!(o instanceof Type))
{
return false;
}
Type other = (Type) o;
return type.equals(other.type);
}
@Override
public int hashCode()
{
return type.hashCode();
}
@Override
public String toString()
{
return type;
}
public String toAsmString()
{
if (type.startsWith("L") && type.endsWith(";"))
{
return type.substring(1, type.length() - 1);
}
else
{
return type;
}
}
public static Type fromAsmString(String str)
{
if (str.startsWith("["))
{
// array type
return new Type(str);
}
else
{
// object type
return new Type("L" + str + ";");
}
}
private static int getDimensions(String type)
{
if (!type.startsWith("["))
{
return 0;
}
return (int) type.chars().filter(i -> i == '[').count();
}
public static Type getType(String type, int dims)
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < dims; i++)
{
builder.append('[');
}
return new Type(builder.append(type).toString());
}
public static Type getType(Object object)
{
Type type;
if (object instanceof Double)
{
type = DOUBLE;
}
else if (object instanceof Float)
{
type = FLOAT;
}
else if (object instanceof Integer)
{
type = INT;
}
else if (object instanceof Long)
{
type = LONG;
}
else if (object instanceof String)
{
type = STRING;
}
else if (object instanceof Class)
{
type = new Type("L" + ((Class) object).getName() + ";");
}
else
{
throw new IllegalArgumentException("Unexpected object type: " + object.getClass());
}
return type;
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.annotation.Element;
public class Annotations
{
private final List<Annotation> annotations = new ArrayList<>();
public List<Annotation> getAnnotations()
{
return annotations;
}
public void addAnnotation(Annotation annotation)
{
annotations.add(annotation);
}
public void removeAnnotation(Annotation annotation)
{
annotations.remove(annotation);
}
public void clearAnnotations()
{
annotations.clear();
}
public Annotation find(Type type)
{
for (Annotation a : annotations)
if (a.getType().equals(type))
return a;
return null;
}
public int size()
{
return annotations.size();
}
public Annotation addAnnotation(Type type, String name, Object value)
{
Annotation annotation = new Annotation(this);
annotation.setType(type);
addAnnotation(annotation);
Element element = new Element(annotation);
element.setName(name);
element.setValue(value);
annotation.addElement(element);
return annotation;
}
}

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes;
import net.runelite.asm.Method;
import net.runelite.asm.attributes.code.Exceptions;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.signature.Signature;
public class Code
{
private Method method;
private int maxStack;
private Instructions instructions;
private final Exceptions exceptions;
public Code(Method method)
{
this.method = method;
exceptions = new Exceptions(this);
instructions = new Instructions(this);
}
public Method getMethod()
{
return method;
}
public int getMaxStack()
{
return maxStack;
}
public void setMaxStack(int maxStack)
{
this.maxStack = maxStack;
}
private int getMaxLocalsFromSig()
{
Method m = getMethod();
int num = m.isStatic() ? 0 : 1;
Signature sig = m.getDescriptor();
for (int i = 0; i < sig.size(); ++i)
num += sig.getTypeOfArg(i).getSize();
return num;
}
/**
* calculates the size of the lvt required for this method
* @return
*/
public int getMaxLocals()
{
int max = -1;
for (Instruction ins : instructions.getInstructions())
{
if (ins instanceof LVTInstruction)
{
LVTInstruction lvt = (LVTInstruction) ins;
int sizeRequired = lvt.getVariableIndex() + lvt.type().getSlots();
if (sizeRequired > max)
{
max = sizeRequired;
}
}
}
int fromSig = getMaxLocalsFromSig();
if (fromSig > max)
max = fromSig;
return max;
}
public Exceptions getExceptions()
{
return exceptions;
}
public Instructions getInstructions()
{
return instructions;
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.ClassFile;
import net.runelite.asm.pool.Class;
public class Exceptions
{
private final List<Class> classes = new ArrayList<>();
public void addException(Class cl)
{
classes.add(cl);
}
public List<Class> getExceptions()
{
return classes;
}
public void renameClass(ClassFile cf, String name)
{
for (Class c : new ArrayList<>(classes))
{
if (c.getName().equals(cf.getName()))
{
int idx = classes.indexOf(c);
classes.remove(idx);
classes.add(idx, new Class(name));
}
}
}
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.annotation;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotations;
import org.objectweb.asm.AnnotationVisitor;
public class Annotation
{
private final Annotations annotations;
private Type type;
private final List<Element> elements = new ArrayList<>();
public Annotation(Annotations annotations)
{
this.annotations = annotations;
}
public Annotations getAnnotations()
{
return annotations;
}
public void setType(Type type)
{
this.type = type;
}
public Type getType()
{
return type;
}
public List<Element> getElements()
{
return elements;
}
public Element getElement()
{
return elements.get(0);
}
public void addElement(Element element)
{
elements.add(element);
}
public void accept(AnnotationVisitor visitor)
{
for (Element element : elements)
visitor.visit(element.getName(), element.getValue());
visitor.visitEnd();
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.annotation;
public class Element
{
private final Annotation annotation;
private String name;
private Object value;
public Element(Annotation annotation)
{
this.annotation = annotation;
}
public Annotation getAnnotation()
{
return annotation;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Object getValue()
{
return value;
}
public void setValue(Object value)
{
this.value = value;
}
public String getString()
{
return value.toString();
}
}

View File

@@ -0,0 +1,111 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code;
import net.runelite.asm.ClassFile;
import net.runelite.asm.pool.Class;
public class Exception implements Cloneable
{
private Exceptions exceptions;
private Label start, end, handler;
private Class catchType;
public Exception(Exceptions exceptions)
{
this.exceptions = exceptions;
}
@Override
public Exception clone()
{
try
{
return (Exception) super.clone();
}
catch (CloneNotSupportedException ex)
{
throw new RuntimeException();
}
}
public Exceptions getExceptions()
{
return exceptions;
}
public void setExceptions(Exceptions exceptions)
{
this.exceptions = exceptions;
}
public Label getStart()
{
return start;
}
public void setStart(Label ins)
{
start = ins;
}
public Label getEnd()
{
return end;
}
public void setEnd(Label end)
{
this.end = end;
}
public Label getHandler()
{
return handler;
}
public void setHandler(Label handler)
{
this.handler = handler;
}
public Class getCatchType()
{
return catchType;
}
public void setCatchType(Class catchType)
{
this.catchType = catchType;
}
public void renameClass(ClassFile cf, String name)
{
if (catchType != null && cf.getName().equals(catchType.getName()))
catchType = new Class(name);
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.ClassFile;
import net.runelite.asm.attributes.Code;
public class Exceptions
{
private Code code;
private List<Exception> exceptions = new ArrayList<Exception>();
public Exceptions(Code code)
{
this.code = code;
}
public void add(Exception e)
{
exceptions.add(e);
}
public void remove(Exception e)
{
exceptions.remove(e);
}
public void clear()
{
exceptions.clear();
}
public Code getCode()
{
return code;
}
public List<Exception> getExceptions()
{
return exceptions;
}
public void renameClass(ClassFile cf, String name)
{
for (Exception e : exceptions)
e.renameClass(cf, name);
}
}

View File

@@ -0,0 +1,144 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code;
import net.runelite.asm.Method;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import org.objectweb.asm.MethodVisitor;
public abstract class Instruction implements Cloneable
{
private Instructions instructions;
private InstructionType type;
public Instruction(Instructions instructions, InstructionType type)
{
this.instructions = instructions;
this.type = type;
}
@Override
public String toString()
{
if (this.getInstructions() != null)
{
Method m = this.getInstructions().getCode().getMethod();
return super.toString() + " in " + m;// + " at pc 0x" + Integer.toHexString(this.getPc());
}
else
{
return super.toString() + " <unattached>";
}
}
@Override
public Instruction clone()
{
Instruction i;
try
{
i = (Instruction) super.clone();
}
catch (CloneNotSupportedException ex)
{
throw new RuntimeException(ex);
}
return i;
}
protected void remove()
{
Exceptions exceptions = instructions.getCode().getExceptions();
for (Exception e : exceptions.getExceptions())
{
assert this != e.getStart();
assert this != e.getEnd();
assert this != e.getHandler();
}
}
public boolean removeStack()
{
assert instructions != null;
this.getInstructions().remove(this); // calls remove()
return true;
}
// resolve jumps
public void resolve()
{
}
public void accept(MethodVisitor visitor)
{
visitor.visitInsn(this.getType().getCode());
}
public Instructions getInstructions()
{
return instructions;
}
public void setInstructions(Instructions instructions)
{
this.instructions = instructions;
}
public InstructionType getType()
{
return type;
}
protected void setType(InstructionType type)
{
this.type = type;
}
public abstract InstructionContext execute(Frame e);
/* does this terminate a block? */
public boolean isTerminal()
{
return false;
}
// look up symbols from pool
public void lookup()
{
}
// instructions keep resolved method/field/class names, this updates the pool value (if the underlying resolved object changes)
public void regeneratePool()
{
}
public void renameClass(String oldName, String newName)
{
}
}

View File

@@ -0,0 +1,348 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code;
import net.runelite.asm.attributes.code.instructions.AALoad;
import net.runelite.asm.attributes.code.instructions.AAStore;
import net.runelite.asm.attributes.code.instructions.AConstNull;
import net.runelite.asm.attributes.code.instructions.ALoad;
import net.runelite.asm.attributes.code.instructions.ANewArray;
import net.runelite.asm.attributes.code.instructions.AStore;
import net.runelite.asm.attributes.code.instructions.AThrow;
import net.runelite.asm.attributes.code.instructions.ArrayLength;
import net.runelite.asm.attributes.code.instructions.BALoad;
import net.runelite.asm.attributes.code.instructions.BAStore;
import net.runelite.asm.attributes.code.instructions.BiPush;
import net.runelite.asm.attributes.code.instructions.CALoad;
import net.runelite.asm.attributes.code.instructions.CAStore;
import net.runelite.asm.attributes.code.instructions.CheckCast;
import net.runelite.asm.attributes.code.instructions.D2F;
import net.runelite.asm.attributes.code.instructions.D2I;
import net.runelite.asm.attributes.code.instructions.D2L;
import net.runelite.asm.attributes.code.instructions.DALoad;
import net.runelite.asm.attributes.code.instructions.DAStore;
import net.runelite.asm.attributes.code.instructions.DAdd;
import net.runelite.asm.attributes.code.instructions.DCmpG;
import net.runelite.asm.attributes.code.instructions.DCmpL;
import net.runelite.asm.attributes.code.instructions.DDiv;
import net.runelite.asm.attributes.code.instructions.DLoad;
import net.runelite.asm.attributes.code.instructions.DMul;
import net.runelite.asm.attributes.code.instructions.DNeg;
import net.runelite.asm.attributes.code.instructions.DRem;
import net.runelite.asm.attributes.code.instructions.DStore;
import net.runelite.asm.attributes.code.instructions.DSub;
import net.runelite.asm.attributes.code.instructions.Dup;
import net.runelite.asm.attributes.code.instructions.Dup2;
import net.runelite.asm.attributes.code.instructions.Dup2_X1;
import net.runelite.asm.attributes.code.instructions.Dup2_X2;
import net.runelite.asm.attributes.code.instructions.Dup_X1;
import net.runelite.asm.attributes.code.instructions.Dup_X2;
import net.runelite.asm.attributes.code.instructions.F2D;
import net.runelite.asm.attributes.code.instructions.F2I;
import net.runelite.asm.attributes.code.instructions.F2L;
import net.runelite.asm.attributes.code.instructions.FALoad;
import net.runelite.asm.attributes.code.instructions.FAStore;
import net.runelite.asm.attributes.code.instructions.FAdd;
import net.runelite.asm.attributes.code.instructions.FCmpG;
import net.runelite.asm.attributes.code.instructions.FCmpL;
import net.runelite.asm.attributes.code.instructions.FDiv;
import net.runelite.asm.attributes.code.instructions.FLoad;
import net.runelite.asm.attributes.code.instructions.FMul;
import net.runelite.asm.attributes.code.instructions.FNeg;
import net.runelite.asm.attributes.code.instructions.FRem;
import net.runelite.asm.attributes.code.instructions.FStore;
import net.runelite.asm.attributes.code.instructions.FSub;
import net.runelite.asm.attributes.code.instructions.GetField;
import net.runelite.asm.attributes.code.instructions.GetStatic;
import net.runelite.asm.attributes.code.instructions.Goto;
import net.runelite.asm.attributes.code.instructions.GotoW;
import net.runelite.asm.attributes.code.instructions.I2B;
import net.runelite.asm.attributes.code.instructions.I2C;
import net.runelite.asm.attributes.code.instructions.I2D;
import net.runelite.asm.attributes.code.instructions.I2F;
import net.runelite.asm.attributes.code.instructions.I2L;
import net.runelite.asm.attributes.code.instructions.I2S;
import net.runelite.asm.attributes.code.instructions.IALoad;
import net.runelite.asm.attributes.code.instructions.IAStore;
import net.runelite.asm.attributes.code.instructions.IAdd;
import net.runelite.asm.attributes.code.instructions.IAnd;
import net.runelite.asm.attributes.code.instructions.IDiv;
import net.runelite.asm.attributes.code.instructions.IInc;
import net.runelite.asm.attributes.code.instructions.ILoad;
import net.runelite.asm.attributes.code.instructions.IMul;
import net.runelite.asm.attributes.code.instructions.INeg;
import net.runelite.asm.attributes.code.instructions.IOr;
import net.runelite.asm.attributes.code.instructions.IRem;
import net.runelite.asm.attributes.code.instructions.IShL;
import net.runelite.asm.attributes.code.instructions.IShR;
import net.runelite.asm.attributes.code.instructions.IStore;
import net.runelite.asm.attributes.code.instructions.ISub;
import net.runelite.asm.attributes.code.instructions.IUShR;
import net.runelite.asm.attributes.code.instructions.IXor;
import net.runelite.asm.attributes.code.instructions.IfACmpEq;
import net.runelite.asm.attributes.code.instructions.IfACmpNe;
import net.runelite.asm.attributes.code.instructions.IfCmpGe;
import net.runelite.asm.attributes.code.instructions.IfCmpGt;
import net.runelite.asm.attributes.code.instructions.IfCmpLe;
import net.runelite.asm.attributes.code.instructions.IfCmpLt;
import net.runelite.asm.attributes.code.instructions.IfEq;
import net.runelite.asm.attributes.code.instructions.IfGe;
import net.runelite.asm.attributes.code.instructions.IfGt;
import net.runelite.asm.attributes.code.instructions.IfICmpEq;
import net.runelite.asm.attributes.code.instructions.IfICmpNe;
import net.runelite.asm.attributes.code.instructions.IfLe;
import net.runelite.asm.attributes.code.instructions.IfLt;
import net.runelite.asm.attributes.code.instructions.IfNe;
import net.runelite.asm.attributes.code.instructions.IfNonNull;
import net.runelite.asm.attributes.code.instructions.IfNull;
import net.runelite.asm.attributes.code.instructions.InstanceOf;
import net.runelite.asm.attributes.code.instructions.InvokeDynamic;
import net.runelite.asm.attributes.code.instructions.InvokeInterface;
import net.runelite.asm.attributes.code.instructions.InvokeSpecial;
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
import net.runelite.asm.attributes.code.instructions.InvokeVirtual;
import net.runelite.asm.attributes.code.instructions.L2D;
import net.runelite.asm.attributes.code.instructions.L2F;
import net.runelite.asm.attributes.code.instructions.L2I;
import net.runelite.asm.attributes.code.instructions.LALoad;
import net.runelite.asm.attributes.code.instructions.LAStore;
import net.runelite.asm.attributes.code.instructions.LAdd;
import net.runelite.asm.attributes.code.instructions.LAnd;
import net.runelite.asm.attributes.code.instructions.LCmp;
import net.runelite.asm.attributes.code.instructions.LDC;
import net.runelite.asm.attributes.code.instructions.LDiv;
import net.runelite.asm.attributes.code.instructions.LLoad;
import net.runelite.asm.attributes.code.instructions.LMul;
import net.runelite.asm.attributes.code.instructions.LNeg;
import net.runelite.asm.attributes.code.instructions.LOr;
import net.runelite.asm.attributes.code.instructions.LRem;
import net.runelite.asm.attributes.code.instructions.LShL;
import net.runelite.asm.attributes.code.instructions.LShR;
import net.runelite.asm.attributes.code.instructions.LStore;
import net.runelite.asm.attributes.code.instructions.LSub;
import net.runelite.asm.attributes.code.instructions.LUShR;
import net.runelite.asm.attributes.code.instructions.LXor;
import net.runelite.asm.attributes.code.instructions.LookupSwitch;
import net.runelite.asm.attributes.code.instructions.MonitorEnter;
import net.runelite.asm.attributes.code.instructions.MonitorExit;
import net.runelite.asm.attributes.code.instructions.MultiANewArray;
import net.runelite.asm.attributes.code.instructions.NOP;
import net.runelite.asm.attributes.code.instructions.New;
import net.runelite.asm.attributes.code.instructions.NewArray;
import net.runelite.asm.attributes.code.instructions.Pop;
import net.runelite.asm.attributes.code.instructions.Pop2;
import net.runelite.asm.attributes.code.instructions.PutField;
import net.runelite.asm.attributes.code.instructions.PutStatic;
import net.runelite.asm.attributes.code.instructions.Return;
import net.runelite.asm.attributes.code.instructions.SALoad;
import net.runelite.asm.attributes.code.instructions.SAStore;
import net.runelite.asm.attributes.code.instructions.SiPush;
import net.runelite.asm.attributes.code.instructions.Swap;
import net.runelite.asm.attributes.code.instructions.TableSwitch;
import net.runelite.asm.attributes.code.instructions.VReturn;
public enum InstructionType
{
NOP(0x00, "nop", NOP.class),
ACONST_NULL(0x01, "aconst_null", AConstNull.class),
BIPUSH(0x10, "bipush", BiPush.class),
SIPUSH(0x11, "sipush", SiPush.class),
LDC(-1, "ldc", LDC.class),
ILOAD(0x15, "iload", ILoad.class),
LLOAD(0x16, "lload", LLoad.class),
FLOAD(0x17, "fload", FLoad.class),
DLOAD(0x18, "dload", DLoad.class),
ALOAD(0x19, "aload", ALoad.class),
IALOAD(0x2e, "iaload", IALoad.class),
LALOAD(0x2f, "laload", LALoad.class),
FALOAD(0x30, "faload", FALoad.class),
DALOAD(0x31, "daload", DALoad.class),
AALOAD(0x32, "aaload", AALoad.class),
BALOAD(0x33, "baload", BALoad.class),
CALOAD(0x34, "caload", CALoad.class),
SALOAD(0x35, "saload", SALoad.class),
ISTORE(0x36, "istore", IStore.class),
LSTORE(0x37, "lstore", LStore.class),
FSTORE(0x38, "fstore", FStore.class),
DSTORE(0x39, "dstore", DStore.class),
ASTORE(0x3a, "astore", AStore.class),
IASTORE(0x4f, "iastore", IAStore.class),
LASTORE(0x50, "lastore", LAStore.class),
FASTORE(0x51, "fastore", FAStore.class),
DASTORE(0x52, "dastore", DAStore.class),
AASTORE(0x53, "aastore", AAStore.class),
BASTORE(0x54, "bastore", BAStore.class),
CASTORE(0x55, "castore", CAStore.class),
SASTORE(0x56, "sastore", SAStore.class),
POP(0x57, "pop", Pop.class),
POP2(0x58, "pop2", Pop2.class),
DUP(0x59, "dup", Dup.class),
DUP_X1(0x5a, "dup_x1", Dup_X1.class),
DUP_X2(0x5b, "dup_x2", Dup_X2.class),
DUP2(0x5c, "dup2", Dup2.class),
DUP2_X1(0x5d, "dup2_x1", Dup2_X1.class),
DUP2_X2(0x5e, "dup2_x2", Dup2_X2.class),
SWAP(0x5f, "swap", Swap.class),
IADD(0x60, "iadd", IAdd.class),
LADD(0x61, "ladd", LAdd.class),
FADD(0x62, "fadd", FAdd.class),
DADD(0x63, "dadd", DAdd.class),
ISUB(0x64, "isub", ISub.class),
LSUB(0x65, "lsub", LSub.class),
FSUB(0x66, "fsub", FSub.class),
DSUB(0x67, "dsub", DSub.class),
IMUL(0x68, "imul", IMul.class),
LMUL(0x69, "lmul", LMul.class),
FMUL(0x6a, "fmul", FMul.class),
DMUL(0x6b, "dmul", DMul.class),
IDIV(0x6c, "idiv", IDiv.class),
LDIV(0x6d, "ldiv", LDiv.class),
FDIV(0x6e, "fdiv", FDiv.class),
DDIV(0x6f, "ddiv", DDiv.class),
IREM(0x70, "irem", IRem.class),
LREM(0x71, "lrem", LRem.class),
FREM(0x72, "frem", FRem.class),
DREM(0x73, "drem", DRem.class),
INEG(0x74, "ineg", INeg.class),
LNEG(0x75, "lneg", LNeg.class),
FNEG(0x76, "fneg", FNeg.class),
DNEG(0x77, "dneg", DNeg.class),
ISHL(0x78, "ishl", IShL.class),
LSHL(0x79, "lshl", LShL.class),
ISHR(0x7a, "ishr", IShR.class),
LSHR(0x7b, "lshr", LShR.class),
IUSHR(0x7c, "iushr", IUShR.class),
LUSHR(0x7d, "lushr", LUShR.class),
IAND(0x7e, "iand", IAnd.class),
LAND(0x7f, "land", LAnd.class),
IOR(0x80, "ior", IOr.class),
LOR(0x81, "lor", LOr.class),
IXOR(0x82, "ixor", IXor.class),
LXOR(0x83, "lxor", LXor.class),
IINC(0x84, "iinc", IInc.class),
I2L(0x85, "i2l", I2L.class),
I2F(0x86, "i2f", I2F.class),
I2D(0x87, "i2d", I2D.class),
L2I(0x88, "l2i", L2I.class),
L2F(0x89, "l2f", L2F.class),
L2D(0x8a, "l2d", L2D.class),
F2I(0x8b, "f2i", F2I.class),
F2L(0x8c, "f2l", F2L.class),
F2D(0x8d, "f2d", F2D.class),
D2I(0x8e, "d2i", D2I.class),
D2L(0x8f, "d2l", D2L.class),
D2F(0x90, "d2f", D2F.class),
I2B(0x91, "i2b", I2B.class),
I2C(0x92, "i2c", I2C.class),
I2S(0x93, "i2s", I2S.class),
LCMP(0x94, "lcmp", LCmp.class),
FCMPL(0x95, "fcmpl", FCmpL.class),
FCMPG(0x96, "fcmpg", FCmpG.class),
DCMPL(0x97, "dcmpl", DCmpL.class),
DCMPG(0x98, "dcmpg", DCmpG.class),
IFEQ(0x99, "ifeq", IfEq.class),
IFNE(0x9a, "ifne", IfNe.class),
IFLT(0x9b, "iflt", IfLt.class),
IFGE(0x9c, "ifge", IfGe.class),
IFGT(0x9d, "ifgt", IfGt.class),
IFLE(0x9e, "ifle", IfLe.class),
IF_ICMPEQ(0x9f, "if_icmpeq", IfICmpEq.class),
IF_ICMPNE(0xa0, "if_icmpne", IfICmpNe.class),
IF_ICMPLT(0xa1, "if_cmplt", IfCmpLt.class),
IF_ICMPGE(0xa2, "if_icmpge", IfCmpGe.class),
IF_ICMPGT(0xa3, "if_icmpgt", IfCmpGt.class),
IF_ICMPLE(0xa4, "if_icmple", IfCmpLe.class),
IF_ACMPEQ(0xa5, "if_acmpeq", IfACmpEq.class),
IF_ACMPNE(0xa6, "if_acmpne", IfACmpNe.class),
GOTO(0xa7, "goto", Goto.class),
TABLESWITCH(0xaa, "tableswitch", TableSwitch.class),
LOOKUPSWITCH(0xab, "lookupswitch", LookupSwitch.class),
IRETURN(0xac, "ireturn", Return.class),
LRETURN(0xad, "lreturn", Return.class),
FRETURN(0xae, "freturn", Return.class),
DRETURN(0xaf, "dreturn", Return.class),
ARETURN(0xb0, "areturn", Return.class),
RETURN(0xb1, "return", VReturn.class),
GETSTATIC(0xb2, "getstatic", GetStatic.class),
PUTSTATIC(0xb3, "putstatic", PutStatic.class),
GETFIELD(0xb4, "getfield", GetField.class),
PUTFIELD(0xb5, "putfield", PutField.class),
INVOKEVIRTUAL(0xb6, "invokevirtual", InvokeVirtual.class),
INVOKESPECIAL(0xb7, "invokespecial", InvokeSpecial.class),
INVOKESTATIC(0xb8, "invokestatic", InvokeStatic.class),
INVOKEINTERFACE(0xb9, "invokeinterface", InvokeInterface.class),
INVOKEDYNAMIC(0xba, "invokedynamic", InvokeDynamic.class),
NEW(0xbb, "new", New.class),
NEWARRAY(0xbc, "newarray", NewArray.class),
ANEWARRAY(0xbd, "anewarray", ANewArray.class),
ARRAYLENGTH(0xbe, "arraylength", ArrayLength.class),
ATHROW(0xbf, "athrow", AThrow.class),
CHECKCAST(0xc0, "checkcast", CheckCast.class),
INSTANCEOf(0xc1, "instanceof", InstanceOf.class),
MONITORENTER(0xc2, "monitorenter", MonitorEnter.class),
MONITOREXIT(0xc3, "monitorexit", MonitorExit.class),
MULTIANEWARRAY(0xc5, "multianewarray", MultiANewArray.class),
IFNULL(0xc6, "ifnull", IfNull.class),
IFNONNULL(0xc7, "ifnonnull", IfNonNull.class),
GOTO_W(0xc8, "goto_w", GotoW.class);
private final int code;
private final String name;
private final Class<? extends Instruction> clazz;
InstructionType(int op, String name, Class<? extends Instruction> clazz)
{
this.code = op;
this.name = name;
this.clazz = clazz;
}
public int getCode()
{
return code;
}
public String getName()
{
return name;
}
public Class<? extends Instruction> getInstructionClass()
{
return clazz;
}
public static InstructionType findInstructionFromCode(int code)
{
for (InstructionType t : InstructionType.values())
{
if (t.getCode() == code)
{
return t;
}
}
return null;
}
}

View File

@@ -0,0 +1,189 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.runelite.asm.attributes.Code;
public class Instructions
{
private final Code code;
private final List<Instruction> instructions = new ArrayList<>();
private final Map<org.objectweb.asm.Label, Label> labelMap = new HashMap<>();
public Instructions(Code code)
{
this.code = code;
}
public Label createLabelFor(Instruction target)
{
return createLabelFor(target, false);
}
public Label createLabelFor(Instruction target, boolean forceCreate)
{
assert target.getInstructions() == this;
assert instructions.contains(target);
if (target instanceof Label)
{
return (Label) target;
}
int i = instructions.indexOf(target);
if (i > 0)
{
Instruction before = instructions.get(i - 1);
if (!forceCreate && before instanceof Label)
{
return (Label) before;
}
}
Label label = new Label(this);
label.setLabel(new org.objectweb.asm.Label());
instructions.add(i, label);
labelMap.put(label.getLabel(), label);
return label;
}
public Label findLabel(org.objectweb.asm.Label l)
{
Label label = labelMap.get(l);
assert label != null;
return label;
}
public Label findOrCreateLabel(org.objectweb.asm.Label l)
{
Label label = labelMap.get(l);
if (label != null)
{
return label;
}
label = new Label(this, l);
labelMap.put(l, label);
return label;
}
public void rebuildLabels()
{
labelMap.clear();
// ow2 asm requires new Labels each time you write out a class
// with ClassWriter, or else it crytpically fails
for (Instruction i : instructions)
{
if (i instanceof Label)
{
org.objectweb.asm.Label label = new org.objectweb.asm.Label();
((Label) i).setLabel(label);
labelMap.put(label, (Label) i);
}
}
}
public List<Instruction> getInstructions()
{
return instructions;
}
public void addInstruction(Instruction i)
{
assert i.getInstructions() == this;
instructions.add(i);
}
public void addInstruction(int idx, Instruction i)
{
assert i.getInstructions() == this;
instructions.add(idx, i);
}
public void remove(Instruction ins)
{
assert ins.getInstructions() == this;
ins.remove();
instructions.remove(ins);
ins.setInstructions(null);
}
public void clear()
{
for (Instruction ins : instructions)
{
ins.remove();
ins.setInstructions(null);
}
instructions.clear();
}
public Code getCode()
{
return code;
}
public void lookup()
{
for (Instruction i : instructions)
{
i.lookup();
}
}
public void regeneratePool()
{
for (Instruction i : instructions)
{
i.regeneratePool();
}
}
public int replace(Instruction oldi, Instruction newi)
{
assert oldi != newi;
assert oldi.getInstructions() == this;
assert newi.getInstructions() == this;
assert instructions.contains(oldi);
assert !instructions.contains(newi);
int i = instructions.indexOf(oldi);
instructions.remove(oldi);
oldi.setInstructions(null);
instructions.add(i, newi);
return i;
}
}

View File

@@ -0,0 +1,128 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code;
import net.runelite.asm.attributes.code.instructions.NOP;
import org.objectweb.asm.MethodVisitor;
public class Label extends NOP
{
private org.objectweb.asm.Label label;
private Integer lineNumber;
public Label(Instructions instructions)
{
super(instructions);
}
public Label(Instructions instructions, org.objectweb.asm.Label label)
{
super(instructions);
this.label = label;
}
@Override
public String toString()
{
String string;
if (this.getInstructions() == null)
{
string = "label <unattached>";
}
else
{
Instruction next = next();
if (next == null)
{
string = "label with no next instruction";
}
else
{
string = "label " + next.toString();
}
}
if (lineNumber != null)
{
string += " on line number " + lineNumber;
}
return string;
}
@Override
public Instruction clone()
{
Label l = (Label) super.clone();
l.label = new org.objectweb.asm.Label();
l.lineNumber = lineNumber;
return l;
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitLabel(label);
if (lineNumber != null)
{
visitor.visitLineNumber(lineNumber, label);
}
}
public org.objectweb.asm.Label getLabel()
{
return label;
}
public void setLabel(org.objectweb.asm.Label label)
{
this.label = label;
}
public void setLineNumber(Integer lineNumber)
{
this.lineNumber = lineNumber;
}
public Instruction next()
{
Instructions ins = this.getInstructions();
int i = ins.getInstructions().indexOf(this);
assert i != -1;
Instruction next;
do
{
next = ins.getInstructions().get(i + 1);
++i;
}
while (next instanceof Label);
return next;
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2018 Morgan Lewis <http://github.com/MESLewis>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code;
import org.objectweb.asm.Label;
public class LocalVariable
{
private final String name;
private final String desc;
private final String signature;
private final Label start;
private final Label end;
private final int index;
public LocalVariable(String name, String desc, String signature, Label start, Label end, int index)
{
this.name = name;
this.desc = desc;
this.signature = signature;
this.start = start;
this.end = end;
this.index = index;
}
public String getName()
{
return name;
}
public String getDesc()
{
return desc;
}
public String getSignature()
{
return signature;
}
public Label getStart()
{
return start;
}
public Label getEnd()
{
return end;
}
public int getIndex()
{
return index;
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2018 Morgan Lewis <http://github.com/MESLewis>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code;
public class Parameter
{
private final String name;
private final int access;
private LocalVariable localVariable;
public Parameter(String name, int access)
{
this.name = name;
this.access = access;
}
public String getName()
{
return name;
}
public int getAccess()
{
return access;
}
public LocalVariable getLocalVariable()
{
return localVariable;
}
public void setLocalVariable(LocalVariable localVariable)
{
this.localVariable = localVariable;
}
}

View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.asm.Field;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
import net.runelite.deob.deobfuscators.mapping.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public interface AdditionInstruction extends MappableInstruction
{
default InstructionContext findArrayLoad(InstructionContext ic1, InstructionContext ic2)
{
Instruction i1 = ic1.getInstruction();
Instruction i2 = ic2.getInstruction();
if (i1 instanceof ArrayLoad && !(i2 instanceof ArrayLoad))
{
return ic1;
}
if (i2 instanceof ArrayLoad && !(i1 instanceof ArrayLoad))
{
return ic2;
}
return null;
}
@Override
default void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other)
{
/* lhs/rhs of addition instructions are randomally swapped, but
* we still map if each side is recognizable
*
* N.B. since the lhs/rhs of nested iadds can be swapped, and
* the mapper maps the first that it encounters, this can certainly
* attempt to map the wrong instructions even when mapping the correct
* method, so be careful.
*/
StackContext ctx1 = ctx.getPops().get(0);
StackContext ctx2 = ctx.getPops().get(1);
StackContext other1 = other.getPops().get(0);
StackContext other2 = other.getPops().get(1);
InstructionContext rc1 = ctx1.getPushed().resolve(ctx1);
InstructionContext rc2 = ctx2.getPushed().resolve(ctx2); //iaload
InstructionContext ro1 = other1.getPushed().resolve(other1);
InstructionContext ro2 = other2.getPushed().resolve(other2); //iaload
// There are a couple static final arrays that are only ever read from 1 or 2 places.. and never written
InstructionContext al1 = findArrayLoad(rc1, rc2);
InstructionContext al2 = findArrayLoad(ro1, ro2);
if (al1 == null || al2 == null)
{
return;
}
StackContext array1 = al1.getPops().get(1);
StackContext array2 = al2.getPops().get(1);
InstructionContext field1 = array1.getPushed().resolve(array1);
InstructionContext field2 = array2.getPushed().resolve(array2);
if (!(field1.getInstruction() instanceof GetFieldInstruction) || !(field2.getInstruction() instanceof GetFieldInstruction))
{
return;
}
GetFieldInstruction gf1 = (GetFieldInstruction) field1.getInstruction();
GetFieldInstruction gf2 = (GetFieldInstruction) field2.getInstruction();
Field f1 = gf1.getMyField();
Field f2 = gf2.getMyField();
if (f1 == null || f2 == null || !MappingExecutorUtil.isMaybeEqual(f1, f2))
{
return;
}
mappings.map((Instruction) this, f1, f2);
}
@Override
default boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
return this.getClass() == otherIc.getInstruction().getClass();
}
@Override
default boolean canMap(InstructionContext thisIc)
{
return true;
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
import net.runelite.deob.deobfuscators.mapping.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public interface ArrayLoad extends MappableInstruction
{
@Override
default void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other)
{
StackContext index1 = ctx.getPops().get(0),
index2 = other.getPops().get(0);
InstructionContext ctx1 = MappingExecutorUtil.resolve(index1.getPushed(), index1),
ctx2 = MappingExecutorUtil.resolve(index2.getPushed(), index2);
assert ctx1.getInstruction() instanceof GetFieldInstruction;
assert ctx2.getInstruction() instanceof GetFieldInstruction;
GetFieldInstruction gf1 = (GetFieldInstruction) ctx1.getInstruction();
GetFieldInstruction gf2 = (GetFieldInstruction) ctx2.getInstruction();
mappings.map((Instruction) this, gf1.getMyField(), gf2.getMyField());
}
@Override
default boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
if (thisIc.getInstruction().getType() != otherIc.getInstruction().getType())
{
return false;
}
StackContext index1 = thisIc.getPops().get(0),
index2 = otherIc.getPops().get(0);
InstructionContext ctx1 = MappingExecutorUtil.resolve(index1.getPushed(), index1),
ctx2 = MappingExecutorUtil.resolve(index2.getPushed(), index2);
assert ctx1.getInstruction() instanceof GetFieldInstruction;
assert ctx2.getInstruction() instanceof GetFieldInstruction;
GetFieldInstruction gf1 = (GetFieldInstruction) ctx1.getInstruction();
GetFieldInstruction gf2 = (GetFieldInstruction) ctx2.getInstruction();
return MappingExecutorUtil.isMaybeEqual(gf1.getMyField(), gf2.getMyField());
}
@Override
default boolean canMap(InstructionContext thisIc)
{
// assume that obfuscation can't remove a load with a variable
// index. map field access.
StackContext index = thisIc.getPops().get(0);
InstructionContext ctx = MappingExecutorUtil.resolve(index.getPushed(), index);
return ctx.getInstruction() instanceof GetFieldInstruction;
}
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
public interface ArrayStoreInstruction extends MappableInstruction
{
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
public interface ComparisonInstruction
{
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
public interface ConversionInstruction
{
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.asm.Field;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
import net.runelite.deob.deobfuscators.mapping.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public interface DivisionInstruction extends MappableInstruction
{
@Override
default void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other)
{
StackContext s1 = ctx.getPops().get(0),
s2 = ctx.getPops().get(1);
StackContext o1 = other.getPops().get(0),
o2 = other.getPops().get(1);
InstructionContext i1 = MappingExecutorUtil.resolve(s1.getPushed(), s1);
InstructionContext i2 = MappingExecutorUtil.resolve(s2.getPushed(), s2);
InstructionContext io1 = MappingExecutorUtil.resolve(o1.getPushed(), o1);
InstructionContext io2 = MappingExecutorUtil.resolve(o2.getPushed(), o2);
if (i1.getInstruction() instanceof GetFieldInstruction && io1.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction f1 = (GetFieldInstruction) i1.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io1.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
if (fi1 != null && fi2 != null)
mappings.map((Instruction) this, fi1, fi2);
}
if (i2.getInstruction() instanceof GetFieldInstruction && io2.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction f1 = (GetFieldInstruction) i2.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io2.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
if (fi1 != null && fi2 != null)
mappings.map((Instruction) this, fi1, fi2);
}
}
@Override
default boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
return this.getClass() == otherIc.getInstruction().getClass();
}
@Override
default boolean canMap(InstructionContext thisIc)
{
return true;
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import java.util.List;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
public interface DupInstruction
{
StackContext getOriginal(StackContext sctx);
StackContext getOtherBranch(StackContext sctx);
/**
* get the duplicated stackcontexts (which is popped from this)
* @param ictx instruction context for this instruction
* @return
*/
List<StackContext> getDuplicated(InstructionContext ictx);
/**
* get the copied stackcontexts (pushed from this)
* @param ictx
* @return
*/
List<StackContext> getCopies(InstructionContext ictx);
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.asm.pool.Field;
public interface FieldInstruction
{
Field getField();
void setField(Field field);
net.runelite.asm.Field getMyField();
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
public interface GetFieldInstruction extends FieldInstruction
{
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
public interface IntInstruction
{
int getOperand();
void setOperand(int operand);
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import java.util.List;
import net.runelite.asm.Method;
public interface InvokeInstruction extends MappableInstruction
{
void removeParameter(int idx);
net.runelite.asm.pool.Method getMethod();
void setMethod(net.runelite.asm.pool.Method method);
List<Method> getMethods();
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import java.util.List;
import net.runelite.asm.attributes.code.Label;
public interface JumpingInstruction
{
List<Label> getJumps();
void setJumps(List<Label> labels);
void setLabel(org.objectweb.asm.Label label);
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.asm.attributes.code.Instruction;
public interface LVTInstruction
{
int getVariableIndex();
Instruction setVariableIndex(int idx);
boolean store();
LVTInstructionType type();
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
public enum LVTInstructionType
{
INT(1),
LONG(2),
FLOAT(1),
DOUBLE(2),
OBJECT(1);
private final int slots;
private LVTInstructionType(int slots)
{
this.slots = slots;
}
public int getSlots()
{
return slots;
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public interface MappableInstruction
{
void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other);
boolean isSame(InstructionContext thisIc, InstructionContext otherIc);
boolean canMap(InstructionContext thisIc);
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.asm.attributes.code.Instruction;
public interface PushConstantInstruction
{
Object getConstant();
Instruction setConstant(Object entry);
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
public interface ReturnInstruction
{
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
public interface SetFieldInstruction extends FieldInstruction, MappableInstruction
{
}

View File

@@ -0,0 +1,136 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.asm.Field;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
import net.runelite.deob.deobfuscators.mapping.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public interface SubtractionInstruction extends MappableInstruction
{
@Override
default void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other)
{
StackContext s1 = ctx.getPops().get(0),
s2 = ctx.getPops().get(1);
StackContext o1 = other.getPops().get(0),
o2 = other.getPops().get(1);
InstructionContext i1 = MappingExecutorUtil.resolve(s1.getPushed(), s1);
InstructionContext i2 = MappingExecutorUtil.resolve(s2.getPushed(), s2);
InstructionContext io1 = MappingExecutorUtil.resolve(o1.getPushed(), o1);
InstructionContext io2 = MappingExecutorUtil.resolve(o2.getPushed(), o2);
if (i1.getInstruction() instanceof GetFieldInstruction && io1.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction f1 = (GetFieldInstruction) i1.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io1.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
assert MappingExecutorUtil.isMaybeEqual(fi1, fi2);
if (fi1 != null && fi2 != null)
{
mappings.map((Instruction) this, fi1, fi2);
}
}
if (i2.getInstruction() instanceof GetFieldInstruction && io2.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction f1 = (GetFieldInstruction) i2.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io2.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
assert MappingExecutorUtil.isMaybeEqual(fi1, fi2);
if (fi1 != null && fi2 != null)
{
mappings.map((Instruction) this, fi1, fi2);
}
}
}
@Override
default boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
if (this.getClass() != otherIc.getInstruction().getClass())
{
return false;
}
StackContext s1 = thisIc.getPops().get(0),
s2 = thisIc.getPops().get(1);
StackContext o1 = otherIc.getPops().get(0),
o2 = otherIc.getPops().get(1);
InstructionContext i1 = MappingExecutorUtil.resolve(s1.getPushed(), s1);
InstructionContext i2 = MappingExecutorUtil.resolve(s2.getPushed(), s2);
InstructionContext io1 = MappingExecutorUtil.resolve(o1.getPushed(), o1);
InstructionContext io2 = MappingExecutorUtil.resolve(o2.getPushed(), o2);
if (i1.getInstruction() instanceof GetFieldInstruction && io1.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction f1 = (GetFieldInstruction) i1.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io1.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
if (!MappingExecutorUtil.isMaybeEqual(fi1, fi2))
{
return false;
}
}
if (i2.getInstruction() instanceof GetFieldInstruction && io2.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction f1 = (GetFieldInstruction) i2.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io2.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
if (!MappingExecutorUtil.isMaybeEqual(fi1, fi2))
{
return false;
}
}
return true;
}
@Override
default boolean canMap(InstructionContext thisIc)
{
return true;
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.asm.Type;
public interface TypeInstruction
{
Type getType_();
void setType(Type type);
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ArrayLoad;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class AALoad extends Instruction implements ArrayLoad
{
public AALoad(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(index, array);
Type subtype;
if (array.getType().isArray())
{
subtype = array.getType().getSubtype();
}
else
{
// This will happen from aaloading from a aconst_null
subtype = array.getType();
}
StackContext ctx = new StackContext(ins, subtype, array.getValue().arrayGet(index.getValue()));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class AAStore extends ArrayStore
{
public AAStore(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(value, index, array);
array.getValue().arraySet(index.getValue(), value.getValue());
return ins;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class AConstNull extends Instruction
{
public AConstNull(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public AConstNull(Instructions instructions)
{
super(instructions, InstructionType.ACONST_NULL);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext ctx = new StackContext(ins, Type.OBJECT, Value.NULL);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.attributes.code.instruction.types.LVTInstructionType;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.VariableContext;
import net.runelite.asm.execution.Variables;
import org.objectweb.asm.MethodVisitor;
public class ALoad extends Instruction implements LVTInstruction
{
private int index;
public ALoad(Instructions instructions, int index)
{
super(instructions, InstructionType.ALOAD);
this.index = index;
}
public ALoad(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitVarInsn(this.getType().getCode(), this.getVariableIndex());
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
Variables var = frame.getVariables();
VariableContext vctx = var.get(index);
ins.read(vctx);
StackContext ctx = new StackContext(ins, vctx);
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public int getVariableIndex()
{
return index;
}
@Override
public boolean store()
{
return false;
}
@Override
public Instruction setVariableIndex(int idx)
{
index = idx;
return this;
}
@Override
public LVTInstructionType type()
{
return LVTInstructionType.OBJECT;
}
}

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.TypeInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
import org.objectweb.asm.MethodVisitor;
public class ANewArray extends Instruction implements TypeInstruction
{
private Type type;
private ClassFile myClass;
public ANewArray(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitTypeInsn(this.getType().getCode(), type.toAsmString());
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext count = stack.pop();
ins.pop(count);
StackContext ctx = new StackContext(ins, type, Value.newArray(count.getValue()));
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public void lookup()
{
ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
myClass = group.findClass(type.getInternalName());
}
@Override
public void regeneratePool()
{
if (myClass != null)
{
int dimms = type.getDimensions();
type = Type.getType("L" + myClass.getName() + ";", dimms);
}
}
@Override
public Type getType_()
{
return type;
}
@Override
public void setType(Type type)
{
this.type = type;
}
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.attributes.code.instruction.types.LVTInstructionType;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.VariableContext;
import net.runelite.asm.execution.Variables;
import org.objectweb.asm.MethodVisitor;
public class AStore extends Instruction implements LVTInstruction
{
private int index;
public AStore(Instructions instructions, int index)
{
super(instructions, InstructionType.ASTORE);
this.index = index;
}
public AStore(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitVarInsn(this.getType().getCode(), this.getVariableIndex());
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
Variables variables = frame.getVariables();
StackContext object = stack.pop();
ins.pop(object);
variables.set(index, new VariableContext(ins, object));
return ins;
}
@Override
public int getVariableIndex()
{
return index;
}
@Override
public boolean store()
{
return true;
}
@Override
public Instruction setVariableIndex(int idx)
{
index = idx;
return this;
}
@Override
public LVTInstructionType type()
{
return LVTInstructionType.OBJECT;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class AThrow extends Instruction
{
public AThrow(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
// get exception
StackContext exception = stack.pop();
ins.pop(exception);
frame.stop();
return ins;
}
@Override
public boolean isTerminal()
{
return true;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class ArrayLength extends Instruction
{
public ArrayLength(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext array = stack.pop();
ins.pop(array);
StackContext ctx = new StackContext(ins, Type.INT, array.getValue().arrayLength());
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,140 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Field;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ArrayStoreInstruction;
import net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
import net.runelite.deob.deobfuscators.mapping.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public abstract class ArrayStore extends Instruction implements ArrayStoreInstruction
{
public ArrayStore(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public Field getMyField(InstructionContext thisIc)
{
StackContext sctx = thisIc.getPops().get(2);
InstructionContext pushed = sctx.getPushed();
InstructionContext r = pushed.resolve(sctx);
if (r.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction gf = (GetFieldInstruction) r.getInstruction();
Field f = gf.getMyField();
return f;
}
return null;
}
@Override
public boolean canMap(InstructionContext thisIc)
{
return getMyField(thisIc) != null;
}
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other)
{
assert ctx.getInstruction().getClass() == other.getInstruction().getClass();
Field myField = this.getMyField(ctx),
otherField = ((ArrayStore) other.getInstruction()).getMyField(other);
mapping.map(this, myField, otherField);
// map value
StackContext object1 = ctx.getPops().get(0), // value set to.
object2 = other.getPops().get(0);
InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1);
InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2);
if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(),
gf2 = (GetFieldInstruction) base2.getInstruction();
Field f1 = gf1.getMyField(),
f2 = gf2.getMyField();
assert MappingExecutorUtil.isMaybeEqual(f1, f2);
if (f1 != null && f2 != null)
{
mapping.map(this, f1, f2);
}
}
}
@Override
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
if (thisIc.getInstruction().getClass() != otherIc.getInstruction().getClass())
{
return false;
}
Field myField = this.getMyField(thisIc),
otherField = ((ArrayStore) otherIc.getInstruction()).getMyField(otherIc);
if (!MappingExecutorUtil.isMaybeEqual(myField, otherField))
{
return false;
}
StackContext object1 = thisIc.getPops().get(0), // value set to.
object2 = otherIc.getPops().get(0);
InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1);
InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2);
if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(),
gf2 = (GetFieldInstruction) base2.getInstruction();
Field f1 = gf1.getMyField(),
f2 = gf2.getMyField();
if (!MappingExecutorUtil.isMaybeEqual(f1, f2))
{
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ArrayLoad;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class BALoad extends Instruction implements ArrayLoad
{
public BALoad(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(index, array);
StackContext ctx = new StackContext(ins, Type.INT, array.getValue().arrayGet(index.getValue()).cast(int.class)); // sign extend
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class BAStore extends ArrayStore
{
public BAStore(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(value, index, array);
array.getValue().arraySet(index.getValue(), value.getValue());
return ins;
}
}

View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.IntInstruction;
import net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
import org.objectweb.asm.MethodVisitor;
public class BiPush extends Instruction implements PushConstantInstruction, IntInstruction
{
private byte b;
public BiPush(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public BiPush(Instructions instructions, byte b)
{
super(instructions, InstructionType.BIPUSH);
this.b = b;
}
@Override
public String toString()
{
return "bipush " + b;
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitIntInsn(this.getType().getCode(), b);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext ctx = new StackContext(ins, Type.INT, new Value((int) b)); // bipush sign extends the value to an int
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public Object getConstant()
{
return b;
}
@Override
public Instruction setConstant(Object entry)
{
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public int getOperand()
{
return b & 0xFF;
}
@Override
public void setOperand(int operand)
{
b = (byte) operand;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ArrayLoad;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class CALoad extends Instruction implements ArrayLoad
{
public CALoad(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(index, array);
StackContext ctx = new StackContext(ins, Type.INT, array.getValue().arrayGet(index.getValue()).cast(int.class)); // zero extended to int
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class CAStore extends ArrayStore
{
public CAStore(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(value, index, array);
array.getValue().arraySet(index.getValue(), value.getValue());
return ins;
}
}

View File

@@ -0,0 +1,110 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.TypeInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import org.objectweb.asm.MethodVisitor;
public class CheckCast extends Instruction implements TypeInstruction
{
private Type type;
private ClassFile myClass;
public CheckCast(Instructions instructions)
{
super(instructions, InstructionType.CHECKCAST);
}
public CheckCast(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitTypeInsn(this.getType().getCode(), type.toAsmString());
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
ins.pop(value);
StackContext ctx = new StackContext(ins,
type,
value.getValue()
);
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public void lookup()
{
ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
myClass = group.findClass(type.getInternalName());
}
@Override
public void regeneratePool()
{
if (myClass != null)
{
int dimms = type.getDimensions();
type = Type.getType("L" + myClass.getName() + ";", dimms);
}
}
@Override
public Type getType_()
{
return type;
}
@Override
public void setType(Type type)
{
this.type = type;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class D2F extends Instruction implements ConversionInstruction
{
public D2F(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
ins.pop(value);
StackContext ctx = new StackContext(ins, Type.FLOAT, value.getValue().cast(float.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class D2I extends Instruction implements ConversionInstruction
{
public D2I(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
ins.pop(value);
StackContext ctx = new StackContext(ins, Type.INT, value.getValue().cast(int.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class D2L extends Instruction implements ConversionInstruction
{
public D2L(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
ins.pop(value);
StackContext ctx = new StackContext(ins, Type.LONG, value.getValue().cast(long.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ArrayLoad;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class DALoad extends Instruction implements ArrayLoad
{
public DALoad(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(index, array);
StackContext ctx = new StackContext(ins, Type.DOUBLE, array.getValue().arrayGet(index.getValue()).cast(double.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class DAStore extends ArrayStore
{
public DAStore(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(value, index, array);
array.getValue().arraySet(index.getValue(), value.getValue());
return ins;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.AdditionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class DAdd extends Instruction implements AdditionInstruction
{
public DAdd(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
double d2 = (double) two.getValue().getValue(),
d1 = (double) one.getValue().getValue();
result = new Value(d1 + d2);
}
StackContext ctx = new StackContext(ins, Type.DOUBLE, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class DCmpG extends Instruction
{
public DCmpG(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
double d2 = (double) two.getValue().getValue(),
d1 = (double) one.getValue().getValue();
if (d1 > d2)
result = new Value(1);
else if (d1 == d2)
result = new Value(0);
else if (d1 < d2)
result = new Value(-1);
}
StackContext ctx = new StackContext(ins, Type.INT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class DCmpL extends Instruction
{
public DCmpL(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
double d2 = (double) two.getValue().getValue(),
d1 = (double) one.getValue().getValue();
if (d1 > d2)
result = new Value(1);
else if (d1 == d2)
result = new Value(0);
else if (d1 < d2)
result = new Value(-1);
}
StackContext ctx = new StackContext(ins, Type.INT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.DivisionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class DDiv extends Instruction implements DivisionInstruction
{
public DDiv(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
double d2 = (double) two.getValue().getValue(),
d1 = (double) one.getValue().getValue();
if (d2 != 0.0d)
result = new Value(d1 / d2);
}
StackContext ctx = new StackContext(ins, Type.DOUBLE, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.attributes.code.instruction.types.LVTInstructionType;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.VariableContext;
import net.runelite.asm.execution.Variables;
import org.objectweb.asm.MethodVisitor;
public class DLoad extends Instruction implements LVTInstruction
{
private int index;
public DLoad(Instructions instructions, int index)
{
super(instructions, InstructionType.DLOAD);
this.index = index;
}
public DLoad(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitVarInsn(this.getType().getCode(), this.getVariableIndex());
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
Variables variables = frame.getVariables();
VariableContext vctx = variables.get(index);
assert vctx.getType().equals(Type.DOUBLE);
ins.read(vctx);
StackContext ctx = new StackContext(ins, vctx);
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public int getVariableIndex()
{
return index;
}
@Override
public boolean store()
{
return false;
}
@Override
public Instruction setVariableIndex(int idx)
{
index = idx;
return this;
}
@Override
public LVTInstructionType type()
{
return LVTInstructionType.DOUBLE;
}
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class DMul extends Instruction
{
public DMul(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
double d2 = (double) two.getValue().getValue(),
d1 = (double) one.getValue().getValue();
result = new Value(d1 * d2);
}
StackContext ctx = new StackContext(ins, Type.DOUBLE, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class DNeg extends Instruction
{
public DNeg(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
ins.pop(value);
Value result = Value.UNKNOWN;
if (!value.getValue().isUnknownOrNull())
{
double d = (double) value.getValue().getValue();
result = new Value(-d);
}
StackContext ctx = new StackContext(ins, Type.DOUBLE, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class DRem extends Instruction
{
public DRem(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
double d2 = (double) two.getValue().getValue(),
d1 = (double) one.getValue().getValue();
if (d2 != 0.0d)
result = new Value(d1 % d2);
}
StackContext ctx = new StackContext(ins, Type.DOUBLE, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.attributes.code.instruction.types.LVTInstructionType;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.VariableContext;
import net.runelite.asm.execution.Variables;
import org.objectweb.asm.MethodVisitor;
public class DStore extends Instruction implements LVTInstruction
{
private int index;
public DStore(Instructions instructions, int index)
{
super(instructions, InstructionType.DSTORE);
this.index = index;
}
public DStore(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitVarInsn(this.getType().getCode(), this.getVariableIndex());
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
Variables variables = frame.getVariables();
StackContext value = stack.pop();
ins.pop(value);
variables.set(index, new VariableContext(ins, value));
return ins;
}
@Override
public int getVariableIndex()
{
return index;
}
@Override
public boolean store()
{
return true;
}
@Override
public Instruction setVariableIndex(int idx)
{
index = idx;
return this;
}
@Override
public LVTInstructionType type()
{
return LVTInstructionType.DOUBLE;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.SubtractionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class DSub extends Instruction implements SubtractionInstruction
{
public DSub(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
double d2 = (double) two.getValue().getValue(),
d1 = (double) one.getValue().getValue();
result = new Value(d1 - d2);
}
StackContext ctx = new StackContext(ins, Type.DOUBLE, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,127 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.DupInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class Dup extends Instruction implements DupInstruction
{
public Dup(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public Dup(Instructions instructions)
{
super(instructions, InstructionType.DUP);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext obj = stack.pop();
ins.pop(obj);
StackContext ctx = new StackContext(ins, obj.getType(), obj.getValue());
stack.push(ctx);
ins.push(ctx);
ctx = new StackContext(ins, obj.getType(), obj.getValue());
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public boolean removeStack()
{
// removing something from the stack this pushed at index 'idx'
// idx = 0 is top of the stack, goes up.
//
// the stack is relative to post-execute of this instruction
// for dup, to remove one of the things pushed by it you simply
// remove the dup instruction
super.removeStack();
// do not continue as the other branch still uses what we left
// usually this is for new dup invokespecial and we end up with
// an unused new/invokesepcial
return false;
}
@Override
public StackContext getOriginal(StackContext sctx)
{
// ctx = stack pushed by this instruction, return stack popped by this instruction
InstructionContext ctx = sctx.getPushed();
assert ctx.getInstruction() == this;
assert ctx.getPushes().contains(sctx);
return ctx.getPops().get(0);
}
@Override
public StackContext getOtherBranch(StackContext sctx)
{
InstructionContext ctx = sctx.getPushed();
assert ctx.getInstruction() == this;
List<StackContext> pushes = ctx.getPushes();
assert pushes.contains(sctx);
int idx = pushes.indexOf(sctx);
assert idx == 0 || idx == 1;
return pushes.get(~idx & 1);
}
@Override
public List<StackContext> getDuplicated(InstructionContext ictx)
{
assert ictx.getInstruction() == this;
return new ArrayList<>(ictx.getPops());
}
@Override
public List<StackContext> getCopies(InstructionContext ictx)
{
return new ArrayList<>(ictx.getPushes());
}
}

View File

@@ -0,0 +1,142 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.DupInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class Dup2 extends Instruction implements DupInstruction
{
public Dup2(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext one = stack.pop();
StackContext two = null;
if (one.getType().getSize() == 1)
two = stack.pop();
ins.pop(one);
if (two != null)
ins.pop(two);
if (two != null)
{
StackContext ctx = new StackContext(ins, two.getType(), two.getValue());
stack.push(ctx);
ins.push(ctx);
}
StackContext ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(one);
ins.push(ctx);
if (two != null)
{
ctx = new StackContext(ins, two.getType(), two.getValue());
stack.push(ctx);
ins.push(ctx);
}
ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(one);
ins.push(ctx);
return ins;
}
@Override
public boolean removeStack()
{
throw new UnsupportedOperationException();
}
@Override
public StackContext getOriginal(StackContext sctx)
{
// 2 1 -> 2 1 2 1 OR 1 -> 1 1
InstructionContext ctx = sctx.getPushed();
assert ctx.getPops().size() == 2 || ctx.getPops().size() == 1;
assert ctx.getInstruction() == this;
assert ctx.getPushes().contains(sctx);
int idx = ctx.getPushes().indexOf(sctx);
if (ctx.getPops().size() == 1)
{
return ctx.getPops().get(0);
}
switch (idx)
{
case 0:
case 2:
return ctx.getPops().get(1);
case 1:
case 4:
return ctx.getPops().get(0);
default:
throw new IllegalStateException();
}
}
@Override
public StackContext getOtherBranch(StackContext sctx)
{
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public List<StackContext> getDuplicated(InstructionContext ictx)
{
return new ArrayList<>(ictx.getPops());
}
@Override
public List<StackContext> getCopies(InstructionContext ictx)
{
return new ArrayList<>(ictx.getPushes());
}
}

View File

@@ -0,0 +1,262 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import java.util.Arrays;
import java.util.List;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.DupInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class Dup2_X1 extends Instruction implements DupInstruction
{
public Dup2_X1(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public Dup2_X1(Instructions instructions)
{
super(instructions, InstructionType.DUP2_X1);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext one = stack.pop();
StackContext two = null;
if (one.getType().getSize() == 1)
two = stack.pop();
StackContext three = stack.pop();
ins.pop(one);
if (two != null)
ins.pop(two);
ins.pop(three);
if (two != null)
{
StackContext ctx = new StackContext(ins, two.getType(), two.getValue());
stack.push(ctx);
ins.push(ctx);
}
StackContext ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(ctx);
ins.push(ctx);
ctx = new StackContext(ins, three.getType(), three.getValue());
stack.push(ctx);
ins.push(ctx);
if (two != null)
{
ctx = new StackContext(ins, two.getType(), two.getValue());
stack.push(ctx);
ins.push(ctx);
}
ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public boolean removeStack()
{
throw new UnsupportedOperationException();
}
@Override
public StackContext getOriginal(StackContext sctx)
{
InstructionContext ctx = sctx.getPushed();
assert ctx.getInstruction() == this;
assert ctx.getPushes().contains(sctx);
int idx = ctx.getPushes().indexOf(sctx);
// 2 1 0 -> 1 0 2 1 0 OR 1 0 -> 0 1 0
assert ctx.getPushes().size() == 5 || ctx.getPushes().size() == 3;
int orig;
if (ctx.getPushes().size() == 5)
{
switch (idx)
{
case 0:
orig = 1;
break;
case 1:
orig = 0;
break;
case 2:
orig = 2;
break;
case 3:
orig = 1;
break;
case 4:
orig = 0;
break;
default:
throw new IllegalStateException();
}
}
else if (ctx.getPushes().size() == 3)
{
switch (idx)
{
case 0:
orig = 0;
break;
case 1:
orig = 1;
break;
case 2:
orig = 0;
break;
default:
throw new IllegalStateException();
}
}
else
{
throw new IllegalStateException();
}
return ctx.getPops().get(orig);
}
@Override
public StackContext getOtherBranch(StackContext sctx)
{
InstructionContext ctx = sctx.getPushed();
assert ctx.getInstruction() == this;
assert ctx.getPushes().contains(sctx);
int idx = ctx.getPushes().indexOf(sctx);
// 2 1 0 -> 1 0 2 1 0 OR 1 0 -> 0 1 0
int other;
if (ctx.getPushes().size() == 5)
{
switch (idx)
{
case 0:
other = 3;
break;
case 1:
other = 4;
break;
case 3:
other = 0;
break;
case 4:
other = 1;
break;
default:
return null;
}
}
else if (ctx.getPushes().size() == 3)
{
switch (idx)
{
case 0:
other = 2;
break;
case 2:
other = 0;
break;
default:
return null;
}
}
else
{
throw new IllegalStateException();
}
return ctx.getPushes().get(other);
}
@Override
public List<StackContext> getDuplicated(InstructionContext ictx)
{
if (ictx.getPushes().size() == 5)
{
// 0, 1
return Arrays.asList(ictx.getPops().get(0), ictx.getPops().get(1));
}
else if (ictx.getPushes().size() == 3)
{
// 0
return Arrays.asList(ictx.getPops().get(0));
}
else
{
throw new IllegalStateException();
}
}
@Override
public List<StackContext> getCopies(InstructionContext ictx)
{
if (ictx.getPushes().size() == 5)
{
return Arrays.asList(ictx.getPushes().get(0), ictx.getPushes().get(1));
}
else if (ictx.getPushes().size() == 3)
{
// 0
return Arrays.asList(ictx.getPushes().get(0));
}
else
{
throw new IllegalStateException();
}
}
}

View File

@@ -0,0 +1,138 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import java.util.List;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.DupInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class Dup2_X2 extends Instruction implements DupInstruction
{
public Dup2_X2(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext one = stack.pop();
StackContext two = null;
if (one.getType().getSize() == 1)
two = stack.pop();
StackContext three = stack.pop();
StackContext four = null;
if (one.getType().getSize() == 1)
four = stack.pop();
ins.pop(one);
if (two != null)
ins.pop(two);
ins.pop(three);
if (four != null)
ins.pop(four);
if (two != null)
{
StackContext ctx = new StackContext(ins, two.getType(), two.getValue());
stack.push(ctx);
ins.push(ctx);
}
StackContext ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(one);
ins.push(ctx);
if (four != null)
{
ctx = new StackContext(ins, four.getType(), four.getValue());
stack.push(ctx);
ins.push(ctx);
}
ctx = new StackContext(ins, three.getType(), three.getValue());
stack.push(one);
ins.push(ctx);
if (two != null)
{
ctx = new StackContext(ins, two.getType(), two.getValue());
stack.push(ctx);
ins.push(ctx);
}
ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(one);
ins.push(ctx);
return ins;
}
@Override
public boolean removeStack()
{
throw new UnsupportedOperationException();
}
@Override
public StackContext getOriginal(StackContext ctx)
{
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public StackContext getOtherBranch(StackContext sctx)
{
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public List<StackContext> getDuplicated(InstructionContext ictx)
{
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public List<StackContext> getCopies(InstructionContext ictx)
{
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}

View File

@@ -0,0 +1,152 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import java.util.Arrays;
import java.util.List;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.DupInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class Dup_X1 extends Instruction implements DupInstruction
{
public Dup_X1(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public Dup_X1(Instructions instructions)
{
super(instructions, InstructionType.DUP_X1);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext one = stack.pop();
StackContext two = stack.pop();
ins.pop(one, two);
StackContext ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(ctx);
ins.push(ctx);
ctx = new StackContext(ins, two.getType(), two.getValue());
stack.push(ctx);
ins.push(ctx);
ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public boolean removeStack()
{
throw new UnsupportedOperationException();
}
@Override
public StackContext getOriginal(StackContext sctx)
{
// ctx = stack pushed by this instruction, return stack popped by this instruction
InstructionContext ctx = sctx.getPushed();
assert ctx.getInstruction() == this;
assert ctx.getPushes().contains(sctx);
int pushedIndex = ctx.getPushes().indexOf(sctx);
int poppedIndex;
// 2 1 -> 1 2 1
// index 0 is 0, index 1 is 1, index 2 is 2
switch (pushedIndex)
{
case 0:
case 2:
poppedIndex = 0;
break;
case 1:
poppedIndex = 1;
break;
default:
throw new IllegalStateException();
}
// get popped ctx
return ctx.getPops().get(poppedIndex);
}
@Override
public StackContext getOtherBranch(StackContext sctx)
{
// sctx = stack pushed by this instruction, return the other branch
InstructionContext ctx = sctx.getPushed();
assert ctx.getInstruction() == this;
assert ctx.getPushes().contains(sctx);
int pushedIndex = ctx.getPushes().indexOf(sctx);
// 2 1 -> 1 2 1
// if pushed index is 0 or 2, return other, if 1 there is no other side
assert pushedIndex >= 0 && pushedIndex <= 2;
if (pushedIndex == 0)
return ctx.getPushes().get(2);
else if (pushedIndex == 2)
return ctx.getPushes().get(0);
return null;
}
@Override
public List<StackContext> getDuplicated(InstructionContext ictx)
{
assert ictx.getInstruction() == this;
return Arrays.asList(ictx.getPops().get(0));
}
@Override
public List<StackContext> getCopies(InstructionContext ictx)
{
return Arrays.asList(ictx.getPushes().get(0), ictx.getPushes().get(2));
}
}

View File

@@ -0,0 +1,155 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import java.util.Arrays;
import java.util.List;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.DupInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class Dup_X2 extends Instruction implements DupInstruction
{
public Dup_X2(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext one = stack.pop();
StackContext two = stack.pop();
StackContext three = null;
if (two.getType().getSize() == 1)
three = stack.pop();
ins.pop(one, two);
if (three != null)
ins.pop(three);
StackContext ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(ctx);
ins.push(ctx);
if (three != null)
{
ctx = new StackContext(ins, three.getType(), three.getValue());
stack.push(ctx);
ins.push(ctx);
}
ctx = new StackContext(ins, two.getType(), two.getValue());
stack.push(ctx);
ins.push(ctx);
ctx = new StackContext(ins, one.getType(), one.getValue());
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public boolean removeStack()
{
throw new UnsupportedOperationException();
}
@Override
public StackContext getOriginal(StackContext sctx)
{
// 3 2 1 -> 1 3 2 1
InstructionContext ctx = sctx.getPushed();
assert ctx.getInstruction() == this;
assert ctx.getPushes().contains(sctx);
int pushedIndex = ctx.getPushes().indexOf(sctx);
int poppedIndex;
switch (pushedIndex)
{
case 0:
case 3:
poppedIndex = 0;
break;
case 1:
poppedIndex = 2;
break;
case 2:
poppedIndex = 1;
break;
default:
throw new IllegalStateException();
}
return ctx.getPops().get(poppedIndex);
}
@Override
public StackContext getOtherBranch(StackContext sctx)
{
// sctx = stack pushed by this instruction, return the other branch
InstructionContext ctx = sctx.getPushed();
assert ctx.getInstruction() == this;
assert ctx.getPushes().contains(sctx);
int pushedIndex = ctx.getPushes().indexOf(sctx);
// 3 2 1 -> 1 3 2 1
if (pushedIndex == 0)
return ctx.getPushes().get(3);
else if (pushedIndex == 3)
return ctx.getPushes().get(0);
return null;
}
@Override
public List<StackContext> getDuplicated(InstructionContext ictx)
{
return Arrays.asList(ictx.getPops().get(0));
}
@Override
public List<StackContext> getCopies(InstructionContext ictx)
{
return Arrays.asList(ictx.getPushes().get(0));
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class F2D extends Instruction implements ConversionInstruction
{
public F2D(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, Type.DOUBLE, object.getValue().cast(double.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class F2I extends Instruction implements ConversionInstruction
{
public F2I(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, Type.INT, object.getValue().cast(int.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class F2L extends Instruction implements ConversionInstruction
{
public F2L(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, Type.LONG, object.getValue().cast(long.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ArrayLoad;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class FALoad extends Instruction implements ArrayLoad
{
public FALoad(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(index, array);
StackContext ctx = new StackContext(ins, Type.FLOAT, array.getValue().arrayGet(index.getValue()).cast(float.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class FAStore extends ArrayStore
{
public FAStore(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
StackContext index = stack.pop();
StackContext array = stack.pop();
ins.pop(value, index, array);
array.getValue().arraySet(index.getValue(), value.getValue());
return ins;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.AdditionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class FAdd extends Instruction implements AdditionInstruction
{
public FAdd(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
float f2 = (float) two.getValue().getValue(),
f1 = (float) one.getValue().getValue();
result = new Value(f1 + f2);
}
StackContext ctx = new StackContext(ins, Type.FLOAT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class FCmpG extends Instruction
{
public FCmpG(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
float f2 = (float) two.getValue().getValue(),
f1 = (float) one.getValue().getValue();
if (f1 > f2)
result = new Value(1);
else if (f1 == f2)
result = new Value(0);
else if (f1 < f2)
result = new Value(-1);
}
StackContext ctx = new StackContext(ins, Type.INT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class FCmpL extends Instruction
{
public FCmpL(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
float f2 = (float) two.getValue().getValue(),
f1 = (float) one.getValue().getValue();
if (f1 > f2)
result = new Value(1);
else if (f1 == f2)
result = new Value(0);
else if (f1 < f2)
result = new Value(-1);
}
StackContext ctx = new StackContext(ins, Type.INT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.DivisionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class FDiv extends Instruction implements DivisionInstruction
{
public FDiv(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
float f2 = (float) two.getValue().getValue(),
f1 = (float) one.getValue().getValue();
if (f2 != 0.0f)
result = new Value(f1 / f2);
}
StackContext ctx = new StackContext(ins, Type.FLOAT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.attributes.code.instruction.types.LVTInstructionType;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.VariableContext;
import net.runelite.asm.execution.Variables;
import org.objectweb.asm.MethodVisitor;
public class FLoad extends Instruction implements LVTInstruction
{
private int index;
public FLoad(Instructions instructions, int index)
{
super(instructions, InstructionType.FLOAD);
this.index = index;
}
public FLoad(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitVarInsn(this.getType().getCode(), this.getVariableIndex());
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
Variables variables = frame.getVariables();
VariableContext vctx = variables.get(index);
assert vctx.getType().equals(Type.FLOAT);
ins.read(vctx);
StackContext ctx = new StackContext(ins, vctx);
stack.push(ctx);
ins.push(ctx);
return ins;
}
@Override
public int getVariableIndex()
{
return index;
}
@Override
public boolean store()
{
return false;
}
@Override
public Instruction setVariableIndex(int idx)
{
index = idx;
return this;
}
@Override
public LVTInstructionType type()
{
return LVTInstructionType.FLOAT;
}
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class FMul extends Instruction
{
public FMul(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
float f2 = (float) two.getValue().getValue(),
f1 = (float) one.getValue().getValue();
result = new Value(f1 * f2);
}
StackContext ctx = new StackContext(ins, Type.FLOAT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class FNeg extends Instruction
{
public FNeg(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext value = stack.pop();
ins.pop(value);
Value result = Value.UNKNOWN;
if (!value.getValue().isUnknownOrNull())
{
float f = (float) value.getValue().getValue();
result = new Value(-f);
}
StackContext ctx = new StackContext(ins, Type.FLOAT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class FRem extends Instruction
{
public FRem(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
float f2 = (float) two.getValue().getValue(),
f1 = (float) one.getValue().getValue();
if (f2 != 0.0f)
result = new Value(f1 % f2);
}
StackContext ctx = new StackContext(ins, Type.FLOAT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.attributes.code.instruction.types.LVTInstructionType;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.VariableContext;
import net.runelite.asm.execution.Variables;
import org.objectweb.asm.MethodVisitor;
public class FStore extends Instruction implements LVTInstruction
{
private int index;
public FStore(Instructions instructions, int index)
{
super(instructions, InstructionType.FSTORE);
this.index = index;
}
public FStore(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitVarInsn(this.getType().getCode(), this.getVariableIndex());
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
Variables variables = frame.getVariables();
StackContext value = stack.pop();
ins.pop(value);
variables.set(index, new VariableContext(ins, value));
return ins;
}
@Override
public int getVariableIndex()
{
return index;
}
@Override
public boolean store()
{
return true;
}
@Override
public Instruction setVariableIndex(int idx)
{
index = idx;
return this;
}
@Override
public LVTInstructionType type()
{
return LVTInstructionType.FLOAT;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.SubtractionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
public class FSub extends Instruction implements SubtractionInstruction
{
public FSub(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext two = stack.pop();
StackContext one = stack.pop();
ins.pop(two, one);
Value result = Value.UNKNOWN;
if (!two.getValue().isUnknownOrNull() && !one.getValue().isUnknownOrNull())
{
float f2 = (float) two.getValue().getValue(),
f1 = (float) one.getValue().getValue();
result = new Value(f1 - f2);
}
StackContext ctx = new StackContext(ins, Type.FLOAT, result);
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,145 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.ClassFile;
import net.runelite.asm.Method;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
import net.runelite.asm.pool.Class;
import net.runelite.asm.pool.Field;
import org.objectweb.asm.MethodVisitor;
public class GetField extends Instruction implements GetFieldInstruction
{
private Field field;
private net.runelite.asm.Field myField;
public GetField(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public GetField(Instructions instructions, Field field)
{
super(instructions, InstructionType.GETFIELD);
this.field = field;
}
@Override
public String toString()
{
Method m = this.getInstructions().getCode().getMethod();
return "getfield " + myField + " in " + m;// + " at pc 0x" + Integer.toHexString(this.getPc());
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitFieldInsn(this.getType().getCode(),
field.getClazz().getName(),
field.getName(),
field.getType().toString()
);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, field.getType(), Value.UNKNOWN);
stack.push(ctx);
ins.push(ctx);
if (myField != null)
{
frame.getExecution().order(frame, myField);
}
return ins;
}
@Override
public Field getField()
{
return field;
}
@Override
public net.runelite.asm.Field getMyField()
{
Class clazz = field.getClazz();
ClassFile cf = this.getInstructions().getCode().getMethod().getClassFile().getGroup().findClass(clazz.getName());
if (cf == null)
{
return null;
}
net.runelite.asm.Field f2 = cf.findFieldDeep(field.getName(), field.getType());
return f2;
}
@Override
public void lookup()
{
myField = getMyField();
}
@Override
public void regeneratePool()
{
if (myField != null)
{
// only rebuild field info if the field has changed.
// otherwise it will rewrite the pool field into to something
// different if the field was deep
if (getMyField() != myField)
{
field = myField.getPoolField();
}
}
}
@Override
public void setField(Field field)
{
this.field = field;
}
}

View File

@@ -0,0 +1,139 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.ClassFile;
import net.runelite.asm.Method;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
import net.runelite.asm.execution.Value;
import net.runelite.asm.pool.Class;
import net.runelite.asm.pool.Field;
import org.objectweb.asm.MethodVisitor;
public class GetStatic extends Instruction implements GetFieldInstruction
{
private Field field;
private net.runelite.asm.Field myField;
public GetStatic(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public GetStatic(Instructions instructions, Field field)
{
super(instructions, InstructionType.GETSTATIC);
this.field = field;
}
@Override
public String toString()
{
Method m = this.getInstructions().getCode().getMethod();
return "getstatic " + myField + " in " + m;
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitFieldInsn(this.getType().getCode(),
field.getClazz().getName(),
field.getName(),
field.getType().toString()
);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext ctx = new StackContext(ins, field.getType(), Value.UNKNOWN);
stack.push(ctx);
ins.push(ctx);
if (myField != null)
{
frame.getExecution().order(frame, myField);
}
return ins;
}
@Override
public Field getField()
{
return field;
}
@Override
public net.runelite.asm.Field getMyField()
{
Class clazz = field.getClazz();
ClassFile cf = this.getInstructions().getCode().getMethod().getClassFile().getGroup().findClass(clazz.getName());
if (cf == null)
{
return null;
}
net.runelite.asm.Field f2 = cf.findFieldDeep(field.getName(), field.getType());
return f2;
}
@Override
public void lookup()
{
myField = this.getMyField();
}
@Override
public void regeneratePool()
{
if (myField != null)
{
if (getMyField() != myField)
{
field = myField.getPoolField();
}
}
}
@Override
public void setField(Field field)
{
this.field = field;
}
}

View File

@@ -0,0 +1,124 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import java.util.Collections;
import java.util.List;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.Label;
import net.runelite.asm.attributes.code.instruction.types.JumpingInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import org.objectweb.asm.MethodVisitor;
public class Goto extends Instruction implements JumpingInstruction
{
private org.objectweb.asm.Label asmlabel;
private Label to;
public Goto(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public Goto(Instructions instructions, Label to)
{
super(instructions, InstructionType.GOTO);
assert to != null;
this.to = to;
}
@Override
public String toString()
{
return "goto " + to;// + " (at pc " + (this.getPc() + offset) + ")";
}
@Override
public void accept(MethodVisitor visitor)
{
assert getJumps().size() == 1;
visitor.visitJumpInsn(this.getType().getCode(), getJumps().get(0).getLabel());
}
@Override
public void resolve()
{
Instructions ins = this.getInstructions();
to = ins.findLabel(asmlabel);
assert to != null;
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ctx = new InstructionContext(this, frame);
frame.jump(ctx, to);
return ctx;
}
@Override
public boolean isTerminal()
{
return true;
}
@Override
public List<Label> getJumps()
{
return Collections.singletonList(to);
}
@Override
public void setJumps(List<Label> labels)
{
assert labels.size() == 1;
to = labels.get(0);
}
@Override
public void setLabel(org.objectweb.asm.Label label)
{
assert label != null;
asmlabel = label;
}
public Label getTo()
{
return to;
}
public void setTo(Label to)
{
this.to = to;
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import java.util.Collections;
import java.util.List;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.Label;
import net.runelite.asm.attributes.code.instruction.types.JumpingInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import org.objectweb.asm.MethodVisitor;
public class GotoW extends Instruction implements JumpingInstruction
{
private org.objectweb.asm.Label asmlabel;
private Label to;
public GotoW(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public void accept(MethodVisitor visitor)
{
assert getJumps().size() == 1;
visitor.visitJumpInsn(this.getType().getCode(), getJumps().get(0).getLabel());
}
@Override
public void resolve()
{
Instructions ins = this.getInstructions();
to = ins.findLabel(asmlabel);
assert to != null;
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ctx = new InstructionContext(this, frame);
frame.jump(ctx, to);
return ctx;
}
@Override
public boolean isTerminal()
{
return true;
}
@Override
public List<Label> getJumps()
{
return Collections.singletonList(to);
}
@Override
public void setJumps(List<Label> labels)
{
assert labels.size() == 1;
to = labels.get(0);
}
@Override
public void setLabel(org.objectweb.asm.Label label)
{
asmlabel = label;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class I2B extends Instruction implements ConversionInstruction
{
public I2B(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, Type.INT, object.getValue().cast(int.class)); // sign extneded
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class I2C extends Instruction implements ConversionInstruction
{
public I2C(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, Type.INT, object.getValue().cast(int.class)); // sign extended
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class I2D extends Instruction implements ConversionInstruction
{
public I2D(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, Type.DOUBLE, object.getValue().cast(double.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class I2F extends Instruction implements ConversionInstruction
{
public I2F(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, Type.FLOAT, object.getValue().cast(float.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class I2L extends Instruction implements ConversionInstruction
{
public I2L(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
public I2L(Instructions instructions)
{
super(instructions, InstructionType.I2L);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, Type.LONG, object.getValue().cast(long.class));
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.code.instructions;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ConversionInstruction;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.Stack;
import net.runelite.asm.execution.StackContext;
public class I2S extends Instruction implements ConversionInstruction
{
public I2S(Instructions instructions, InstructionType type)
{
super(instructions, type);
}
@Override
public InstructionContext execute(Frame frame)
{
InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack();
StackContext object = stack.pop();
ins.pop(object);
StackContext ctx = new StackContext(ins, Type.INT, object.getValue().cast(int.class)); // sign extended
stack.push(ctx);
ins.push(ctx);
return ins;
}
}

Some files were not shown because too many files have changed in this diff Show More