fix bugs
This commit is contained in:
parent
7f46d6c12f
commit
a999338cd0
7 changed files with 139 additions and 1115 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use anyhow::Context;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io::{Cursor, Read};
|
||||
|
|
@ -5,6 +6,7 @@ use std::path::PathBuf;
|
|||
|
||||
use androscalpel::{Apk, Class, IdType};
|
||||
|
||||
use androscalpel::SmaliName;
|
||||
use patcher::{
|
||||
code_loading_patcher::{insert_code, CodePatchingStrategy},
|
||||
labeling,
|
||||
|
|
@ -58,7 +60,21 @@ fn main() {
|
|||
if let Some(class) = apk.get_class_mut(&method.class_) {
|
||||
//println!("{:#?}", class.direct_methods.keys());
|
||||
//println!("{:#?}", class.virtual_methods.keys());
|
||||
let method = class.virtual_methods.get_mut(method).unwrap();
|
||||
let method = if let Some(method) = class.virtual_methods.get_mut(method) {
|
||||
method
|
||||
} else {
|
||||
class
|
||||
.direct_methods
|
||||
.get_mut(method)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"method {} not found in {}",
|
||||
method.try_to_smali().unwrap(),
|
||||
class.descriptor.try_to_smali().unwrap()
|
||||
)
|
||||
})
|
||||
.unwrap()
|
||||
};
|
||||
transform_method(method, &rt_data, test_class.clone(), &mut test_methods).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
@ -95,5 +111,6 @@ fn main() {
|
|||
cli.apksigner,
|
||||
cli.keypassword.as_deref(),
|
||||
None::<HashMap<_, Option<Cursor<&[u8]>>>>,
|
||||
);
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,15 @@ pub fn insert_code(
|
|||
/// For now, we ignore class collision.
|
||||
fn insert_code_naive(apk: &mut Apk, data: &RuntimeData) -> Result<()> {
|
||||
for dyn_data in &data.dyn_code_load {
|
||||
for file in &dyn_data.files {
|
||||
let file = File::open(file)?;
|
||||
apk.add_code(file, crate::labeling, false)?;
|
||||
for file_name in &dyn_data.files {
|
||||
let file = File::open(file_name)?;
|
||||
apk.add_code(file, crate::labeling, false)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Could not add code from {}",
|
||||
file_name.to_str().unwrap_or("<failed to parse file name>")
|
||||
)
|
||||
})?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -60,9 +66,15 @@ fn insert_code_model_class_loaders(apk: &mut Apk, runtime_data: &mut RuntimeData
|
|||
for dyn_data in &runtime_data.dyn_code_load {
|
||||
let mut apk = Apk::new();
|
||||
let class = dyn_data.classloader_class.clone();
|
||||
for file in &dyn_data.files {
|
||||
let file = File::open(file)?;
|
||||
apk.add_code(file, crate::labeling, false)?;
|
||||
for file_name in &dyn_data.files {
|
||||
let file = File::open(file_name)?;
|
||||
apk.add_code(file, crate::labeling, false)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Could not add code from {}",
|
||||
file_name.to_str().unwrap_or("<failed to parse file name>")
|
||||
)
|
||||
})?;
|
||||
}
|
||||
|
||||
assert!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue