androscalpel/androscalpel/examples/map_layout.rs

36 lines
956 B
Rust

use std::path::PathBuf;
use androscalpel::Apk;
use clap::Parser;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None, arg_required_else_help = true)]
struct Cli {
#[arg(short, long)]
dex: PathBuf,
}
fn main() {
if cfg!(not(feature = "map_dex_file")) {
panic!("This program must be compiled with the map_dex_file feature: `cargo run --example map_layout --features map_dex_file`");
}
env_logger::init();
let cli = Cli::parse();
let mut apk = Apk::new();
let data = std::fs::read(&cli.dex).unwrap();
apk.add_dex_file(
&cli.dex.into_os_string().into_string().unwrap(),
&data,
|_, _, _| None,
true,
)
.unwrap();
//load_apk(File::open(&cli.apk).unwrap(), |_, _, _| None, false).unwrap();
for (_name, dex) in &apk.dex_files {
//println!("{name}:");
#[cfg(feature = "map_dex_file")]
println!("{}", dex.html_layout())
}
}