public void setApiLevel(int apiLevel) { this.opcodes = Opcodes.forApi(apiLevel); this.apiLevel = apiLevel; }
private static String buildFrameworkCache(String resPath) throws Exception { List<File> resFiles = new LinkedList<>(); try { URL url = FrameworkJarBuilder.class.getResource(resPath); File file = new File(url.toURI()); resFiles.addAll(Utils.getFilesWithSmaliExtension(file)); } catch (URISyntaxException e) { e.printStackTrace(); } DexBuilder dexBuilder = new DexBuilder(Opcodes.getDefault()); StringBuilder sb = new StringBuilder(); for (File resFile : resFiles) { String absPath = resFile.getAbsolutePath(); String path = absPath.substring(absPath.lastIndexOf(FRAMEWORK_ROOT)); InputStream is = FrameworkJarBuilder.class.getResourceAsStream(path); BuilderClassDef classDef = SmaliParser.parse(path, is, dexBuilder); sb.append(ReferenceUtil.getReferenceString(classDef)); sb.append(':').append(path.substring(1)).append('\n'); } return sb.toString(); }
private void build() throws AndrolibException { try { DexBuilder dexBuilder; if (mApiLevel > 0) { dexBuilder = new DexBuilder(Opcodes.forApi(mApiLevel)); } else { dexBuilder = new DexBuilder(Opcodes.getDefault()); } for (String fileName : mSmaliDir.getDirectory().getFiles(true)) { buildFile(fileName, dexBuilder); } dexBuilder.writeTo(new FileDataStore( new File(mDexFile.getAbsolutePath()))); } catch (IOException | DirectoryException ex) { throw new AndrolibException(ex); } }
public final void insn_format10x() throws RecognitionException { CommonTree INSTRUCTION_FORMAT10x116=null; try { // smaliTreeWalker.g:818:3: ( ^( I_STATEMENT_FORMAT10x INSTRUCTION_FORMAT10x ) ) // smaliTreeWalker.g:819:5: ^( I_STATEMENT_FORMAT10x INSTRUCTION_FORMAT10x ) { match(input,I_STATEMENT_FORMAT10x,FOLLOW_I_STATEMENT_FORMAT10x_in_insn_format10x2244); match(input, Token.DOWN, null); INSTRUCTION_FORMAT10x116=(CommonTree)match(input,INSTRUCTION_FORMAT10x,FOLLOW_INSTRUCTION_FORMAT10x_in_insn_format10x2246); match(input, Token.UP, null); Opcode opcode = opcodes.getOpcodeByName((INSTRUCTION_FORMAT10x116!=null?INSTRUCTION_FORMAT10x116.getText():null)); method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction10x(opcode)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } } // $ANTLR end "insn_format10x"
"Liface/sub2;", "Liface/sub3;", "Liface/sub4;")); oldClassPath = new ClassPath(new DexClassProvider(new ImmutableDexFile(Opcodes.getDefault(), classes))); newClassPath = new ClassPath(Lists.newArrayList(new DexClassProvider( new ImmutableDexFile(Opcodes.forArtVersion(72), classes))), true, 72);
this.opcodes = Opcodes.forArtVersion(oatHeader.getVersion()); this.vdexProvider = vdexProvider;
@Nonnull public static Instruction readFrom(@Nonnull DexReader reader) { int opcodeValue = reader.peekUbyte(); if (opcodeValue == 0) { opcodeValue = reader.peekUshort(); } Opcode opcode = reader.dexBuf.getOpcodes().getOpcodeByValue(opcodeValue); Instruction instruction = buildInstruction(reader.dexBuf, opcode, reader.getOffset()); reader.moveRelative(instruction.getCodeUnits()*2); return instruction; }
public final void insn_format10t() throws RecognitionException { CommonTree INSTRUCTION_FORMAT10t114=null; Label label_ref115 =null; try { // smaliTreeWalker.g:810:3: ( ^( I_STATEMENT_FORMAT10t INSTRUCTION_FORMAT10t label_ref ) ) // smaliTreeWalker.g:811:5: ^( I_STATEMENT_FORMAT10t INSTRUCTION_FORMAT10t label_ref ) { match(input,I_STATEMENT_FORMAT10t,FOLLOW_I_STATEMENT_FORMAT10t_in_insn_format10t2217); match(input, Token.DOWN, null); INSTRUCTION_FORMAT10t114=(CommonTree)match(input,INSTRUCTION_FORMAT10t,FOLLOW_INSTRUCTION_FORMAT10t_in_insn_format10t2219); pushFollow(FOLLOW_label_ref_in_insn_format10t2221); label_ref115=label_ref(); state._fsp--; match(input, Token.UP, null); Opcode opcode = opcodes.getOpcodeByName((INSTRUCTION_FORMAT10t114!=null?INSTRUCTION_FORMAT10t114.getText():null)); method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction10t(opcode, label_ref115)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } } // $ANTLR end "insn_format10t"
this.opcodes = Opcodes.forArtVersion(oatHeader.getVersion()); this.vdexProvider = vdexProvider;
@Nonnull public static Instruction readFrom(@Nonnull DexReader reader) { int opcodeValue = reader.peekUbyte(); if (opcodeValue == 0) { opcodeValue = reader.peekUshort(); } Opcode opcode = reader.dexBuf.getOpcodes().getOpcodeByValue(opcodeValue); Instruction instruction = buildInstruction(reader.dexBuf, opcode, reader.getOffset()); reader.moveRelative(instruction.getCodeUnits()*2); return instruction; }
public void setApiLevel(int apiLevel) { this.opcodes = Opcodes.forApi(apiLevel); this.apiLevel = apiLevel; }
/** * @param smaliPath Path to Smali file or folder */ public ClassManager build(String smaliPath) throws IOException { return build(smaliPath, new DexBuilder(Opcodes.getDefault())); }
public final void insn_format20t() throws RecognitionException { CommonTree INSTRUCTION_FORMAT20t126=null; Label label_ref127 =null; try { // smaliTreeWalker.g:873:3: ( ^( I_STATEMENT_FORMAT20t INSTRUCTION_FORMAT20t label_ref ) ) // smaliTreeWalker.g:874:5: ^( I_STATEMENT_FORMAT20t INSTRUCTION_FORMAT20t label_ref ) { match(input,I_STATEMENT_FORMAT20t,FOLLOW_I_STATEMENT_FORMAT20t_in_insn_format20t2387); match(input, Token.DOWN, null); INSTRUCTION_FORMAT20t126=(CommonTree)match(input,INSTRUCTION_FORMAT20t,FOLLOW_INSTRUCTION_FORMAT20t_in_insn_format20t2389); pushFollow(FOLLOW_label_ref_in_insn_format20t2391); label_ref127=label_ref(); state._fsp--; match(input, Token.UP, null); Opcode opcode = opcodes.getOpcodeByName((INSTRUCTION_FORMAT20t126!=null?INSTRUCTION_FORMAT20t126.getText():null)); method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction20t(opcode, label_ref127)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } } // $ANTLR end "insn_format20t"
public void setApiLevel(int apiLevel) { this.opcodes = new Opcodes(apiLevel); this.apiLevel = apiLevel; }
@Test public void testBuilderCallSite() throws IOException { DexBuilder dexBuilder = new DexBuilder(Opcodes.forArtVersion(111)); BuilderCallSiteReference callSite = dexBuilder.internCallSite(new ImmutableCallSiteReference("call_site_1", new ImmutableMethodHandleReference( MethodHandleType.INVOKE_STATIC, new ImmutableMethodReference("Lcls1", "loader", ImmutableList.of("Ljava/lang/invoke/Lookup;", "Ljava/lang/String;", "Ljava/lang/invoke/MethodType;"), "Ljava/lang/invoke/CallSite;")), "someMethod", new ImmutableMethodProtoReference(ImmutableList.of(), "V"), ImmutableList.of())); MethodImplementationBuilder methodImplementationBuilder = new MethodImplementationBuilder(10); methodImplementationBuilder.addInstruction(new BuilderInstruction35c(Opcode.INVOKE_CUSTOM, 0, 0, 0, 0, 0, 0, callSite)); BuilderMethod method = dexBuilder.internMethod("Lcls1", "method1", null, "V", 0, ImmutableSet.of(), methodImplementationBuilder.getMethodImplementation()); dexBuilder.internClassDef("Lcls1;", AccessFlags.PUBLIC.getValue(), "Ljava/lang/Object;", null, null, ImmutableSet.of(), null, ImmutableList.of(method)); File tempFile = File.createTempFile("dex", ".dex"); dexBuilder.writeTo(new FileDataStore(tempFile)); verifyDexFile(DexFileFactory.loadDexFile(tempFile, Opcodes.forArtVersion(111))); }
@Nonnull public static Instruction readFrom(@Nonnull DexReader reader) { int opcodeValue = reader.peekUbyte(); if (opcodeValue == 0) { opcodeValue = reader.peekUshort(); } Opcode opcode = reader.dexBuf.getOpcodes().getOpcodeByValue(opcodeValue); Instruction instruction = buildInstruction(reader.dexBuf, opcode, reader.getOffset()); reader.moveRelative(instruction.getCodeUnits()*2); return instruction; }
public static List<BuilderClassDef> parse(String path) throws Exception { DexBuilder dexBuilder = new DexBuilder(Opcodes.forApi(SmaliParser.DEFAULT_API_LEVEL)); return parseFiles(new File(path), dexBuilder); }
/** * 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); }
public final void insn_format30t() throws RecognitionException { CommonTree INSTRUCTION_FORMAT30t163=null; Label label_ref164 =null; try { // smaliTreeWalker.g:1075:3: ( ^( I_STATEMENT_FORMAT30t INSTRUCTION_FORMAT30t label_ref ) ) // smaliTreeWalker.g:1076:5: ^( I_STATEMENT_FORMAT30t INSTRUCTION_FORMAT30t label_ref ) { match(input,I_STATEMENT_FORMAT30t,FOLLOW_I_STATEMENT_FORMAT30t_in_insn_format30t2944); match(input, Token.DOWN, null); INSTRUCTION_FORMAT30t163=(CommonTree)match(input,INSTRUCTION_FORMAT30t,FOLLOW_INSTRUCTION_FORMAT30t_in_insn_format30t2946); pushFollow(FOLLOW_label_ref_in_insn_format30t2948); label_ref164=label_ref(); state._fsp--; match(input, Token.UP, null); Opcode opcode = opcodes.getOpcodeByName((INSTRUCTION_FORMAT30t163!=null?INSTRUCTION_FORMAT30t163.getText():null)); method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction30t(opcode, label_ref164)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } } // $ANTLR end "insn_format30t"