1#![allow(dead_code)]
2
3use crate::dex::reader::DexReader;
4use crate::dex::file::DexFile;
5use crate::dex::instructions::Instructions;
6
7pub mod dex;
8pub mod error;
9mod adler32;
10
11pub fn parse(filepath: &str) -> DexFile {
13 let readers = DexReader::build_from_file(filepath);
14 DexFile::merge(readers)
15}
16
17pub fn get_qualified_method_names(dex: &DexFile) -> Vec<String> {
19 let mut methods = Vec::new();
20
21 let class_names = dex.get_classes_names();
22 for class in class_names.iter() {
23 if let Some(class_def) = dex.classes.get_class_def(class) {
24 for method in class_def.get_methods() {
25 let name = method.get_method_name();
26 methods.push(format!("{class}->{name}"));
27 }
28 }
29 }
30
31 methods
32}
33
34pub fn get_bytecode_for_method(dex: &DexFile,
36 class_name: &String,
37 method_name: &String) -> Option<Vec<Instructions>> {
38 if let Some(class_def) = dex.get_class_def(class_name) {
39 if let Some(encoded_method) = class_def.get_encoded_method(method_name) {
40 if let Some(code_item) = &encoded_method.code_item {
41 return code_item.insns.clone();
42 }
43 }
44 }
45
46 None
47}