当前位置: 首页>>代码示例>>Java>>正文


Java ReferenceInstruction.getReference方法代码示例

本文整理汇总了Java中org.jf.dexlib2.iface.instruction.ReferenceInstruction.getReference方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceInstruction.getReference方法的具体用法?Java ReferenceInstruction.getReference怎么用?Java ReferenceInstruction.getReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jf.dexlib2.iface.instruction.ReferenceInstruction的用法示例。


在下文中一共展示了ReferenceInstruction.getReference方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jimplify

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
public void jimplify (DexBody body) {
      if(!(instruction instanceof Instruction21c))
          throw new IllegalArgumentException("Expected Instruction21c but got: "+instruction.getClass());

      ReferenceInstruction constClass = (ReferenceInstruction) this.instruction;

      TypeReference tidi = (TypeReference)(constClass.getReference());
      String type = tidi.getType();
      if (type.startsWith("L") && type.endsWith(";"))
        type = type.replaceAll("^L", "").replaceAll(";$", "");

      int dest = ((OneRegisterInstruction) instruction).getRegisterA();
      Constant cst = ClassConstant.v(type);
      assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), cst);
      setUnit(assign);
      addTags(assign);
      body.add(assign);

if (IDalvikTyper.ENABLE_DVKTYPER) {
	Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
        int op = (int)instruction.getOpcode().value;
        //DalvikTyper.v().captureAssign((JAssignStmt)assign, op); //TODO: classtype could be null!
        DalvikTyper.v().setType(assign.getLeftOpBox(), cst.getType(), false);
      }
  }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:26,代码来源:ConstClassInstruction.java

示例2: analyzeMoveResult

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
private void analyzeMoveResult(@Nonnull AnalyzedInstruction analyzedInstruction) {
    AnalyzedInstruction previousInstruction = analyzedInstructions.valueAt(analyzedInstruction.instructionIndex - 1);
    if (!previousInstruction.instruction.getOpcode().setsResult()) {
        throw new AnalysisException(analyzedInstruction.instruction.getOpcode().name + " must occur after an " +
                "invoke-*/fill-new-array instruction");
    }

    RegisterType resultRegisterType;
    ReferenceInstruction invokeInstruction = (ReferenceInstruction) previousInstruction.instruction;
    Reference reference = invokeInstruction.getReference();

    if (reference instanceof MethodReference) {
        resultRegisterType = RegisterType.getRegisterType(classPath, ((MethodReference) reference).getReturnType());
    } else {
        resultRegisterType = RegisterType.getRegisterType(classPath, (TypeReference) reference);
    }

    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, resultRegisterType);
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:20,代码来源:MethodAnalyzer.java

示例3: analyze

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
private void analyze(@Nonnull DexBackedMethodImplementation implementation) {
    cyclomaticComplexity = calculateComplexity(implementation);
    registerCount = implementation.getRegisterCount();
    tryCatchCount = implementation.getTryBlocks().size();
    debugItemCount = Utils.makeCollection(implementation.getDebugItems()).size();

    for (Instruction instruction : implementation.getInstructions()) {
        instructionCount++;
        Opcode op = instruction.getOpcode();
        opCounts.adjustOrPutValue(op, 1, 1);

        if (instruction instanceof ReferenceInstruction) {
            ReferenceInstruction refInstr = (ReferenceInstruction) instruction;
            switch (op.referenceType) {
                case ReferenceType.METHOD:
                    MethodReference methodRef = (MethodReference) refInstr.getReference();
                    if (fullMethodSignatures) {
                        apiCounts.adjustOrPutValue(methodRef, 1, 1);
                    } else {
                        ShortMethodReference shortMethodRef = new ShortMethodReference(methodRef);
                        apiCounts.adjustOrPutValue(shortMethodRef, 1, 1);
                    }
                    break;
                case ReferenceType.FIELD:
                    FieldReference fieldRef = (FieldReference) refInstr.getReference();
                    fieldReferenceCounts.adjustOrPutValue(fieldRef, 1, 1);
                    break;
                case ReferenceType.STRING:
                    StringReference stringRef = (StringReference) refInstr.getReference();
                    stringReferenceCounts.adjustOrPutValue(stringRef, 1, 1);
                    break;
            }
        }
    }
}
 
