org.objectweb.asm.tree.LdcInsnNode Java Examples
The following examples show how to use
org.objectweb.asm.tree.LdcInsnNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstructionComparator.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) { if (node1.getOpcode() != node2.getOpcode()) { return false; } switch (node2.getType()) { case VAR_INSN: return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2); case TYPE_INSN: return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2); case FIELD_INSN: return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2); case METHOD_INSN: return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2); case LDC_INSN: return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2); case IINC_INSN: return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2); case INT_INSN: return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2); default: return true; } }
Example #2
Source File: SourceInterpreter.java From Concurnas with MIT License | 6 votes |
@Override public SourceValue newOperation(final AbstractInsnNode insn) { int size; switch (insn.getOpcode()) { case LCONST_0: case LCONST_1: case DCONST_0: case DCONST_1: size = 2; break; case LDC: Object value = ((LdcInsnNode) insn).cst; size = value instanceof Long || value instanceof Double ? 2 : 1; break; case GETSTATIC: size = Type.getType(((FieldInsnNode) insn).desc).getSize(); break; default: size = 1; break; } return new SourceValue(size, insn); }
Example #3
Source File: OpcodeFormatting.java From Cafebabe with GNU General Public License v3.0 | 6 votes |
/** * Given an integer, returns an InsnNode that will properly represent the int. * * @param i * @return */ public static AbstractInsnNode toInt(int i) { switch (i) { case -1: return new InsnNode(Opcodes.ICONST_M1); case 0: return new InsnNode(Opcodes.ICONST_0); case 1: return new InsnNode(Opcodes.ICONST_1); case 2: return new InsnNode(Opcodes.ICONST_2); case 3: return new InsnNode(Opcodes.ICONST_3); case 4: return new InsnNode(Opcodes.ICONST_4); case 5: return new InsnNode(Opcodes.ICONST_5); } if (i > -129 && i < 128) { return new IntInsnNode(Opcodes.BIPUSH, i); } return new LdcInsnNode(i); }
Example #4
Source File: SourceInterpreter.java From JReFrameworker with MIT License | 6 votes |
@Override public SourceValue newOperation(final AbstractInsnNode insn) { int size; switch (insn.getOpcode()) { case LCONST_0: case LCONST_1: case DCONST_0: case DCONST_1: size = 2; break; case LDC: Object value = ((LdcInsnNode) insn).cst; size = value instanceof Long || value instanceof Double ? 2 : 1; break; case GETSTATIC: size = Type.getType(((FieldInsnNode) insn).desc).getSize(); break; default: size = 1; break; } return new SourceValue(size, insn); }
Example #5
Source File: OpUtils.java From zelixkiller with GNU General Public License v3.0 | 6 votes |
/** * Given an integer, returns an InsnNode that will properly represent the * int. * * @param i * @return */ public static AbstractInsnNode toInt(int i) { switch (i) { case -1: return new InsnNode(Opcodes.ICONST_M1); case 0: return new InsnNode(Opcodes.ICONST_0); case 1: return new InsnNode(Opcodes.ICONST_1); case 2: return new InsnNode(Opcodes.ICONST_2); case 3: return new InsnNode(Opcodes.ICONST_3); case 4: return new InsnNode(Opcodes.ICONST_4); case 5: return new InsnNode(Opcodes.ICONST_5); } if (i > -129 && i < 128) { return new IntInsnNode(Opcodes.BIPUSH, i); } return new LdcInsnNode(i); }
Example #6
Source File: TreeInstructions.java From instrumentation with Apache License 2.0 | 6 votes |
public static AbstractInsnNode getPushInstruction(int value) { if (value == -1) { return new InsnNode(Opcodes.ICONST_M1); } else if (value == 0) { return new InsnNode(Opcodes.ICONST_0); } else if (value == 1) { return new InsnNode(Opcodes.ICONST_1); } else if (value == 2) { return new InsnNode(Opcodes.ICONST_2); } else if (value == 3) { return new InsnNode(Opcodes.ICONST_3); } else if (value == 4) { return new InsnNode(Opcodes.ICONST_4); } else if (value == 5) { return new InsnNode(Opcodes.ICONST_5); } else if ((value >= -128) && (value <= 127)) { return new IntInsnNode(Opcodes.BIPUSH, value); } else if ((value >= -32768) && (value <= 32767)) { return new IntInsnNode(Opcodes.SIPUSH, value); } else { return new LdcInsnNode(value); } }
Example #7
Source File: AntiDebug.java From radon with GNU General Public License v3.0 | 6 votes |
private InsnList createIsDebugList() { boolean isUpper = RandomUtils.getRandomBoolean(); String argument = DEBUG_OPTIONS[debugOptionIndex.incrementAndGet() % DEBUG_OPTIONS.length]; if (isUpper) argument = argument.toUpperCase(); else argument = argument.toLowerCase(); InsnList insnList = new InsnList(); insnList.add(new MethodInsnNode(INVOKESTATIC, "java/lang/management/ManagementFactory", "getRuntimeMXBean", "()Ljava/lang/management/RuntimeMXBean;", false)); insnList.add(new MethodInsnNode(INVOKEINTERFACE, "java/lang/management/RuntimeMXBean", "getInputArguments", "()Ljava/util/List;", true)); insnList.add(new MethodInsnNode(INVOKEVIRTUAL, "java/lang/Object", "toString", "()Ljava/lang/String;", false)); insnList.add(new MethodInsnNode(INVOKEVIRTUAL, "java/lang/String", isUpper ? "toUpperCase" : "toLowerCase", "()Ljava/lang/String;", false)); insnList.add(new LdcInsnNode(argument)); insnList.add(new MethodInsnNode(INVOKEVIRTUAL, "java/lang/String", "contains", "(Ljava/lang/CharSequence;)Z", false)); return insnList; }
Example #8
Source File: SourceInterpreter.java From JReFrameworker with MIT License | 6 votes |
@Override public SourceValue newOperation(final AbstractInsnNode insn) { int size; switch (insn.getOpcode()) { case LCONST_0: case LCONST_1: case DCONST_0: case DCONST_1: size = 2; break; case LDC: Object value = ((LdcInsnNode) insn).cst; size = value instanceof Long || value instanceof Double ? 2 : 1; break; case GETSTATIC: size = Type.getType(((FieldInsnNode) insn).desc).getSize(); break; default: size = 1; break; } return new SourceValue(size, insn); }
Example #9
Source File: ASMUtils.java From rembulan with Apache License 2.0 | 6 votes |
public static AbstractInsnNode loadInt(int i) { switch (i) { case -1: return new InsnNode(ICONST_M1); case 0: return new InsnNode(ICONST_0); case 1: return new InsnNode(ICONST_1); case 2: return new InsnNode(ICONST_2); case 3: return new InsnNode(ICONST_3); case 4: return new InsnNode(ICONST_4); case 5: return new InsnNode(ICONST_5); default: { if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) return new IntInsnNode(BIPUSH, i); else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) return new IntInsnNode(SIPUSH, i); else return new LdcInsnNode(i); } } }
Example #10
Source File: ConversionMethods.java From rembulan with Apache License 2.0 | 6 votes |
public static InsnList toNumericalValue(String what) { Objects.requireNonNull(what); InsnList il = new InsnList(); il.add(new LdcInsnNode(what)); il.add(new MethodInsnNode( INVOKESTATIC, Type.getInternalName(Conversions.class), "toNumericalValue", Type.getMethodDescriptor( Type.getType(Number.class), Type.getType(Object.class), Type.getType(String.class)), false)); return il; }
Example #11
Source File: LoadIntStep.java From deobfuscator with Apache License 2.0 | 6 votes |
public LoadIntStep() { super((a) -> { if(!(a instanceof LdcInsnNode)) return true; return ((LdcInsnNode)a).cst instanceof Integer; },Opcodes.ICONST_M1, Opcodes.ICONST_0, Opcodes.ICONST_1, Opcodes.ICONST_2, Opcodes.ICONST_3, Opcodes.ICONST_4, Opcodes.ICONST_5, Opcodes.LDC, Opcodes.BIPUSH, Opcodes.SIPUSH ); }
Example #12
Source File: SourceInterpreter.java From JByteMod-Beta with GNU General Public License v2.0 | 6 votes |
@Override public SourceValue newOperation(final AbstractInsnNode insn) { int size; switch (insn.getOpcode()) { case LCONST_0: case LCONST_1: case DCONST_0: case DCONST_1: size = 2; break; case LDC: Object cst = ((LdcInsnNode) insn).cst; size = cst instanceof Long || cst instanceof Double ? 2 : 1; break; case GETSTATIC: size = Type.getType(((FieldInsnNode) insn).desc).getSize(); break; default: size = 1; } return new SourceValue(size, insn); }
Example #13
Source File: AsmMethodSource.java From JAADAS with GNU General Public License v3.0 | 6 votes |
private void convertLdcInsn(LdcInsnNode insn) { Object val = insn.cst; boolean dword = val instanceof Long || val instanceof Double; StackFrame frame = getFrame(insn); Operand[] out = frame.out(); Operand opr; if (out == null) { Value v = toSootValue(val); opr = new Operand(insn, v); frame.out(opr); } else { opr = out[0]; } if (dword) pushDual(opr); else push(opr); }
Example #14
Source File: Instrumentator.java From instrumentation with Apache License 2.0 | 6 votes |
private void addGetMethodInvocation(InsnList il) { il.add(TreeInstructions.getPushInstruction(this.methodArguments.length)); il.add(new TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/Class")); int parameterClassesIndex = getFistAvailablePosition(); il.add(new VarInsnNode(Opcodes.ASTORE, parameterClassesIndex)); this.mn.maxLocals++; for (int i = 0; i < this.methodArguments.length; i++) { il.add(new VarInsnNode(Opcodes.ALOAD, parameterClassesIndex)); il.add(TreeInstructions.getPushInstruction(i)); il.add(TreeInstructions.getClassReferenceInstruction(methodArguments[i], cn.version & 0xFFFF)); il.add(new InsnNode(Opcodes.AASTORE)); } il.add(TreeInstructions.getClassConstantReference(this.classType, cn.version & 0xFFFF)); il.add(new LdcInsnNode(this.mn.name)); il.add(new VarInsnNode(Opcodes.ALOAD, parameterClassesIndex)); il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "org/brutusin/instrumentation/utils/Helper", "getSource", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/Object;", false)); }
Example #15
Source File: SourceInterpreter.java From Cafebabe with GNU General Public License v3.0 | 6 votes |
@Override public SourceValue newOperation(final AbstractInsnNode insn) { int size; switch (insn.getOpcode()) { case LCONST_0: case LCONST_1: case DCONST_0: case DCONST_1: size = 2; break; case LDC: Object value = ((LdcInsnNode) insn).cst; size = value instanceof Long || value instanceof Double ? 2 : 1; break; case GETSTATIC: size = Type.getType(((FieldInsnNode) insn).desc).getSize(); break; default: size = 1; break; } return new SourceValue(size, insn); }
Example #16
Source File: InstructionEditorPanel.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
private void ldcComponentUpdate(WebComboBox wcb, LdcInsnNode ain, Field f, WebTextField field) { switch (wcb.getSelectedIndex()) { case 0: setField(f, ain, field.getText().trim()); break; case 1: setField(f, ain, Integer.parseInt(field.getText().trim())); break; case 2: setField(f, ain, Float.parseFloat(field.getText().trim())); break; case 3: setField(f, ain, Long.parseLong(field.getText().trim())); break; case 4: setField(f, ain, Double.parseDouble(field.getText().trim())); break; case 5: setField(f, ain, Type.getType(field.getText().trim())); break; case 6: setField(f, ain, field.getText().trim()); break; case 7: setField(f, ain, field.getText().trim()); break; } }
Example #17
Source File: LightFlowObfuscationTransformer.java From deobfuscator with Apache License 2.0 | 5 votes |
private boolean willPush(AbstractInsnNode ain) { if(ain.getOpcode() == Opcodes.LDC && (((LdcInsnNode)ain).cst instanceof Long || ((LdcInsnNode)ain).cst instanceof Double)) return false; return Utils.willPushToStack(ain.getOpcode()) && ain.getOpcode() != Opcodes.GETSTATIC && ain.getOpcode() != Opcodes.LLOAD && ain.getOpcode() != Opcodes.DLOAD; }
Example #18
Source File: OpcodeFormatting.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
public static String toString(AbstractInsnNode ain) { String s = getOpcodeText(ain.getOpcode()); switch (ain.getType()) { case AbstractInsnNode.FIELD_INSN: FieldInsnNode fin = (FieldInsnNode) ain; return s + " " + fin.owner + "#" + fin.name + " " + fin.desc; case AbstractInsnNode.METHOD_INSN: MethodInsnNode min = (MethodInsnNode) ain; return s + " " + min.owner + "#" + min.name + min.desc; case AbstractInsnNode.VAR_INSN: VarInsnNode vin = (VarInsnNode) ain; return s + " " + vin.var; case AbstractInsnNode.TYPE_INSN: TypeInsnNode tin = (TypeInsnNode) ain; return s + " " + tin.desc; case AbstractInsnNode.MULTIANEWARRAY_INSN: MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain; return s + " " + mnin.dims + " " + mnin.desc; case AbstractInsnNode.JUMP_INSN: JumpInsnNode jin = (JumpInsnNode) ain; return s + " " + getIndex(jin.label); case AbstractInsnNode.LDC_INSN: LdcInsnNode ldc = (LdcInsnNode) ain; return s + " " + ldc.cst.toString(); case AbstractInsnNode.INT_INSN: return s + " " + getIntValue(ain); case AbstractInsnNode.IINC_INSN: IincInsnNode iinc = (IincInsnNode) ain; return s + " " + iinc.var + " +" + iinc.incr; case AbstractInsnNode.FRAME: FrameNode fn = (FrameNode) ain; return s + " " + getOpcodeText(fn.type) + " " + fn.local.size() + " " + fn.stack.size(); case AbstractInsnNode.LABEL: LabelNode ln = (LabelNode) ain; return s + " " + getIndex(ln); } return s; }
Example #19
Source File: OverclockingClassTransformer.java From malmo with MIT License | 5 votes |
private static void removeInterpolation(ClassNode node, boolean isObfuscated) { // We're attempting to turn this line from EntityOtherPlayerMP.func_180426_a: // this.otherPlayerMPPosRotationIncrements = p_180426_9_; // into this: // this.otherPlayerMPPosRotationIncrements = 1; final String methodName = "func_180426_a"; final String methodDescriptor = "(DDDFFIZ)V"; // double x/y/z, float yaw/pitch, int increments, bool (unused), returns void. System.out.println("MALMO: Found EntityOtherPlayerMP, attempting to transform it"); for (MethodNode method : node.methods) { if (method.name.equals(methodName) && method.desc.equals(methodDescriptor)) { System.out.println("MALMO: Found EntityOtherPlayerMP.func_180426_a() method, attempting to transform it"); for (AbstractInsnNode instruction : method.instructions.toArray()) { if (instruction.getOpcode() == Opcodes.ILOAD) { LdcInsnNode newNode = new LdcInsnNode(new Integer(1)); method.instructions.insert(instruction, newNode); method.instructions.remove(instruction); return; } } } } }
Example #20
Source File: ASMUtilsTest.java From radon with GNU General Public License v3.0 | 5 votes |
@Test public void testGetDoubleFromInsn() { Assert.assertEquals((double) Opcodes.NOP, ASMUtils.getDoubleFromInsn(new InsnNode(Opcodes.DCONST_0)), 0); Assert.assertEquals((double) Opcodes.ACONST_NULL, ASMUtils.getDoubleFromInsn(new LdcInsnNode(1.0)), 0); thrown.expect(RadonException.class); ASMUtils.getDoubleFromInsn(new InsnNode(Opcodes.NOP)); }
Example #21
Source File: ASMUtilsTest.java From radon with GNU General Public License v3.0 | 5 votes |
@Test public void testGetFloatFromInsn() { Assert.assertEquals((float) Opcodes.NOP, ASMUtils.getFloatFromInsn(new InsnNode(Opcodes.FCONST_0)), 0); Assert.assertEquals((float) Opcodes.ACONST_NULL, ASMUtils.getFloatFromInsn(new LdcInsnNode(1.0f)), 0); thrown.expect(RadonException.class); ASMUtils.getFloatFromInsn(new InsnNode(Opcodes.NOP)); }
Example #22
Source File: ASMUtilsTest.java From radon with GNU General Public License v3.0 | 5 votes |
@Test public void testGetIntegerFromInsn() { Assert.assertEquals(Opcodes.ACONST_NULL, ASMUtils.getIntegerFromInsn(new InsnNode(Opcodes.ICONST_1))); Assert.assertEquals(Opcodes.ACONST_NULL, ASMUtils.getIntegerFromInsn(new IntInsnNode(Opcodes.ICONST_1, 1))); Assert.assertEquals(Opcodes.ACONST_NULL, ASMUtils.getIntegerFromInsn(new LdcInsnNode(Opcodes.ACONST_NULL))); thrown.expect(RadonException.class); ASMUtils.getIntegerFromInsn(new InsnNode(Opcodes.NOP)); }
Example #23
Source File: ASMUtilsTest.java From radon with GNU General Public License v3.0 | 5 votes |
@Test public void testIsFloatInsn() { Assert.assertTrue( ASMUtils.isFloatInsn(new LdcInsnNode((float) Opcodes.NOP))); Assert.assertFalse(ASMUtils.isFloatInsn(new LdcInsnNode(null))); }
Example #24
Source File: ASMUtils.java From radon with GNU General Public License v3.0 | 5 votes |
public static double getDoubleFromInsn(AbstractInsnNode insn) { int opcode = insn.getOpcode(); if (opcode >= Opcodes.DCONST_0 && opcode <= Opcodes.DCONST_1) { return opcode - 14; } else if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof Double) { return (Double) ((LdcInsnNode) insn).cst; } throw new RadonException("Unexpected instruction"); }
Example #25
Source File: ASMUtils.java From radon with GNU General Public License v3.0 | 5 votes |
public static float getFloatFromInsn(AbstractInsnNode insn) { int opcode = insn.getOpcode(); if (opcode >= Opcodes.FCONST_0 && opcode <= Opcodes.FCONST_2) { return opcode - 11; } else if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof Float) { return (Float) ((LdcInsnNode) insn).cst; } throw new RadonException("Unexpected instruction"); }
Example #26
Source File: ASMUtils.java From radon with GNU General Public License v3.0 | 5 votes |
public static long getLongFromInsn(AbstractInsnNode insn) { int opcode = insn.getOpcode(); if (opcode >= Opcodes.LCONST_0 && opcode <= Opcodes.LCONST_1) { return opcode - 9; } else if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof Long) { return (Long) ((LdcInsnNode) insn).cst; } throw new RadonException("Unexpected instruction"); }
Example #27
Source File: ASMUtils.java From radon with GNU General Public License v3.0 | 5 votes |
public static int getIntegerFromInsn(AbstractInsnNode insn) { int opcode = insn.getOpcode(); if (opcode >= Opcodes.ICONST_M1 && opcode <= Opcodes.ICONST_5) { return opcode - 3; } else if (insn instanceof IntInsnNode && insn.getOpcode() != Opcodes.NEWARRAY) { return ((IntInsnNode) insn).operand; } else if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof Integer) { return (Integer) ((LdcInsnNode) insn).cst; } throw new RadonException("Unexpected instruction"); }
Example #28
Source File: ASMUtils.java From radon with GNU General Public License v3.0 | 5 votes |
public static AbstractInsnNode getNumberInsn(float number) { if (number >= 0 && number <= 2) { return new InsnNode((int) (number + 11)); } else { return new LdcInsnNode(number); } }
Example #29
Source File: CorrelationMapper.java From zelixkiller with GNU General Public License v3.0 | 5 votes |
/** * Get's a member's class types from its description. Best for methods. * * @param member * @param map * @return */ private static List<MappedClass> getTypesFromMember(MappedMember member, Map<String, MappedClass> map) { List<String> names = RegexUtils.matchDescriptionClasses(member.getDesc()); if (member.isMethod()) { for (AbstractInsnNode ain : member.getMethodNode().instructions.toArray()) { if (ain.getType() == AbstractInsnNode.METHOD_INSN) { MethodInsnNode min = (MethodInsnNode) ain; names.addAll(RegexUtils.matchDescriptionClasses(min.desc)); names.add(min.owner); } else if (ain.getType() == AbstractInsnNode.FIELD_INSN) { FieldInsnNode fin = (FieldInsnNode) ain; names.addAll(RegexUtils.matchDescriptionClasses(fin.desc)); names.add(fin.owner); } else if (ain.getType() == AbstractInsnNode.TYPE_INSN) { TypeInsnNode tin = (TypeInsnNode) ain; names.addAll(RegexUtils.matchDescriptionClasses(tin.desc)); } else if (ain.getType() == AbstractInsnNode.LDC_INSN) { LdcInsnNode ldc = (LdcInsnNode) ain; if (ldc.cst instanceof Type) { Type t = (Type) ldc.cst; names.add(t.getClassName().replace(".", "/")); } } } } if (names.size() == 0) { return null; } List<MappedClass> classes = new ArrayList<MappedClass>(); for (String name : names) { if (!map.containsKey(name)) { continue; } classes.add(map.get(name)); } return classes; }
Example #30
Source File: ASMUtils.java From radon with GNU General Public License v3.0 | 5 votes |
public static AbstractInsnNode getNumberInsn(int number) { if (number >= -1 && number <= 5) return new InsnNode(number + 3); else if (number >= -128 && number <= 127) return new IntInsnNode(Opcodes.BIPUSH, number); else if (number >= -32768 && number <= 32767) return new IntInsnNode(Opcodes.SIPUSH, number); else return new LdcInsnNode(number); }