本文整理汇总了Java中org.jf.dexlib2.iface.MethodImplementation.getInstructions方法的典型用法代码示例。如果您正苦于以下问题:Java MethodImplementation.getInstructions方法的具体用法?Java MethodImplementation.getInstructions怎么用?Java MethodImplementation.getInstructions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jf.dexlib2.iface.MethodImplementation
的用法示例。
在下文中一共展示了MethodImplementation.getInstructions方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reMethodImpl
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
@Override
protected MethodImplementation reMethodImpl(MethodImplementation methodImplementation) {
if (methodImplementation == null){
return null;
}
Iterable<? extends Instruction> instructions = methodImplementation.getInstructions();
Iterable<? extends DebugItem> debugItems = methodImplementation.getDebugItems();
List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = methodImplementation.getTryBlocks();
return new ImmutableMethodImplementation(methodImplementation.getRegisterCount(), reInstructions(instructions), reTryCatchBlock(methodImplementation.getTryBlocks()), reDebugItem(methodImplementation.getDebugItems()));
}
示例2: of
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
@Nullable
public static ImmutableMethodImplementation of(@Nullable MethodImplementation methodImplementation) {
if (methodImplementation == null) {
return null;
}
if (methodImplementation instanceof ImmutableMethodImplementation) {
return (ImmutableMethodImplementation)methodImplementation;
}
return new ImmutableMethodImplementation(
methodImplementation.getRegisterCount(),
methodImplementation.getInstructions(),
methodImplementation.getTryBlocks(),
methodImplementation.getDebugItems());
}
示例3: getInstructions
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
@Nullable @Override
public Iterable<? extends Instruction> getInstructions(@Nonnull BuilderMethod builderMethod) {
MethodImplementation impl = builderMethod.getImplementation();
if (impl == null) {
return null;
}
return impl.getInstructions();
}
示例4: of
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
public static ImmutableMethodImplementation of( MethodImplementation methodImplementation) {
if (methodImplementation == null) {
return null;
}
if (methodImplementation instanceof ImmutableMethodImplementation) {
return (ImmutableMethodImplementation)methodImplementation;
}
return new ImmutableMethodImplementation(
methodImplementation.getRegisterCount(),
methodImplementation.getInstructions(),
methodImplementation.getTryBlocks(),
methodImplementation.getDebugItems());
}
示例5: getInstructions
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
@Override
public Iterable<? extends Instruction> getInstructions( BuilderMethod builderMethod) {
MethodImplementation impl = builderMethod.getImplementation();
if (impl == null) {
return null;
}
return impl.getInstructions();
}
示例6: onSimpleEdit
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
@Override
protected Method onSimpleEdit(Method patch, PatcherAnnotation annotation, Method target, boolean inPlace) {
if (!inPlace && NATIVE.isSet(patch.getAccessFlags() & target.getAccessFlags())) {
log(ERROR, "cannot rename native method");
}
MethodImplementation implementation = target.getImplementation();
if (isTaggedByLastParameter(patch, false)) {
List<? extends MethodParameter> parameters = patch.getParameters();
MethodParameter lastParameter = parameters.get(parameters.size() - 1);
int tagRegisterCount = (TypeUtils.isWideType(lastParameter) ? 2 : 1);
implementation = new BasicMethodImplementation(
implementation.getRegisterCount() + tagRegisterCount,
implementation.getInstructions(),
implementation.getTryBlocks(),
implementation.getDebugItems());
}
Method patched = new BasicMethod(
patch.getDefiningClass(),
patch.getName(),
patch.getParameters(),
patch.getReturnType(),
patch.getAccessFlags(),
annotation.getFilteredAnnotations(),
implementation);
return super.onSimpleEdit(patched, annotation, target, inPlace);
}
示例7: of
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
@Nullable
public static ImmutableMethodImplementation of(@Nullable MethodImplementation methodImplementation) {
if (methodImplementation == null) {
return null;
}
if (methodImplementation instanceof ImmutableMethodImplementation) {
return (ImmutableMethodImplementation) methodImplementation;
}
return new ImmutableMethodImplementation(
methodImplementation.getRegisterCount(),
methodImplementation.getInstructions(),
methodImplementation.getTryBlocks(),
methodImplementation.getDebugItems());
}
示例8: getInstructions
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
@Nullable
@Override
public Iterable<? extends Instruction> getInstructions(@Nonnull PoolMethod method) {
MethodImplementation impl = method.getImplementation();
if (impl != null) {
return impl.getInstructions();
}
return null;
}
示例9: getInstructions
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
@Nullable
@Override
public Iterable<? extends Instruction> getInstructions(@Nonnull BuilderMethod builderMethod) {
MethodImplementation impl = builderMethod.getImplementation();
if (impl == null) {
return null;
}
return impl.getInstructions();
}
示例10: DexBody
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
/**
* @param code the codeitem that is contained in this body
* @param method the method that is associated with this body
*/
public DexBody(DexFile dexFile, Method method, RefType declaringClassType) {
MethodImplementation code = method.getImplementation();
if (code == null)
throw new RuntimeException("error: no code for method "+ method.getName());
this.declaringClassType = declaringClassType;
tries = code.getTryBlocks();
methodSignature = method.getDefiningClass() +": "+ method.getReturnType() +" "+ method.getName() +"(";
for (MethodParameter mp: method.getParameters())
methodSignature += mp.getType() +",";
List<? extends CharSequence> paramTypes = method.getParameterTypes();
if (paramTypes != null) {
parameterTypes = new ArrayList<Type>();
for (CharSequence type : paramTypes)
parameterTypes.add(DexType.toSoot(type.toString()));
} else {
parameterTypes = Collections.emptyList();
}
isStatic = Modifier.isStatic(method.getAccessFlags());
numRegisters = code.getRegisterCount();
numParameterRegisters = MethodUtil.getParameterRegisterCount(method);
if (!isStatic)
numParameterRegisters--;
instructions = new ArrayList<DexlibAbstractInstruction>();
instructionAtAddress = new HashMap<Integer, DexlibAbstractInstruction>();
registerLocals = new Local[numRegisters];
int address = 0;
for (Instruction instruction : code.getInstructions()) {
DexlibAbstractInstruction dexInstruction = fromInstruction(instruction, address);
instructions.add(dexInstruction);
instructionAtAddress.put(address, dexInstruction);
Debug.printDbg(" put instruction '", dexInstruction ,"' at 0x", Integer.toHexString(address));
address += instruction.getCodeUnits();
}
// Check taken from Android's dalvik/libdex/DexSwapVerify.cpp
if (numParameterRegisters > numRegisters)
throw new RuntimeException("Malformed dex file: insSize (" + numParameterRegisters
+ ") > registersSize (" + numRegisters + ")");
for (DebugItem di: code.getDebugItems()) {
if (di instanceof ImmutableLineNumber) {
ImmutableLineNumber ln = (ImmutableLineNumber)di;
DexlibAbstractInstruction ins = instructionAtAddress(ln.getCodeAddress());
if (ins == null) {
Debug.printDbg("Line number tag pointing to invalid offset: " + ln.getCodeAddress());
continue;
}
ins.setLineNumber(ln.getLineNumber());
Debug.printDbg("Add line number tag " + ln.getLineNumber() + " for instruction: "
+ instructionAtAddress(ln.getCodeAddress()));
}
}
this.dexFile = dexFile;
}
示例11: internCode
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的package包/类
private void internCode(@Nonnull Method method) {
// this also handles parameter names, which aren't directly tied to the MethodImplementation, even though the debug items are
boolean hasInstruction = false;
MethodImplementation methodImpl = method.getImplementation();
if (methodImpl != null) {
for (Instruction instruction : methodImpl.getInstructions()) {
hasInstruction = true;
if (instruction instanceof ReferenceInstruction) {
Reference reference = ((ReferenceInstruction) instruction).getReference();
switch (instruction.getOpcode().referenceType) {
case ReferenceType.STRING:
stringPool.intern((StringReference) reference);
break;
case ReferenceType.TYPE:
typePool.intern((TypeReference) reference);
break;
case ReferenceType.FIELD:
fieldPool.intern((FieldReference) reference);
break;
case ReferenceType.METHOD:
methodPool.intern((MethodReference) reference);
break;
default:
throw new ExceptionWithContext("Unrecognized reference type: %d",
instruction.getOpcode().referenceType);
}
}
}
List<? extends TryBlock> tryBlocks = methodImpl.getTryBlocks();
if (!hasInstruction && tryBlocks.size() > 0) {
throw new ExceptionWithContext("Method %s has no instructions, but has try blocks.",
ReferenceUtil.getMethodDescriptor(method));
}
for (TryBlock<? extends ExceptionHandler> tryBlock : methodImpl.getTryBlocks()) {
for (ExceptionHandler handler : tryBlock.getExceptionHandlers()) {
typePool.internNullable(handler.getExceptionType());
}
}
}
}
示例12: test
import org.jf.dexlib2.iface.MethodImplementation; //导入方法依赖的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();
}
}