开发者ID:CalebFenton,项目名称:apkfile,代码行数:36,代码来源:DexMethod.java

示例4: introducedTypes

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
@Override
public Set<Type> introducedTypes() {
    Set<Type> types = new HashSet<Type>();
    // Aput instructions don't have references
    if (!(instruction instanceof ReferenceInstruction))
        return types;

    ReferenceInstruction i = (ReferenceInstruction) instruction;

    FieldReference field = (FieldReference) i.getReference();

    types.add(DexType.toSoot(field.getType()));
    types.add(DexType.toSoot(field.getDefiningClass()));
    return types;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:16,代码来源:FieldInstruction.java

示例5: analyzeNewArray

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
private void analyzeNewArray(@Nonnull AnalyzedInstruction analyzedInstruction) {
    ReferenceInstruction instruction = (ReferenceInstruction) analyzedInstruction.instruction;

    TypeReference type = (TypeReference) instruction.getReference();
    if (type.getType().charAt(0) != '[') {
        throw new AnalysisException("new-array used with non-array type");
    }

    RegisterType arrayType = RegisterType.getRegisterType(classPath, type);

    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, arrayType);
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:13,代码来源:MethodAnalyzer.java

示例6: analyzeIgetSgetWideObject

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
private void analyzeIgetSgetWideObject(@Nonnull AnalyzedInstruction analyzedInstruction) {
    ReferenceInstruction referenceInstruction = (ReferenceInstruction) analyzedInstruction.instruction;

    FieldReference fieldReference = (FieldReference) referenceInstruction.getReference();

    RegisterType fieldType = RegisterType.getRegisterType(classPath, fieldReference.getType());
    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, fieldType);
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:9,代码来源:MethodAnalyzer.java

示例7: parse

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
@Override
    public void parse(MethodTracer tracer, ThreadReference thread, Location location, InsnNode node) {
        MethodLocation insn = node.getInstruction();
        MethodState mstate = tracer.getMstate();
        switch (mstate.getState()) {
            case IDEL:
                if (node.insnType == InsnType.INVOKE) {
                    ReferenceInstruction refinsn = (ReferenceInstruction)insn.getInstruction();
                    if (refinsn == null) {
                        mstate.clear();
                        break;
                    }
                    MethodReference mthref = (MethodReference)refinsn.getReference();
                    MethodEntity entity = new MethodEntity(mthref);
                    if (simplify.getDecryptMethods().contains(entity)) {
                        mstate.setState(MethodState.STATE.MOVE_RESULT); //find out next move-result instruction
                        mstate.setType(mthref.getReturnType());
                        node.add(AFlag.REMOVE);
                    }
                }
                break;
            case MOVE_RESULT:
                if (node.insnType == InsnType.MOVE_RESULT) {
                    OneRegisterInstruction ori = (OneRegisterInstruction)insn.getInstruction();
                    if (ori == null) {
                        mstate.clear();
                        break;
                    }
                    mstate.setRegisterNum(ori.getRegisterA());
                    mstate.setState(MethodState.STATE.WAIT_RESULT);
                    node.add(AFlag.REPLACE_WITH_CONSTANT);
                }
                break;
            case WAIT_RESULT:
                if (mstate.getRegisterNum() >= 0) {
//                            System.out.println("get register:"+mstate.getRegisterNum()+" "+mstate.getType());
                    Value value = new register().getValue(simplify.getCtx(), thread, location,
                            Utility.mapRegister(simplify.getCtx().getVm(), tracer.getTargetMethod(), mstate.getRegisterNum()),
                            mstate.getType());
                    if (value != null) {
                        InsnNode replace = tracer.getLastReplace();
                        if (replace != null) {
                            replace.add(AType.VALUE, new ValueAttrubite(mstate.getType(), value));
                        }
                    }
                    mstate.clear();
                }
                break;
        }
    }
 
开发者ID:CvvT,项目名称:andbg,代码行数:51,代码来源:DecryptDecode.java

示例8: analyzeCheckCast

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
private void analyzeCheckCast(@Nonnull AnalyzedInstruction analyzedInstruction) {
    ReferenceInstruction instruction = (ReferenceInstruction) analyzedInstruction.instruction;
    TypeReference reference = (TypeReference) instruction.getReference();
    RegisterType castRegisterType = RegisterType.getRegisterType(classPath, reference);
    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, castRegisterType);
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:7,代码来源:MethodAnalyzer.java

示例9: analyzeInvokeDirectCommon

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
private void analyzeInvokeDirectCommon(@Nonnull AnalyzedInstruction analyzedInstruction, int objectRegister) {
    //the only time that an invoke instruction changes a register type is when using invoke-direct on a
    //constructor (<init>) method, which changes the uninitialized reference (and any register that the same
    //uninit reference has been copied to) to an initialized reference

    ReferenceInstruction instruction = (ReferenceInstruction) analyzedInstruction.instruction;

    MethodReference methodReference = (MethodReference) instruction.getReference();

    if (!methodReference.getName().equals("<init>")) {
        return;
    }

    RegisterType objectRegisterType = analyzedInstruction.getPreInstructionRegisterType(objectRegister);

    if (objectRegisterType.category != RegisterType.UNINIT_REF &&
            objectRegisterType.category != RegisterType.UNINIT_THIS) {
        return;
    }

    setPostRegisterTypeAndPropagateChanges(analyzedInstruction, objectRegister,
            RegisterType.getRegisterType(RegisterType.REFERENCE, objectRegisterType.type));

    for (int i = 0; i < analyzedInstruction.postRegisterMap.length; i++) {
        RegisterType postInstructionRegisterType = analyzedInstruction.postRegisterMap[i];
        if (postInstructionRegisterType.category == RegisterType.UNKNOWN) {
            RegisterType preInstructionRegisterType =
                    analyzedInstruction.getPreInstructionRegisterType(i);

            if (preInstructionRegisterType.category == RegisterType.UNINIT_REF ||
                    preInstructionRegisterType.category == RegisterType.UNINIT_THIS) {
                RegisterType registerType;
                if (preInstructionRegisterType.equals(objectRegisterType)) {
                    registerType = analyzedInstruction.postRegisterMap[objectRegister];
                } else {
                    registerType = preInstructionRegisterType;
                }

                setPostRegisterTypeAndPropagateChanges(analyzedInstruction, i, registerType);
            }
        }
    }
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:44,代码来源:MethodAnalyzer.java

示例10: test

import org.jf.dexlib2.iface.instruction.ReferenceInstruction; //导入方法依赖的package包/类
public static void test(String argv[]){
		try {
			DexBackedDexFile dexFile = DexFileFactory.loadDexFile(search_path, 16);
			for (ClassDef classdef: dexFile.getClasses()){
				for (Method method: classdef.getMethods()){
					MethodImplementation impl = method.getImplementation();
					if (impl == null) {
						continue;
					}
//					System.out.println(method.getDefiningClass() + "->" + method.getName());
					for (Instruction instruction: impl.getInstructions()){
						Opcode opcode = instruction.getOpcode();
						if (opcode.referenceType == ReferenceType.METHOD){
							ReferenceInstruction ref = (ReferenceInstruction)instruction;
							MethodReference methodRef = (MethodReference)ref.getReference();
							if (methodRef.getName().equals("d") && 
									methodRef.getDefiningClass().equals("Lcom/baidu/protect/A;")) {
								List<? extends CharSequence> params = methodRef.getParameterTypes();
								
								if (params.size() == paramsList.size()) {
									boolean flag = true;
									int index = 0;
									for(CharSequence param: params){
										if (!param.equals(paramsList.get(index))) {
											flag = false;
											break;
										}
										index++;
									}
									if (flag && "V".equals(methodRef.getReturnType())) {
										
									}
								}
							}
//							System.out.println(methodRef.getName() + " " + methodRef.getDefiningClass());
						}
					}
				}
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
 
开发者ID:CvvT,项目名称:DexTamper,代码行数:45,代码来源:Test.java


注:本文中的org.jf.dexlib2.iface.instruction.ReferenceInstruction.getReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。