diff --git a/patcher/Cargo.lock b/patcher/Cargo.lock index cb7e63f..461f177 100644 --- a/patcher/Cargo.lock +++ b/patcher/Cargo.lock @@ -35,9 +35,10 @@ dependencies = [ [[package]] name = "androscalpel" version = "0.1.0" -source = "git+ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git?rev=3cc02a3#3cc02a32925db36b3398224a7604fcaa37ddc4d2" +source = "git+ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git?rev=1f2de8b#1f2de8b60daf3c2beba1193174e537175f939e4a" dependencies = [ "adler", + "androscalpel_platform_api_list", "androscalpel_serializer", "anyhow", "apk_frauder", @@ -48,10 +49,15 @@ dependencies = [ "sha1", ] +[[package]] +name = "androscalpel_platform_api_list" +version = "0.1.0" +source = "git+ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git?rev=1f2de8b#1f2de8b60daf3c2beba1193174e537175f939e4a" + [[package]] name = "androscalpel_serializer" version = "0.1.0" -source = "git+ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git?rev=3cc02a3#3cc02a32925db36b3398224a7604fcaa37ddc4d2" +source = "git+ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git?rev=1f2de8b#1f2de8b60daf3c2beba1193174e537175f939e4a" dependencies = [ "androscalpel_serializer_derive", "log", @@ -60,7 +66,7 @@ dependencies = [ [[package]] name = "androscalpel_serializer_derive" version = "0.1.0" -source = "git+ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git?rev=3cc02a3#3cc02a32925db36b3398224a7604fcaa37ddc4d2" +source = "git+ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git?rev=1f2de8b#1f2de8b60daf3c2beba1193174e537175f939e4a" dependencies = [ "proc-macro2", "quote", @@ -129,7 +135,7 @@ dependencies = [ [[package]] name = "apk_frauder" version = "0.1.0" -source = "git+ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git?rev=3cc02a3#3cc02a32925db36b3398224a7604fcaa37ddc4d2" +source = "git+ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git?rev=1f2de8b#1f2de8b60daf3c2beba1193174e537175f939e4a" dependencies = [ "androscalpel_serializer", "anyhow", diff --git a/patcher/Cargo.toml b/patcher/Cargo.toml index 02b2c0a..88c30e7 100644 --- a/patcher/Cargo.toml +++ b/patcher/Cargo.toml @@ -6,8 +6,8 @@ edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -androscalpel = { git = "ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "3cc02a3", features = ["code-analysis"] } -apk_frauder = { git = "ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "3cc02a3"} +androscalpel = { git = "ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "1f2de8b", features = ["code-analysis"] } +apk_frauder = { git = "ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "1f2de8b"} #androscalpel = { path = "../../androscalpel/androscalpel", features = ["code-analysis"] } #apk_frauder = { path = "../../androscalpel/apk_frauder"} anyhow = { version = "1.0.95", features = ["backtrace"] } diff --git a/patcher/src/code_loading_patcher.rs b/patcher/src/code_loading_patcher.rs index 9cc5471..7a52343 100644 --- a/patcher/src/code_loading_patcher.rs +++ b/patcher/src/code_loading_patcher.rs @@ -249,6 +249,8 @@ impl ClassLoader<'_> { } } + /// Rename the definition of `cls` in the class loader. + /// pub fn rename_classdef(&mut self, cls: &IdType) -> Result<()> { let id = self.id.clone(); let mut i = 0; @@ -310,12 +312,22 @@ impl ClassLoader<'_> { r } + /// Return the new name of a type after class renaming. + /// This method select the right renamed type by modeling the behavior of + /// the android SDK class loaders. + /// If the class loader is not a class loader from the android SDK, default + /// to the behavior of DexClassLoader: Platform classes have precedence over + /// classes defined by a parent classloader that have precedence over classes + /// defined by the classloader itself. pub fn get_ref_new_name( &self, ty: &IdType, class_loaders: &HashMap, ) -> Option { - // TODO: Check Platform Classes + if ty.is_platform_class() { + // Platform classes have precedence for all android SDK classloader. + return Some(ty); + } if self.class == *DELEGATE_LAST_CLASS_LOADER { if let Some(new_ty) = self.renamed_classes.get(ty) { return Some(new_ty.clone());