public void setApiLevel(int apiLevel) { this.opcodes = Opcodes.forApi(apiLevel); this.apiLevel = apiLevel; }
public static boolean isSupportedDexVersion(int version) { return VersionMap.mapDexVersionToApi(version) != VersionMap.NO_VERSION; }
/** * Get the highest magic number supported by Android for this api level. * @return The dex file magic number */ public static byte[] getMagicForApi(int api) { return getMagicForDexVersion(VersionMap.mapApiToDexVersion(api)); }
private boolean needsAnalyzed() { for (Instruction instruction: methodImpl.getInstructions()) { if (instruction.getOpcode().odexOnly()) { return true; } } return false; }
/** * @param smaliPath Path to Smali file or folder */ public ClassManager build(File smaliPath, int outputAPILevel) throws IOException { return build(smaliPath, new DexBuilder(Opcodes.forApi(outputAPILevel))); }
/** * Returns true if this class is an interface. * * If this class is not defined, then this will throw an UnresolvedClassException * * @return True if this class is an interface */ public boolean isInterface() { ClassDef classDef = getClassDef(); return (classDef.getAccessFlags() & AccessFlags.INTERFACE.getValue()) != 0; }
@Override public void jimplify(DexBody body) { int acccessFlags = targetMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) { jimplifyStatic(body); } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { jimplifySpecial(body); } else { jimplifyVirtual(body); } }
/** * @param smaliPath Path to Smali file or folder */ public ClassManager build(String smaliPath) throws IOException { return build(smaliPath, new DexBuilder(Opcodes.getDefault())); }
@Nonnull public static DexBackedDexFile loadDexFile(@Nonnull String path, @Nullable Opcodes opcodes) throws IOException { return loadDexFile(new File(path), opcodes); }
private static void writeAccessFlags(IndentingWriter writer, int accessFlags) throws IOException { for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForMethod(accessFlags)) { writer.write(accessFlag.toString()); writer.write(' '); } }
private String writeInvalidItemIndex(InvalidItemIndex ex, int type, IndentingWriter writer) throws IOException { writer.write("#"); writer.write(ex.getMessage()); writer.write("\n"); return String.format("%s@%d", ReferenceType.toString(type), ex.getInvalidIndex()); }
private Opcode getInvokeOp(int classAccessFlags, int methodAccessFlags, boolean isRange) { Opcode invokeOp; boolean isInterface = Modifier.isInterface(classAccessFlags); if (isInterface) { invokeOp = isRange ? Opcode.INVOKE_INTERFACE_RANGE : Opcode.INVOKE_INTERFACE; return invokeOp; } boolean isStatic = Modifier.isStatic(methodAccessFlags); boolean isPrivate = Modifier.isPrivate(methodAccessFlags); boolean isConstructor = (methodAccessFlags & AccessFlags.CONSTRUCTOR.getValue()) != 0; if (isStatic) { invokeOp = isRange ? Opcode.INVOKE_STATIC_RANGE : Opcode.INVOKE_STATIC; } else if (isPrivate || isConstructor) { invokeOp = isRange ? Opcode.INVOKE_DIRECT_RANGE : Opcode.INVOKE_DIRECT; } else { invokeOp = isRange ? Opcode.INVOKE_VIRTUAL_RANGE : Opcode.INVOKE_VIRTUAL; } return invokeOp; }
@Override public String toString() { return opc.toString() + " " + regs; }
private boolean isAllowedOdex(@Nonnull Opcode opcode) { BaksmaliOptions options = methodDef.classDef.options; if (options.allowOdex) { return true; } if (methodDef.classDef.options.apiLevel >= 14) { return false; } return opcode.isVolatileFieldAccessor() || opcode == Opcode.THROW_VERIFICATION_ERROR; }
private Insn buildLit16BinaryInsn(String binaryOperation, Register firstOpReg, short secondOpLieteral) { Opcode opc = Opcode.valueOf(binaryOperation + "_INT_LIT16"); return new Insn22s(opc, destinationReg, firstOpReg, secondOpLieteral); }
/** * Create a ClassManager with no input Smali classes. It will only contain parse library * classes. */ public ClassManager build(int outputAPILevel) throws IOException { DexBuilder dexBuilder = new DexBuilder(Opcodes.forApi(outputAPILevel)); return build(dexBuilder); }
public void setApiLevel(int apiLevel) { this.opcodes = Opcodes.forApi(apiLevel); this.apiLevel = apiLevel; }
/** * Create a ClassManager with no input Smali classes. It will only contain parse library * classes. */ public ClassManager build() throws IOException { DexBuilder dexBuilder = new DexBuilder(Opcodes.getDefault()); return build(dexBuilder); }
private Insn buildLit8BinaryInsn(String binaryOperation, Register firstOpReg, byte secondOpLiteral) { Opcode opc = Opcode.valueOf(binaryOperation + "_INT_LIT8"); return new Insn22b(opc, destinationReg, firstOpReg, secondOpLiteral); }
public static DexBuilder getDexBuilder() { return new DexBuilder(Opcodes.forApi(SmaliParser.DEFAULT_API_LEVEL)); }