List of usage examples for org.objectweb.asm Opcodes ILOAD
int ILOAD
To view the source code for org.objectweb.asm Opcodes ILOAD.
Click Source Link
From source file:asmlib.Type.java
License:Open Source License
public static Type fromLoadOpcode(int opcode) { char type;/*w w w.j av a2s . co m*/ switch (opcode) { case Opcodes.ILOAD: type = 'I'; break; case Opcodes.LLOAD: type = 'J'; break; case Opcodes.FLOAD: type = 'F'; break; case Opcodes.DLOAD: type = 'D'; break; case Opcodes.ALOAD: return Type.OBJECT; default: throw new InstrumentationException("Unknown or invalid bytecode type"); } return Type.fromBytecode(type); }
From source file:asmlib.Type.java
License:Open Source License
/** Mtodo que retorna o opcode certo para o tipo de varivel que se quer fazer load. * Opcodes disponveis:/*from w w w . j av a2 s .com*/ * - ILOAD para boolean, byte, char, short, int * - LLOAD para long * - FLOAD para float * - DLOAD para double * - ALOAD para referncia (objecto ou array) **/ public int getLoadInsn() { char c = bytecodeName().charAt(0); switch (c) { case 'Z': // boolean case 'B': // byte case 'C': // char case 'S': // short case 'I': // int return Opcodes.ILOAD; case 'J': // long return Opcodes.LLOAD; case 'F': // float return Opcodes.FLOAD; case 'D': // double return Opcodes.DLOAD; case '[': // Algum tipo de array case 'L': // objecto case 'T': // objecto (generics) return Opcodes.ALOAD; } throw new InstrumentationException("Unknown fieldType in getLoadInsn"); }
From source file:blue.origami.asm.OGeneratorAdapter.java
License:Apache License
/** * load value from local variable and put it at stack top. * * @param entry/*from w ww . j ava 2s . c o m*/ */ public void loadFromVar(VarEntry entry) { Type typeDesc = Type.getType(entry.getVarClass().typeDesc(0)); this.visitVarInsn(typeDesc.getOpcode(Opcodes.ILOAD), entry.getVarIndex()); }
From source file:br.usp.each.saeg.badua.core.internal.instr.IntegerProbe.java
License:Open Source License
@Override public void accept(final MethodVisitor mv) { // update covered if (potcov != 0) { mv.visitVarInsn(Opcodes.ILOAD, vAlive); if (!singlePredecessor && potcovpuse != 0) { mv.visitVarInsn(Opcodes.ILOAD, vSleepy); mv.visitInsn(Opcodes.IAND);/* ww w. j av a 2s. c o m*/ } InstrSupport.push(mv, (int) potcov); mv.visitInsn(Opcodes.IAND); mv.visitVarInsn(Opcodes.ILOAD, vCovered); mv.visitInsn(Opcodes.IOR); mv.visitVarInsn(Opcodes.ISTORE, vCovered); } // update alive if (disabled != 0) { InstrSupport.push(mv, ~(int) disabled); mv.visitVarInsn(Opcodes.ILOAD, vAlive); mv.visitInsn(Opcodes.IAND); } if (born != 0) { if (disabled == 0) { mv.visitVarInsn(Opcodes.ILOAD, vAlive); } InstrSupport.push(mv, (int) born); mv.visitInsn(Opcodes.IOR); } if (disabled != 0 || born != 0) { mv.visitVarInsn(Opcodes.ISTORE, vAlive); } // update sleepy InstrSupport.push(mv, ~(int) sleepy); mv.visitVarInsn(Opcodes.ISTORE, vSleepy); }
From source file:br.usp.each.saeg.badua.core.internal.instr.IntegerUpdateProbe.java
License:Open Source License
@Override public void accept(final MethodVisitor mv) { mv.visitVarInsn(Opcodes.ILOAD, vCovered); mv.visitInsn(Opcodes.I2L);//from w w w .ja va2 s . c om mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, InstrSupport.DATAMETHOD_NAME, InstrSupport.DATAMETHOD_DESC, false); InstrSupport.push(mv, index); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.LALOAD); mv.visitInsn(Opcodes.LOR); mv.visitInsn(Opcodes.LASTORE); }
From source file:br.usp.each.saeg.badua.test.validation.MaxTest.java
License:Open Source License
@Override @Before//from w w w.j a v a 2 s . com public void setUp() throws Exception { super.setUp(); final int classVersion = Opcodes.V1_6; final int classAccessor = Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER; final String className = "Max"; final String superName = "java/lang/Object"; final int methodAccessor = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC; final String methodName = "max"; final String methodDesc = "([II)I"; final ClassWriter cw = new ClassWriter(0); final MethodVisitor mw; cw.visit(classVersion, classAccessor, className, null, superName, null); mw = cw.visitMethod(methodAccessor, methodName, methodDesc, null, null); mw.visitCode(); // block 0 (definitions {0, 1, 2, 3}) mw.visitInsn(Opcodes.ICONST_0); mw.visitVarInsn(Opcodes.ISTORE, 2); mw.visitVarInsn(Opcodes.ALOAD, 0); mw.visitVarInsn(Opcodes.ILOAD, 2); mw.visitIincInsn(2, 1); mw.visitInsn(Opcodes.IALOAD); mw.visitVarInsn(Opcodes.ISTORE, 3); // block 1 (p-uses {1, 2}) final Label backLoop = new Label(); mw.visitLabel(backLoop); mw.visitVarInsn(Opcodes.ILOAD, 2); mw.visitVarInsn(Opcodes.ILOAD, 1); final Label breakLoop = new Label(); mw.visitJumpInsn(Opcodes.IF_ICMPGE, breakLoop); // block 3 (p-uses {0, 2, 3}) mw.visitVarInsn(Opcodes.ALOAD, 0); mw.visitVarInsn(Opcodes.ILOAD, 2); mw.visitInsn(Opcodes.IALOAD); mw.visitVarInsn(Opcodes.ILOAD, 3); final Label jump = new Label(); mw.visitJumpInsn(Opcodes.IF_ICMPLE, jump); // block 5 (definitions {3}, uses {0, 2}) mw.visitVarInsn(Opcodes.ALOAD, 0); mw.visitVarInsn(Opcodes.ILOAD, 2); mw.visitInsn(Opcodes.IALOAD); mw.visitVarInsn(Opcodes.ISTORE, 3); // block 4 (definitions {2}, uses {2}) mw.visitLabel(jump); mw.visitIincInsn(2, 1); mw.visitJumpInsn(Opcodes.GOTO, backLoop); // block 2 ( uses {3}) mw.visitLabel(breakLoop); mw.visitVarInsn(Opcodes.ILOAD, 3); mw.visitInsn(Opcodes.IRETURN); mw.visitMaxs(2, 4); mw.visitEnd(); cw.visitEnd(); final byte[] bytes = cw.toByteArray(); klass = addClass(className, bytes); method = klass.getMethod(methodName, int[].class, int.class); classId = CRC64.checksum(bytes); RT.init(new RuntimeData()); }
From source file:bytecode.BlockExporter.java
License:Apache License
/** * Exports the given loop to the export destination. This simply exports the * loop body, looping its end back to the beginning of the loop. * * @param l Loop to export//from w w w . jav a 2s . c o m * @return <code>null</code> */ @Override public Void visit(TrivialLoop t) { // Ensure we haven't already exported this block. if (visited.contains(t)) return null; visited.add(t); // Label name mv.visitLabel(getLabel(t)); // Debug line number (if available) if (t.getLineNumber() != null) { mv.visitLineNumber(t.getLineNumber().intValue(), getLabel(t)); } // Condition code mv.visitVarInsn(Opcodes.ILOAD, t.getIndex().getIndex()); t.getLimit().accept(new CodeTraverser(new InstructionExporter(mv))); if (t.getIncrements().get(t.getIndex()) > 0) { mv.visitJumpInsn(Opcodes.IF_ICMPGE, getLabel(t.getNext())); } else { mv.visitJumpInsn(Opcodes.IF_ICMPLE, getLabel(t.getNext())); } // Export loop body, looping back to here at the end (default destination). BlockExporter be = new BlockExporter(mv, t); be.visited.addAll(t.getSuccessors()); t.getStart().accept(be); // Ensure successors are exported. visit(t.getSuccessors()); return null; }
From source file:bytecode.InstructionExporter.java
License:Apache License
/** * Outputs a read operation, choosing both the correct opcode family (variable * read, array load, field get, etc.) and type. * * @param instruction Read instruction./*from ww w. j a v a 2 s . c om*/ * @return <code>null</code> */ @Override public Void visit(Read instruction) { // Variable Reads if (instruction.getState() instanceof Variable) { Variable v = (Variable) instruction.getState(); switch (v.getType().getSort()) { case LONG: mv.visitVarInsn(Opcodes.LLOAD, v.getIndex()); break; case FLOAT: mv.visitVarInsn(Opcodes.FLOAD, v.getIndex()); break; case DOUBLE: mv.visitVarInsn(Opcodes.DLOAD, v.getIndex()); break; case REF: mv.visitVarInsn(Opcodes.ALOAD, v.getIndex()); break; default: mv.visitVarInsn(Opcodes.ILOAD, v.getIndex()); break; } // Array Loads } else if (instruction.getState() instanceof ArrayElement) { switch (instruction.getState().getType().getSort()) { case INT: mv.visitInsn(Opcodes.IALOAD); break; case LONG: mv.visitInsn(Opcodes.LALOAD); break; case FLOAT: mv.visitInsn(Opcodes.FALOAD); break; case DOUBLE: mv.visitInsn(Opcodes.DALOAD); break; case REF: mv.visitInsn(Opcodes.AALOAD); break; case BYTE: mv.visitInsn(Opcodes.BALOAD); break; case BOOL: mv.visitInsn(Opcodes.BALOAD); break; case CHAR: mv.visitInsn(Opcodes.CALOAD); break; case SHORT: mv.visitInsn(Opcodes.SALOAD); break; } // Static Reads } else if (instruction.getState() instanceof Field) { Field f = (Field) instruction.getState(); mv.visitFieldInsn(Opcodes.GETSTATIC, f.getOwner().getName(), f.getName(), f.getType().getDescriptor()); // Field Reads } else if (instruction.getState() instanceof InstanceField) { Field f = (Field) ((InstanceField) instruction.getState()).getField(); mv.visitFieldInsn(Opcodes.GETFIELD, f.getOwner().getName(), f.getName(), f.getType().getDescriptor()); } return null; }
From source file:bytecode.MethodImporter.java
License:Apache License
/** * Imports variable load and store operations, as well as RET?!? * * @param opcode Opcode./*from w w w .ja v a 2s. com*/ * @param var Variable index. */ @Override public void visitVarInsn(final int opcode, final int var) { switch (opcode) { case Opcodes.ILOAD: createVarRead(var, Type.INT); break; case Opcodes.LLOAD: createVarRead(var, Type.LONG); break; case Opcodes.FLOAD: createVarRead(var, Type.FLOAT); break; case Opcodes.DLOAD: createVarRead(var, Type.DOUBLE); break; case Opcodes.ALOAD: createVarRead(var, Type.getFreshRef()); break; case Opcodes.ISTORE: createVarWrite(var, Type.INT); break; case Opcodes.LSTORE: createVarWrite(var, Type.LONG); break; case Opcodes.FSTORE: createVarWrite(var, Type.FLOAT); break; case Opcodes.DSTORE: createVarWrite(var, Type.DOUBLE); break; case Opcodes.ASTORE: createVarWrite(var, Type.getFreshRef()); break; // TODO: RET (paired with JSR) case Opcodes.RET: throw new RuntimeException("visitVarInsn: RET"); } }
From source file:Client.JClassPatcher.java
License:Open Source License
private void patchClient(ClassNode node) { Logger.Info("Patching client (" + node.name + ".class)"); Iterator<MethodNode> methodNodeList = node.methods.iterator(); while (methodNodeList.hasNext()) { MethodNode methodNode = methodNodeList.next(); // I (I)V is where most of the interface is processed if (methodNode.name.equals("I") && methodNode.desc.equals("(I)V")) { // Show combat menu Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); if (insnNode.getOpcode() == Opcodes.BIPUSH) { IntInsnNode bipush = (IntInsnNode) insnNode; if (bipush.operand == -9) { AbstractInsnNode findNode = insnNode; while (findNode.getOpcode() != Opcodes.IF_ICMPEQ) findNode = findNode.getNext(); LabelNode label = ((JumpInsnNode) findNode).label; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Client/Settings", "COMBAT_MENU", "Z")); methodNode.instructions.insertBefore(insnNode, new JumpInsnNode(Opcodes.IFGT, label)); break; }/*from ww w. ja va 2s . c o m*/ } } } else if (methodNode.name.equals("J") && methodNode.desc.equals("(I)V")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Chat command patch if (insnNode.getOpcode() == Opcodes.SIPUSH) { IntInsnNode call = (IntInsnNode) insnNode; if (call.operand == 627) { AbstractInsnNode jmpNode = insnNode; while (jmpNode.getOpcode() != Opcodes.IFEQ) jmpNode = jmpNode.getNext(); AbstractInsnNode insertNode = insnNode; while (insertNode.getOpcode() != Opcodes.INVOKEVIRTUAL) insertNode = insertNode.getPrevious(); JumpInsnNode jmp = (JumpInsnNode) jmpNode; methodNode.instructions.insert(insertNode, new VarInsnNode(Opcodes.ASTORE, 2)); methodNode.instructions.insert(insertNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Client", "processChatCommand", "(Ljava/lang/String;)Ljava/lang/String;")); methodNode.instructions.insert(insertNode, new VarInsnNode(Opcodes.ALOAD, 2)); } } } } else if (methodNode.name.equals("h") && methodNode.desc.equals("(B)V")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Private chat command patch if (insnNode.getOpcode() == Opcodes.GETFIELD) { FieldInsnNode field = (FieldInsnNode) insnNode; if (field.owner.equals("client") && field.name.equals("Ob") && insnNode.getPrevious().getPrevious().getOpcode() != Opcodes.INVOKEVIRTUAL) { insnNode = insnNode.getPrevious().getPrevious(); methodNode.instructions.insert(insnNode, new FieldInsnNode(Opcodes.PUTFIELD, "client", "Ob", "Ljava/lang/String;")); methodNode.instructions.insert(insnNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Client", "processPrivateCommand", "(Ljava/lang/String;)Ljava/lang/String;")); methodNode.instructions.insert(insnNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Ob", "Ljava/lang/String;")); methodNode.instructions.insert(insnNode, new VarInsnNode(Opcodes.ALOAD, 0)); methodNode.instructions.insert(insnNode, new VarInsnNode(Opcodes.ALOAD, 0)); break; } } } } else if (methodNode.name.equals("a") && methodNode.desc.equals("(IIIIIIII)V")) { // Draw NPC hook AbstractInsnNode insnNode = methodNode.instructions.getLast(); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 8)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 1)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 7)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 4)); methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "e", "Mb", "[Ljava/lang/String;")); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ALOAD, 0)); methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Tb", "[Lta;")); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 6)); methodNode.instructions.insertBefore(insnNode, new InsnNode(Opcodes.AALOAD)); methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETFIELD, "ta", "t", "I")); methodNode.instructions.insertBefore(insnNode, new InsnNode(Opcodes.AALOAD)); methodNode.instructions.insertBefore(insnNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Client", "drawNPC", "(IIIILjava/lang/String;)V")); } else if (methodNode.name.equals("b") && methodNode.desc.equals("(IIIIIIII)V")) { // Draw Player hook AbstractInsnNode insnNode = methodNode.instructions.getLast(); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 5)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 6)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 2)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 7)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ALOAD, 0)); methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "rg", "[Lta;")); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 8)); methodNode.instructions.insertBefore(insnNode, new InsnNode(Opcodes.AALOAD)); methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETFIELD, "ta", "C", "Ljava/lang/String;")); methodNode.instructions.insertBefore(insnNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Client", "drawPlayer", "(IIIILjava/lang/String;)V")); } else if (methodNode.name.equals("b") && methodNode.desc.equals("(IIIIIII)V")) { // Draw Item hook // ILOAD 4 is item id AbstractInsnNode insnNode = methodNode.instructions.getLast(); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 3)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 7)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 5)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 1)); methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ILOAD, 4)); methodNode.instructions.insertBefore(insnNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Client", "drawItem", "(IIIII)V")); } else if (methodNode.name.equals("L") && methodNode.desc.equals("(I)V")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Right click bounds fix if (insnNode.getOpcode() == Opcodes.SIPUSH) { IntInsnNode call = (IntInsnNode) insnNode; AbstractInsnNode nextNode = insnNode.getNext(); if (call.operand == 510) { call.operand = 512 - call.operand; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); } else if (call.operand == 315) { call.operand = 334 - call.operand; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "height_client", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); } else if (call.operand == -316) { call.operand = 334 - (call.operand * -1); methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "height_client", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.INEG)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); } } } } else if (methodNode.name.equals("a") && methodNode.desc.equals("(ZZ)V")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Friends chat mouse fix if (insnNode.getOpcode() == Opcodes.SIPUSH) { IntInsnNode call = (IntInsnNode) insnNode; if (call.operand == 489 || call.operand == 429) { call.operand = 512 - call.operand; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); } if (call.operand == -430) { call.operand = 512 - (call.operand * -1); methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.INEG)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); } } } } else if (methodNode.name.equals("i") && methodNode.desc.equals("(I)V")) { AbstractInsnNode lastNode = methodNode.instructions.getLast().getPrevious(); // Send combat style option LabelNode label = new LabelNode(); methodNode.instructions.insert(lastNode, label); // Format methodNode.instructions.insert(lastNode, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "da", "b", "(I)V", false)); methodNode.instructions.insert(lastNode, new IntInsnNode(Opcodes.SIPUSH, 21294)); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Jh", "Lda;")); methodNode.instructions.insert(lastNode, new VarInsnNode(Opcodes.ALOAD, 0)); // Write byte methodNode.instructions.insert(lastNode, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "ja", "c", "(II)V", false)); methodNode.instructions.insert(lastNode, new IntInsnNode(Opcodes.BIPUSH, -80)); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETSTATIC, "Client/Settings", "COMBAT_STYLE", "I")); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETFIELD, "da", "f", "Lja;")); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Jh", "Lda;")); methodNode.instructions.insert(lastNode, new VarInsnNode(Opcodes.ALOAD, 0)); // Create Packet methodNode.instructions.insert(lastNode, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "da", "b", "(II)V", false)); methodNode.instructions.insert(lastNode, new InsnNode(Opcodes.ICONST_0)); methodNode.instructions.insert(lastNode, new IntInsnNode(Opcodes.BIPUSH, 29)); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Jh", "Lda;")); methodNode.instructions.insert(lastNode, new VarInsnNode(Opcodes.ALOAD, 0)); // Skip combat packet if style is already controlled methodNode.instructions.insert(lastNode, new JumpInsnNode(Opcodes.IF_ICMPLE, label)); methodNode.instructions.insert(lastNode, new InsnNode(Opcodes.ICONST_0)); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETSTATIC, "Client/Settings", "COMBAT_STYLE", "I")); // Client init_game methodNode.instructions.insert(lastNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Client", "init_game", "()V", false)); } else if (methodNode.name.equals("o") && methodNode.desc.equals("(I)V")) { // Client.init_login patch AbstractInsnNode findNode = methodNode.instructions.getLast(); methodNode.instructions.insertBefore(findNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Client", "init_login", "()V", false)); } else if (methodNode.name.equals("a") && methodNode.desc.equals("(B)V")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Camera view distance crash fix if (insnNode.getOpcode() == Opcodes.SIPUSH) { IntInsnNode call = (IntInsnNode) insnNode; if (call.operand == 15000) { call.operand = 32767; } } } // Client.init patch AbstractInsnNode findNode = methodNode.instructions.getFirst(); methodNode.instructions.insertBefore(findNode, new VarInsnNode(Opcodes.ALOAD, 0)); methodNode.instructions.insertBefore(findNode, new FieldInsnNode(Opcodes.PUTSTATIC, "Game/Client", "instance", "Ljava/lang/Object;")); methodNode.instructions.insertBefore(findNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Client", "init", "()V", false)); } else if (methodNode.name.equals("G") && methodNode.desc.equals("(I)V")) { // TODO: This can be shortened, I'll fix it another time // NPC Dialogue keyboard AbstractInsnNode lastNode = methodNode.instructions.getLast().getPrevious(); LabelNode label = new LabelNode(); methodNode.instructions.insert(lastNode, label); // Hide dialogue methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.PUTFIELD, "client", "Ph", "Z")); methodNode.instructions.insert(lastNode, new InsnNode(Opcodes.ICONST_0)); methodNode.instructions.insert(lastNode, new VarInsnNode(Opcodes.ALOAD, 0)); // Format methodNode.instructions.insert(lastNode, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "da", "b", "(I)V", false)); methodNode.instructions.insert(lastNode, new IntInsnNode(Opcodes.SIPUSH, 21294)); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Jh", "Lda;")); methodNode.instructions.insert(lastNode, new VarInsnNode(Opcodes.ALOAD, 0)); // Write byte methodNode.instructions.insert(lastNode, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "ja", "c", "(II)V", false)); methodNode.instructions.insert(lastNode, new IntInsnNode(Opcodes.BIPUSH, 115)); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/KeyboardHandler", "dialogue_option", "I")); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETFIELD, "da", "f", "Lja;")); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Jh", "Lda;")); methodNode.instructions.insert(lastNode, new VarInsnNode(Opcodes.ALOAD, 0)); // Create Packet methodNode.instructions.insert(lastNode, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "da", "b", "(II)V", false)); methodNode.instructions.insert(lastNode, new InsnNode(Opcodes.ICONST_0)); methodNode.instructions.insert(lastNode, new IntInsnNode(Opcodes.BIPUSH, 116)); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Jh", "Lda;")); methodNode.instructions.insert(lastNode, new VarInsnNode(Opcodes.ALOAD, 0)); // Check if dialogue option is pressed methodNode.instructions.insert(lastNode, new JumpInsnNode(Opcodes.IF_ICMPGE, label)); // Menu option count methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Id", "I")); methodNode.instructions.insert(lastNode, new VarInsnNode(Opcodes.ALOAD, 0)); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/KeyboardHandler", "dialogue_option", "I")); methodNode.instructions.insert(lastNode, new JumpInsnNode(Opcodes.IFLT, label)); methodNode.instructions.insert(lastNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/KeyboardHandler", "dialogue_option", "I")); } else if (methodNode.name.equals("f") && methodNode.desc.equals("(I)V")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Hide Roof option if (insnNode.getOpcode() == Opcodes.GETFIELD) { FieldInsnNode field = (FieldInsnNode) insnNode; if (field.owner.equals("client") && field.name.equals("yj")) { AbstractInsnNode nextNode = insnNode.getNext(); if (nextNode.getOpcode() == Opcodes.IFNE) { LabelNode label = ((JumpInsnNode) nextNode).label; methodNode.instructions.insert(nextNode, new JumpInsnNode(Opcodes.IFGT, label)); methodNode.instructions.insert(nextNode, new FieldInsnNode(Opcodes.GETSTATIC, "Client/Settings", "HIDE_ROOFS", "Z")); } } } // Move wilderness skull if (insnNode.getOpcode() == Opcodes.SIPUSH) { IntInsnNode call = (IntInsnNode) insnNode; if (call.operand == 465 || call.operand == 453) { call.operand = 512 - call.operand; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); } } } } else if (methodNode.name.equals("a") && methodNode.desc.equals("(IIZ)Z")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Move the load screen text dialogue if (insnNode.getOpcode() == Opcodes.SIPUSH) { IntInsnNode call = (IntInsnNode) insnNode; if (call.operand == 256) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == 192) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "height", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IADD)); methodNode.instructions.insert(insnNode, new IntInsnNode(Opcodes.SIPUSH, 19)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } } } } else if (methodNode.name.equals("d") && methodNode.desc.equals("(B)V")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Center logout dialogue if (insnNode.getOpcode() == Opcodes.SIPUSH || insnNode.getOpcode() == Opcodes.BIPUSH) { IntInsnNode call = (IntInsnNode) insnNode; if (call.operand == 256) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == 173) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "height", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == 126) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); methodNode.instructions.insert(insnNode, new IntInsnNode(Opcodes.SIPUSH, 130)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == 137) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "height", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); methodNode.instructions.insert(insnNode, new IntInsnNode(Opcodes.SIPUSH, 36)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } } } } else if (methodNode.name.equals("j") && methodNode.desc.equals("(I)V")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Center welcome box if (insnNode.getOpcode() == Opcodes.SIPUSH || insnNode.getOpcode() == Opcodes.BIPUSH) { IntInsnNode call = (IntInsnNode) insnNode; if (call.operand == 256) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == 167) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "height", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); methodNode.instructions.insert(insnNode, new IntInsnNode(Opcodes.SIPUSH, 6)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == 56) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); methodNode.instructions.insert(insnNode, new IntInsnNode(Opcodes.SIPUSH, 200)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == -87) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.INEG)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); methodNode.instructions.insert(insnNode, new IntInsnNode(Opcodes.SIPUSH, 169)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == 426) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IADD)); methodNode.instructions.insert(insnNode, new IntInsnNode(Opcodes.SIPUSH, 170)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == 106) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.ISUB)); methodNode.instructions.insert(insnNode, new IntInsnNode(Opcodes.SIPUSH, 150)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } else if (call.operand == 406) { call.operand = 2; methodNode.instructions.insertBefore(insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "Game/Renderer", "width", "I")); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IADD)); methodNode.instructions.insert(insnNode, new IntInsnNode(Opcodes.SIPUSH, 150)); methodNode.instructions.insert(insnNode, new InsnNode(Opcodes.IDIV)); } } } } else if (methodNode.name.equals("k") && methodNode.desc.equals("(B)V")) { Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator(); while (insnNodeList.hasNext()) { AbstractInsnNode insnNode = insnNodeList.next(); // Save settings from combat menu if (insnNode.getOpcode() == Opcodes.PUTFIELD) { FieldInsnNode field = (FieldInsnNode) insnNode; if (field.owner.equals("client") && field.name.equals("Fg")) { methodNode.instructions.insert(insnNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "Client/Settings", "save", "()V", false)); methodNode.instructions.insert(insnNode, new FieldInsnNode(Opcodes.PUTSTATIC, "Client/Settings", "COMBAT_STYLE", "I")); methodNode.instructions.insert(insnNode, new FieldInsnNode(Opcodes.GETFIELD, "client", "Fg", "I")); methodNode.instructions.insert(insnNode, new VarInsnNode(Opcodes.ALOAD, 0)); } } } } else if (methodNode.name.equals("a") && methodNode.desc .equals("(ZLjava/lang/String;ILjava/lang/String;IILjava/lang/String;Ljava/lang/String;)V")) { AbstractInsnNode first = methodNode.instructions.getFirst(); methodNode.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 7)); methodNode.instructions.insertBefore(first, new VarInsnNode(Opcodes.ALOAD, 4)); methodNode.instructions.insertBefore(first, new VarInsnNode(Opcodes.ILOAD, 5)); methodNode.instructions.insertBefore(first, new MethodInsnNode(Opcodes.INVOKESTATIC, "Game/Client", "messageHook", "(Ljava/lang/String;Ljava/lang/String;I)V")); } } }