Java Code Examples for org.jf.dexlib2.Opcode#INVOKE_DIRECT

The following examples show how to use org.jf.dexlib2.Opcode#INVOKE_DIRECT . 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: MethodAnalyzer.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
private void analyzeExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) {
    if (inlineResolver == null) {
        throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing");
    }

    Instruction35mi instruction = (Instruction35mi)analyzedInstruction.instruction;
    Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction);

    Opcode deodexedOpcode;
    int acccessFlags = resolvedMethod.getAccessFlags();
    if (AccessFlags.STATIC.isSet(acccessFlags)) {
        deodexedOpcode = Opcode.INVOKE_STATIC;
    } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) {
        deodexedOpcode = Opcode.INVOKE_DIRECT;
    } else {
        deodexedOpcode = Opcode.INVOKE_VIRTUAL;
    }

    Instruction35c deodexedInstruction = new ImmutableInstruction35c(deodexedOpcode, instruction.getRegisterCount(),
            instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(),
            instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod);

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);
    analyzeInstruction(analyzedInstruction);
}
 
Example 2
Source File: MethodAnalyzer.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
private void analyzeInvokeObjectInitRange(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) {
    Instruction3rc instruction = (Instruction3rc)analyzedInstruction.instruction;

    Instruction deodexedInstruction;

    int startRegister = instruction.getStartRegister();
    // hack: we should be using instruction.getRegisterCount, but some tweaked versions of dalvik appear
    // to generate invoke-object-init/range instructions with an invalid register count. We know it should
    // always be 1, so just use that.
    int registerCount = 1;
    if (startRegister < 16) {
        deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT,
                registerCount, startRegister, 0, 0, 0, 0, instruction.getReference());
    } else {
        deodexedInstruction = new ImmutableInstruction3rc(Opcode.INVOKE_DIRECT_RANGE,
                startRegister, registerCount, instruction.getReference());
    }

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);

    if (analyzeResult) {
        analyzeInstruction(analyzedInstruction);
    }
}
 
Example 3
Source File: MethodAnalyzer.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
private void analyzeExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) {
    if (inlineResolver == null) {
        throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing");
    }

    Instruction35mi instruction = (Instruction35mi)analyzedInstruction.instruction;
    Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction);

    Opcode deodexedOpcode;
    int acccessFlags = resolvedMethod.getAccessFlags();
    if (AccessFlags.STATIC.isSet(acccessFlags)) {
        deodexedOpcode = Opcode.INVOKE_STATIC;
    } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) {
        deodexedOpcode = Opcode.INVOKE_DIRECT;
    } else {
        deodexedOpcode = Opcode.INVOKE_VIRTUAL;
    }

    Instruction35c deodexedInstruction = new ImmutableInstruction35c(deodexedOpcode, instruction.getRegisterCount(),
            instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(),
            instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod);

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);
    analyzeInstruction(analyzedInstruction);
}
 
Example 4
Source File: MethodAnalyzer.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
private void analyzeInvokeObjectInitRange(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) {
    Instruction3rc instruction = (Instruction3rc)analyzedInstruction.instruction;

    Instruction deodexedInstruction;

    int startRegister = instruction.getStartRegister();
    // hack: we should be using instruction.getRegisterCount, but some tweaked versions of dalvik appear
    // to generate invoke-object-init/range instructions with an invalid register count. We know it should
    // always be 1, so just use that.
    int registerCount = 1;
    if (startRegister < 16) {
        deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT,
                registerCount, startRegister, 0, 0, 0, 0, instruction.getReference());
    } else {
        deodexedInstruction = new ImmutableInstruction3rc(Opcode.INVOKE_DIRECT_RANGE,
                startRegister, registerCount, instruction.getReference());
    }

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);

    if (analyzeResult) {
        analyzeInstruction(analyzedInstruction);
    }
}
 
Example 5
Source File: MethodAnalyzer.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
private void analyzeExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) {
    if (inlineResolver == null) {
        throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing");
    }

    Instruction35mi instruction = (Instruction35mi)analyzedInstruction.instruction;
    Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction);

    Opcode deodexedOpcode;
    int acccessFlags = resolvedMethod.getAccessFlags();
    if (AccessFlags.STATIC.isSet(acccessFlags)) {
        deodexedOpcode = Opcode.INVOKE_STATIC;
    } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) {
        deodexedOpcode = Opcode.INVOKE_DIRECT;
    } else {
        deodexedOpcode = Opcode.INVOKE_VIRTUAL;
    }

    Instruction35c deodexedInstruction = new ImmutableInstruction35c(deodexedOpcode, instruction.getRegisterCount(),
            instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(),
            instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod);

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);
    analyzeInstruction(analyzedInstruction);
}
 
Example 6
Source File: MethodAnalyzer.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
private void analyzeInvokeObjectInitRange(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) {
    Instruction3rc instruction = (Instruction3rc)analyzedInstruction.instruction;

    Instruction deodexedInstruction;

    int startRegister = instruction.getStartRegister();
    // hack: we should be using instruction.getRegisterCount, but some tweaked versions of dalvik appear
    // to generate invoke-object-init/range instructions with an invalid register count. We know it should
    // always be 1, so just use that.
    int registerCount = 1;
    if (startRegister < 16) {
        deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT,
                registerCount, startRegister, 0, 0, 0, 0, instruction.getReference());
    } else {
        deodexedInstruction = new ImmutableInstruction3rc(Opcode.INVOKE_DIRECT_RANGE,
                startRegister, registerCount, instruction.getReference());
    }

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);

    if (analyzeResult) {
        analyzeInstruction(analyzedInstruction);
    }
}
 
Example 7
Source File: MethodAnalyzer.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
private void analyzeExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) {
    if (inlineResolver == null) {
        throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing");
    }

    Instruction35mi instruction = (Instruction35mi)analyzedInstruction.instruction;
    Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction);

    Opcode deodexedOpcode;
    int acccessFlags = resolvedMethod.getAccessFlags();
    if (AccessFlags.STATIC.isSet(acccessFlags)) {
        deodexedOpcode = Opcode.INVOKE_STATIC;
    } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) {
        deodexedOpcode = Opcode.INVOKE_DIRECT;
    } else {
        deodexedOpcode = Opcode.INVOKE_VIRTUAL;
    }

    Instruction35c deodexedInstruction = new ImmutableInstruction35c(deodexedOpcode, instruction.getRegisterCount(),
            instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(),
            instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod);

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);
    analyzeInstruction(analyzedInstruction);
}
 
Example 8
Source File: MethodAnalyzer.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
private void analyzeInvokeObjectInitRange(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) {
    Instruction3rc instruction = (Instruction3rc)analyzedInstruction.instruction;

    Instruction deodexedInstruction;

    int startRegister = instruction.getStartRegister();
    // hack: we should be using instruction.getRegisterCount, but some tweaked versions of dalvik appear
    // to generate invoke-object-init/range instructions with an invalid register count. We know it should
    // always be 1, so just use that.
    int registerCount = 1;
    if (startRegister < 16) {
        deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT,
                registerCount, startRegister, 0, 0, 0, 0, instruction.getReference());
    } else {
        deodexedInstruction = new ImmutableInstruction3rc(Opcode.INVOKE_DIRECT_RANGE,
                startRegister, registerCount, instruction.getReference());
    }

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);

    if (analyzeResult) {
        analyzeInstruction(analyzedInstruction);
    }
}
 
Example 9
Source File: MethodAnalyzer.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private void analyzeInvokeDirectEmpty(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) {
    Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction;

    Instruction35c deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT,
            instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(),
            instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(),
            instruction.getReference());

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);

    if (analyzeResult) {
        analyzeInstruction(analyzedInstruction);
    }
}
 
Example 10
Source File: PatchMethodTool.java    From atlas with Apache License 2.0 5 votes vote down vote up
private static MethodImplementation modifyMethodTpatch(@Nonnull MethodImplementation implementation, Method method) {
        MutableMethodImplementation mutableImplementation = new MutableMethodImplementation(implementation);
        System.out.println(mutableImplementation.getRegisterCount());
        List<BuilderInstruction> instructions = mutableImplementation.getInstructions();
        boolean isModified = false;
        for (int i = 0; i < instructions.size(); i++) {
            isModified = false;
            if (instructions.get(i).getOpcode() == Opcode.INVOKE_DIRECT) {
                if (!isModified) {
                    mutableImplementation.addInstruction(i++,
                            new BuilderInstruction21c(Opcode.CONST_STRING, 0,
                                    new ImmutableStringReference("tpatch:" + method.getDefiningClass().replace("/", "."))));
                    mutableImplementation.addInstruction(i++,
                            new BuilderInstruction35c(Opcode.INVOKE_STATIC, 1,
                                    0, 0, 0, 0, 0,
                                    new ImmutableMethodReference("Landroid/util/Log;", "e",
                                            Lists.newArrayList("Ljava/lang/String;", "Ljava/lang/String;"), "I")));
                    isModified = true;
                    break;

                }

            }
//            mutableImplementation.addInstruction(instructions.get(i));
        }

        return mutableImplementation;
    }
 
Example 11
Source File: MethodAnalyzer.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
private void analyzeInvokeDirectEmpty(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) {
    Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction;

    Instruction35c deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT,
            instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(),
            instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(),
            instruction.getReference());

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);

    if (analyzeResult) {
        analyzeInstruction(analyzedInstruction);
    }
}
 
Example 12
Source File: MethodAnalyzer.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
private void analyzeInvokeDirectEmpty(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) {
    Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction;

    Instruction35c deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT,
            instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(),
            instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(),
            instruction.getReference());

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);

    if (analyzeResult) {
        analyzeInstruction(analyzedInstruction);
    }
}
 
Example 13
Source File: MethodAnalyzer.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private void analyzeInvokeDirectEmpty(@Nonnull AnalyzedInstruction analyzedInstruction, boolean analyzeResult) {
    Instruction35c instruction = (Instruction35c)analyzedInstruction.instruction;

    Instruction35c deodexedInstruction = new ImmutableInstruction35c(Opcode.INVOKE_DIRECT,
            instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(),
            instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(),
            instruction.getReference());

    analyzedInstruction.setDeodexedInstruction(deodexedInstruction);

    if (analyzeResult) {
        analyzeInstruction(analyzedInstruction);
    }
}