Java Code Examples for org.objectweb.asm.tree.FieldInsnNode#getOpcode()
The following examples show how to use
org.objectweb.asm.tree.FieldInsnNode#getOpcode() .
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: FieldHandler.java From native-obfuscator with GNU General Public License v3.0 | 5 votes |
@Override protected void process(MethodContext context, FieldInsnNode node) { boolean isStatic = node.getOpcode() == Opcodes.GETSTATIC || node.getOpcode() == Opcodes.PUTSTATIC; CachedFieldInfo info = new CachedFieldInfo(node.owner, node.name, node.desc, isStatic); instructionName += "_" + Type.getType(node.desc).getSort(); if (isStatic) { props.put("class_ptr", context.getCachedClasses().getPointer(node.owner)); } int classId = context.getCachedClasses().getId(node.owner); context.output.append(String.format("if (!cclasses[%d] || env->IsSameObject(cclasses[%d], NULL)) { cclasses_mtx[%d].lock(); if (!cclasses[%d] || env->IsSameObject(cclasses[%d], NULL)) { if (jclass clazz = %s) { cclasses[%d] = (jclass) env->NewWeakGlobalRef(clazz); env->DeleteLocalRef(clazz); } } cclasses_mtx[%d].unlock(); %s } ", classId, classId, classId, classId, classId, MethodProcessor.getClassGetter(context, node.owner), classId, classId, trimmedTryCatchBlock)); int fieldId = context.getCachedFields().getId(info); props.put("fieldid", context.getCachedFields().getPointer(info)); context.output.append(String.format("if (!cfields[%d]) { cfields[%d] = env->Get%sFieldID(%s, %s, %s); %s } ", fieldId, fieldId, isStatic ? "Static" : "", context.getCachedClasses().getPointer(node.owner), context.getStringPool().get(node.name), context.getStringPool().get(node.desc), trimmedTryCatchBlock)); }
Example 2
Source File: AsmMethodSource.java From JAADAS with GNU General Public License v3.0 | 5 votes |
private void convertGetFieldInsn(FieldInsnNode insn) { StackFrame frame = getFrame(insn); Operand[] out = frame.out(); Operand opr; Type type; if (out == null) { SootClass declClass = Scene.v().getSootClass( AsmUtil.toQualifiedName(insn.owner)); type = AsmUtil.toJimpleType(insn.desc); Value val; SootFieldRef ref; if (insn.getOpcode() == GETSTATIC) { ref = Scene.v().makeFieldRef(declClass, insn.name, type, true); val = Jimple.v().newStaticFieldRef(ref); } else { Operand base = popLocal(); ref = Scene.v().makeFieldRef(declClass, insn.name, type, false); InstanceFieldRef ifr = Jimple.v().newInstanceFieldRef( base.stackOrValue(), ref); val = ifr; base.addBox(ifr.getBaseBox()); frame.in(base); frame.boxes(ifr.getBaseBox()); } opr = new Operand(insn, val); frame.out(opr); } else { opr = out[0]; type = opr.<FieldRef>value().getFieldRef().type(); if (insn.getOpcode() == GETFIELD) frame.mergeIn(pop()); } push(type, opr); }
Example 3
Source File: AsmMethodSource.java From JAADAS with GNU General Public License v3.0 | 5 votes |
private void convertFieldInsn(FieldInsnNode insn) { int op = insn.getOpcode(); if (op == GETSTATIC || op == GETFIELD) convertGetFieldInsn(insn); else convertPutFieldInsn(insn); }
Example 4
Source File: TransformerInjectTracker.java From Diorite with MIT License | 5 votes |
private TransformerInjectTracker(Transformer transformer, FieldInsnNode fieldInsnNode, InsnList insnList) { this.transformer = transformer; this.fieldInsnNode = fieldInsnNode; this.isStatic = fieldInsnNode.getOpcode() == PUTSTATIC; this.resultNodeList = insnList; this.initNodeList = insnList; }
Example 5
Source File: SearchEntry.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
public SearchEntry(ClassNode cn, MethodNode mn, FieldInsnNode fin) { this(cn, mn, fin.owner, fin.name, fin.desc, fin.getOpcode()); }
Example 6
Source File: StaticAnalysis.java From hottub with GNU General Public License v2.0 | 4 votes |
public boolean handleField(ClassNode clinit_cn, FieldInsnNode fin) { boolean safe = false; switch (fin.getOpcode()) { case GETFIELD: case PUTFIELD: bad_ref_field++; if (log_enable) { log_f("[unsafe] class: %s [cause:get/putfield] fin.owner: %s fin.name: %s\n", clinit_cn.name, fin.owner, fin.name); } break; case GETSTATIC: // we have a reference, but if it is owned by clinit's class it is ok // this is very rare (makes sense, why would you read from something you will initialize) // this is not a class dependence (as it would depend on itself) // everything else depends on when the owning class was initialized // even known safe classes' fields are unsafe as they might be initialized by a user called method // note: really only final from a known safe class could be safe and unaltered by the user if (clinit_cn.name.equals(fin.owner)) { safe = true; } else { bad_ref_getstatic++; if (log_enable) { log_f("[unsafe] class: %s [cause:getstatic] fin.owner: %s fin.name: %s\n", clinit_cn.name, fin.owner, fin.name); } } break; // only touch static fields from clinit class // causes crashes when running clinit case PUTSTATIC: if (clinit_cn.name.equals(fin.owner)) { safe = true; addClassDependence(clinit_cn, fin.owner); } else { bad_ref_putstatic++; if (log_enable) { log_f("[unsafe] class: %s [cause:putstatic] fin.owner: %s fin.name: %s\n", clinit_cn.name, fin.owner, fin.name); } } break; default: error_unsafe++; log_ln("[error][unsafe] class: " + clinit_cn.name + " [cause:field] unknown opcode: " + fin.getOpcode()); break; } return safe; }
Example 7
Source File: AsmMethodSource.java From JAADAS with GNU General Public License v3.0 | 4 votes |
private void convertPutFieldInsn(FieldInsnNode insn) { boolean instance = insn.getOpcode() == PUTFIELD; StackFrame frame = getFrame(insn); Operand[] out = frame.out(); Operand opr, rvalue; Type type; if (out == null) { SootClass declClass = Scene.v().getSootClass( AsmUtil.toQualifiedName(insn.owner)); type = AsmUtil.toJimpleType(insn.desc); Value val; SootFieldRef ref; rvalue = popImmediate(type); if (!instance) { ref = Scene.v().makeFieldRef(declClass, insn.name, type, true); val = Jimple.v().newStaticFieldRef(ref); frame.in(rvalue); } else { Operand base = popLocal(); ref = Scene.v().makeFieldRef(declClass, insn.name, type, false); InstanceFieldRef ifr = Jimple.v().newInstanceFieldRef( base.stackOrValue(), ref); val = ifr; base.addBox(ifr.getBaseBox()); frame.in(rvalue, base); } opr = new Operand(insn, val); frame.out(opr); AssignStmt as = Jimple.v().newAssignStmt(val, rvalue.stackOrValue()); rvalue.addBox(as.getRightOpBox()); if (!instance) { frame.boxes(as.getRightOpBox()); } else { frame.boxes(as.getRightOpBox(), ((InstanceFieldRef) val).getBaseBox()); } setUnit(insn, as); } else { opr = out[0]; type = opr.<FieldRef>value().getFieldRef().type(); rvalue = pop(type); if (!instance) { /* PUTSTATIC only needs one operand on the stack, the rvalue */ frame.mergeIn(rvalue); } else { /* PUTFIELD has a rvalue and a base */ frame.mergeIn(rvalue, pop()); } } /* * in case any static field or array is read from, and the static constructor * or the field this instruction writes to, modifies that field, write out any * previous read from field/array */ assignReadOps(null); }
Example 8
Source File: AbstractAsyncMethodTransformer.java From tascalate-async-await with BSD 2-Clause "Simplified" License | 4 votes |
protected void createAccessMethodsForAsyncMethod() { List<MethodNode> methods = methodsOf(classNode); for (Iterator<?> i = originalAsyncMethod.instructions.iterator(); i.hasNext();) { AbstractInsnNode instruction = (AbstractInsnNode) i.next(); if (instruction instanceof MethodInsnNode) { MethodInsnNode methodInstructionNode = (MethodInsnNode) instruction; if ((methodInstructionNode.getOpcode() == INVOKEVIRTUAL || methodInstructionNode.getOpcode() == INVOKESPECIAL || methodInstructionNode.getOpcode() == INVOKESTATIC ) && methodInstructionNode.owner.equals(classNode.name)) { MethodNode targetMethodNode = getMethod(methodInstructionNode.name, methodInstructionNode.desc, methods); if (null != targetMethodNode && (targetMethodNode.access & ACC_PRIVATE) != 0) { log.debug("Found private call " + BytecodeTraceUtil.toString(methodInstructionNode)); createAccessMethod(methodInstructionNode, (targetMethodNode.access & ACC_STATIC) != 0, methods); } } if (methodInstructionNode.getOpcode() == INVOKESPECIAL && !"<init>".equals(methodInstructionNode.name) && !methodInstructionNode.owner.equals(classNode.name)) { // INVOKESPECIAL is used for constructors/super-call, // private instance methods // Here we filtered out only to private super-method calls log.debug("Found super-call " + BytecodeTraceUtil.toString(methodInstructionNode)); createAccessMethod(methodInstructionNode, false, methods); } } if (instruction instanceof FieldInsnNode) { FieldInsnNode fieldInstructionNode = (FieldInsnNode) instruction; if (fieldInstructionNode.owner.equals(classNode.name)) { FieldNode targetFieldNode = getField(classNode, fieldInstructionNode.name, fieldInstructionNode.desc); if (null != targetFieldNode && (targetFieldNode.access & ACC_PRIVATE) != 0) { // log.debug("Found " + // BytecodeTraceUtil.toString(fieldInstructionNode)); if (fieldInstructionNode.getOpcode() == GETSTATIC || fieldInstructionNode.getOpcode() == GETFIELD) { createAccessGetter(fieldInstructionNode, (targetFieldNode.access & ACC_STATIC) != 0, methods); } else if (fieldInstructionNode.getOpcode() == PUTSTATIC || fieldInstructionNode.getOpcode() == PUTFIELD) { createAccessSetter(fieldInstructionNode, (targetFieldNode.access & ACC_STATIC) != 0, methods); } } } } if (instruction instanceof InvokeDynamicInsnNode) { Object[] result = findOwnerInvokeDynamic(instruction, methods); if (null != result) { MethodNode method = (MethodNode)result[1]; createAccessLambda((InvokeDynamicInsnNode)instruction, (Handle)result[0], (method.access & ACC_STATIC) != 0, methods); } } } }