rename duplicate classes
This commit is contained in:
parent
5c91adfe93
commit
b7c7282f1b
3 changed files with 29 additions and 11 deletions
8
patcher/Cargo.lock
generated
8
patcher/Cargo.lock
generated
|
|
@ -35,7 +35,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "androscalpel"
|
name = "androscalpel"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=5379c29#5379c29eb881bb2fbed9703206f01f4a9ec73ca3"
|
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=c0152e7#c0152e76089b7a51ce28e19c1828cdbdd435271a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler",
|
"adler",
|
||||||
"androscalpel_serializer",
|
"androscalpel_serializer",
|
||||||
|
|
@ -51,7 +51,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "androscalpel_serializer"
|
name = "androscalpel_serializer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=5379c29#5379c29eb881bb2fbed9703206f01f4a9ec73ca3"
|
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=c0152e7#c0152e76089b7a51ce28e19c1828cdbdd435271a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"androscalpel_serializer_derive",
|
"androscalpel_serializer_derive",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -60,7 +60,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "androscalpel_serializer_derive"
|
name = "androscalpel_serializer_derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=5379c29#5379c29eb881bb2fbed9703206f01f4a9ec73ca3"
|
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=c0152e7#c0152e76089b7a51ce28e19c1828cdbdd435271a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
@ -129,7 +129,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "apk_frauder"
|
name = "apk_frauder"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=5379c29#5379c29eb881bb2fbed9703206f01f4a9ec73ca3"
|
source = "git+ssh://git@git.mineau.eu/histausse/androscalpel.git?rev=c0152e7#c0152e76089b7a51ce28e19c1828cdbdd435271a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"androscalpel_serializer",
|
"androscalpel_serializer",
|
||||||
"flate2",
|
"flate2",
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
androscalpel = { git = "ssh://git@git.mineau.eu/histausse/androscalpel.git", rev = "5379c29", features = ["code-analysis"] }
|
androscalpel = { git = "ssh://git@git.mineau.eu/histausse/androscalpel.git", rev = "c0152e7", features = ["code-analysis"] }
|
||||||
apk_frauder = { git = "ssh://git@git.mineau.eu/histausse/androscalpel.git", rev = "5379c29"}
|
apk_frauder = { git = "ssh://git@git.mineau.eu/histausse/androscalpel.git", rev = "c0152e7"}
|
||||||
anyhow = { version = "1.0.95", features = ["backtrace"] }
|
anyhow = { version = "1.0.95", features = ["backtrace"] }
|
||||||
clap = { version = "4.5.27", features = ["derive"] }
|
clap = { version = "4.5.27", features = ["derive"] }
|
||||||
env_logger = "0.11.6"
|
env_logger = "0.11.6"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
use androscalpel::{Apk, DexString, IdType, VisitableMut, VisitorMut};
|
use androscalpel::{Apk, DexString, IdType, VisitorMut};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use clap::ValueEnum;
|
use clap::ValueEnum;
|
||||||
|
|
||||||
|
|
@ -70,17 +70,30 @@ fn insert_code_model_class_loaders(apk: &mut Apk, data: &RuntimeData) -> Result<
|
||||||
};
|
};
|
||||||
let collisions = class_defined.intersection(&classes);
|
let collisions = class_defined.intersection(&classes);
|
||||||
for cls in collisions {
|
for cls in collisions {
|
||||||
class_loader.rename_classdef(cls);
|
class_loader.rename_classdef(cls)?;
|
||||||
}
|
}
|
||||||
class_defined.extend(classes);
|
class_defined.extend(classes);
|
||||||
|
|
||||||
class_loaders.insert(dyn_data.classloader.clone(), class_loader);
|
class_loaders.insert(dyn_data.classloader.clone(), class_loader);
|
||||||
}
|
}
|
||||||
// TODO: rename colliding classes according to class laoder
|
|
||||||
// TODO: get the ClassLoader::parent values...
|
// TODO: get the ClassLoader::parent values...
|
||||||
// TODO: model the delegation behavior and rename ref to class accordingly
|
// TODO: model the delegation behavior and rename ref to class accordingly
|
||||||
// TODO: update Runtime Data to reflect the name change
|
// TODO: update Runtime Data to reflect the name change
|
||||||
todo!()
|
|
||||||
|
let apk = if let ApkOrRef::Ref(apk) = class_loaders.remove("MAIN").unwrap().apk {
|
||||||
|
apk
|
||||||
|
} else {
|
||||||
|
panic!("Main APK is not stored as ref?")
|
||||||
|
};
|
||||||
|
for (_, ClassLoader { apk: other, .. }) in class_loaders.into_iter() {
|
||||||
|
if let ApkOrRef::Owned(other) = other {
|
||||||
|
apk.merge(other);
|
||||||
|
} else {
|
||||||
|
panic!("Secondary APK is not stored as owned?")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//todo!()
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structure modelizing a class loader.
|
/// Structure modelizing a class loader.
|
||||||
|
|
@ -129,13 +142,18 @@ impl ClassLoader<'_> {
|
||||||
new_name.try_to_smali().unwrap(),
|
new_name.try_to_smali().unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let class = self.apk().remove_class(cls, None).with_context(|| {
|
let class = self.apk().remove_class(cls, None)?.with_context(|| {
|
||||||
format!(
|
format!(
|
||||||
"Try to rename classdef of {} in class loader {}, but classdef not found",
|
"Try to rename classdef of {} in class loader {}, but classdef not found",
|
||||||
cls.__str__(),
|
cls.__str__(),
|
||||||
&id
|
&id
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
let class = RenameTypeVisitor {
|
||||||
|
new_names: [(cls.clone(), new_name.clone())].into(),
|
||||||
|
}
|
||||||
|
.visit_class(class)?;
|
||||||
|
self.apk().add_class("classes.dex", class)?;
|
||||||
|
|
||||||
self.renamed_classes.insert(cls.clone(), new_name);
|
self.renamed_classes.insert(cls.clone(), new_name);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue