Merge pull request #3065 from open-osrs/transform
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
package net.runelite.deob.deobfuscators.transformers;
|
||||||
|
|
||||||
|
import net.runelite.asm.ClassFile;
|
||||||
|
import net.runelite.asm.ClassGroup;
|
||||||
|
import net.runelite.asm.Method;
|
||||||
|
import net.runelite.asm.attributes.Code;
|
||||||
|
import net.runelite.asm.attributes.code.Instructions;
|
||||||
|
import net.runelite.asm.attributes.code.instructions.ALoad;
|
||||||
|
import net.runelite.asm.attributes.code.instructions.InvokeSpecial;
|
||||||
|
import net.runelite.asm.attributes.code.instructions.VReturn;
|
||||||
|
import net.runelite.asm.signature.Signature;
|
||||||
|
import net.runelite.deob.Transformer;
|
||||||
|
|
||||||
|
public class GraphicsObjectTransformer implements Transformer // robots in disguise
|
||||||
|
{
|
||||||
|
private static final String GRAPHICS_OBJECT = "GraphicsObject";
|
||||||
|
private static final String RENDERABLE = "Renderable";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void transform(ClassGroup group)
|
||||||
|
{
|
||||||
|
ClassFile graphicsObject = group.findClass(GRAPHICS_OBJECT);
|
||||||
|
ClassFile renderable = group.findClass(RENDERABLE);
|
||||||
|
|
||||||
|
graphicsObject.clearFinal();
|
||||||
|
|
||||||
|
Method initGraphicsObject = new Method(graphicsObject, "<init>", new Signature("()V"));
|
||||||
|
initGraphicsObject.setPublic();
|
||||||
|
|
||||||
|
final Code code = new Code(initGraphicsObject);
|
||||||
|
code.setMaxStack(1);
|
||||||
|
initGraphicsObject.setCode(code);
|
||||||
|
graphicsObject.addMethod(initGraphicsObject);
|
||||||
|
|
||||||
|
Instructions ins = code.getInstructions();
|
||||||
|
|
||||||
|
ins.addInstruction(new ALoad(ins, 0));
|
||||||
|
ins.addInstruction(new InvokeSpecial(ins, new net.runelite.asm.pool.Method(renderable.getPoolClass(), "<init>", new Signature("()V"))));
|
||||||
|
ins.addInstruction(new VReturn(ins));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,11 +17,7 @@ import net.runelite.asm.attributes.code.instructions.GetStatic;
|
|||||||
import net.runelite.asm.attributes.code.instructions.ILoad;
|
import net.runelite.asm.attributes.code.instructions.ILoad;
|
||||||
import net.runelite.asm.attributes.code.instructions.IfICmpEq;
|
import net.runelite.asm.attributes.code.instructions.IfICmpEq;
|
||||||
import net.runelite.asm.attributes.code.instructions.IfICmpNe;
|
import net.runelite.asm.attributes.code.instructions.IfICmpNe;
|
||||||
import net.runelite.asm.attributes.code.instructions.LDC;
|
|
||||||
import net.runelite.asm.attributes.code.instructions.PutStatic;
|
|
||||||
import net.runelite.asm.attributes.code.instructions.VReturn;
|
|
||||||
import net.runelite.asm.pool.Class;
|
import net.runelite.asm.pool.Class;
|
||||||
import net.runelite.asm.signature.Signature;
|
|
||||||
import net.runelite.deob.Transformer;
|
import net.runelite.deob.Transformer;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import static org.objectweb.asm.Opcodes.ACC_FINAL;
|
import static org.objectweb.asm.Opcodes.ACC_FINAL;
|
||||||
@@ -149,20 +145,6 @@ public class ScriptOpcodesTransformer implements Transformer // robots in disgui
|
|||||||
scriptOpcodes.getFields().clear();
|
scriptOpcodes.getFields().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Method clinit = scriptOpcodes.findMethod("<clinit>");
|
|
||||||
if (clinit == null)
|
|
||||||
{
|
|
||||||
clinit = new Method(scriptOpcodes, "<clinit>", new Signature("()V"));
|
|
||||||
clinit.setStatic(true);
|
|
||||||
Code code = new Code(clinit);
|
|
||||||
code.setMaxStack(1);
|
|
||||||
clinit.setCode(code);
|
|
||||||
scriptOpcodes.addMethod(clinit);
|
|
||||||
}
|
|
||||||
|
|
||||||
Code code = clinit.getCode();
|
|
||||||
Instructions ins = code.getInstructions();
|
|
||||||
|
|
||||||
ClassFile finalScriptOpcodes = scriptOpcodes;
|
ClassFile finalScriptOpcodes = scriptOpcodes;
|
||||||
OPCODE_MAP.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getKey)).forEach((entry) ->
|
OPCODE_MAP.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getKey)).forEach((entry) ->
|
||||||
{
|
{
|
||||||
@@ -173,13 +155,6 @@ public class ScriptOpcodesTransformer implements Transformer // robots in disgui
|
|||||||
field.setAccessFlags(ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
|
field.setAccessFlags(ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
|
||||||
field.setValue(opcode);
|
field.setValue(opcode);
|
||||||
finalScriptOpcodes.addField(field);
|
finalScriptOpcodes.addField(field);
|
||||||
|
|
||||||
LDC ldc = new LDC(ins, opcode);
|
|
||||||
PutStatic put = new PutStatic(ins, field);
|
|
||||||
ins.addInstruction(0, ldc);
|
|
||||||
ins.addInstruction(1, put);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ins.addInstruction(new VReturn(ins));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import net.runelite.deob.deobfuscators.mapping.AnnotationIntegrityChecker;
|
|||||||
import net.runelite.deob.deobfuscators.mapping.AnnotationMapper;
|
import net.runelite.deob.deobfuscators.mapping.AnnotationMapper;
|
||||||
import net.runelite.deob.deobfuscators.mapping.Mapper;
|
import net.runelite.deob.deobfuscators.mapping.Mapper;
|
||||||
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
|
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
|
||||||
|
import net.runelite.deob.deobfuscators.transformers.GraphicsObjectTransformer;
|
||||||
import net.runelite.deob.deobfuscators.transformers.ScriptOpcodesTransformer;
|
import net.runelite.deob.deobfuscators.transformers.ScriptOpcodesTransformer;
|
||||||
import net.runelite.deob.util.JarUtil;
|
import net.runelite.deob.util.JarUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -78,6 +79,7 @@ public class UpdateMappings
|
|||||||
ad.run();
|
ad.run();
|
||||||
|
|
||||||
new ScriptOpcodesTransformer().transform(group2);
|
new ScriptOpcodesTransformer().transform(group2);
|
||||||
|
new GraphicsObjectTransformer().transform(group2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(File out) throws IOException
|
public void save(File out) throws IOException
|
||||||
|
|||||||
Reference in New Issue
Block a user