move dump cfg to androscalpel example

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2025-10-06 23:51:27 +02:00
parent 71d5afd3c8
commit 30ae4b064f
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2

View file

@ -1,31 +0,0 @@
use std::fs::File;
use std::path::PathBuf;
use androscalpel::{Apk, IdMethod, MethodCFG};
use clap::Parser;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None, arg_required_else_help = true)]
struct Cli {
#[arg(short, long)]
apk: PathBuf,
#[arg(short, long)]
method: String,
}
/// Usefull for debugging.
fn main() {
env_logger::init();
let cli = Cli::parse();
let mut apk = Apk::load_apk(File::open(&cli.apk).unwrap(), |_, _, _| None, false).unwrap();
let mid = IdMethod::from_smali(&cli.method).unwrap();
let class = apk.get_class_mut(&mid.class_).unwrap();
let method = if let Some(method) = class.virtual_methods.get(&mid) {
method
} else {
class.direct_methods.get(&mid).unwrap()
};
let cfg = MethodCFG::new(method).unwrap();
print!("{}", cfg.to_dot(true));
}