don't rename platform classes

This commit is contained in:
Jean-Marie Mineau 2025-04-22 16:28:12 +02:00
parent a999338cd0
commit 09448752c0
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
3 changed files with 25 additions and 7 deletions

14
patcher/Cargo.lock generated
View file

@ -35,9 +35,10 @@ dependencies = [
[[package]] [[package]]
name = "androscalpel" name = "androscalpel"
version = "0.1.0" 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 = [ dependencies = [
"adler", "adler",
"androscalpel_platform_api_list",
"androscalpel_serializer", "androscalpel_serializer",
"anyhow", "anyhow",
"apk_frauder", "apk_frauder",
@ -48,10 +49,15 @@ dependencies = [
"sha1", "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]] [[package]]
name = "androscalpel_serializer" name = "androscalpel_serializer"
version = "0.1.0" 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 = [ dependencies = [
"androscalpel_serializer_derive", "androscalpel_serializer_derive",
"log", "log",
@ -60,7 +66,7 @@ dependencies = [
[[package]] [[package]]
name = "androscalpel_serializer_derive" name = "androscalpel_serializer_derive"
version = "0.1.0" 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 = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -129,7 +135,7 @@ dependencies = [
[[package]] [[package]]
name = "apk_frauder" name = "apk_frauder"
version = "0.1.0" 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 = [ dependencies = [
"androscalpel_serializer", "androscalpel_serializer",
"anyhow", "anyhow",

View file

@ -6,8 +6,8 @@ edition = "2024"
# 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@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "3cc02a3", features = ["code-analysis"] } 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 = "3cc02a3"} apk_frauder = { git = "ssh://git@gitlab.inria.fr/androidoftheseus/androscalpel.git", rev = "1f2de8b"}
#androscalpel = { path = "../../androscalpel/androscalpel", features = ["code-analysis"] } #androscalpel = { path = "../../androscalpel/androscalpel", features = ["code-analysis"] }
#apk_frauder = { path = "../../androscalpel/apk_frauder"} #apk_frauder = { path = "../../androscalpel/apk_frauder"}
anyhow = { version = "1.0.95", features = ["backtrace"] } anyhow = { version = "1.0.95", features = ["backtrace"] }

View file

@ -249,6 +249,8 @@ impl ClassLoader<'_> {
} }
} }
/// Rename the definition of `cls` in the class loader.
///
pub fn rename_classdef(&mut self, cls: &IdType) -> Result<()> { pub fn rename_classdef(&mut self, cls: &IdType) -> Result<()> {
let id = self.id.clone(); let id = self.id.clone();
let mut i = 0; let mut i = 0;
@ -310,12 +312,22 @@ impl ClassLoader<'_> {
r 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( pub fn get_ref_new_name(
&self, &self,
ty: &IdType, ty: &IdType,
class_loaders: &HashMap<String, Self>, class_loaders: &HashMap<String, Self>,
) -> Option<IdType> { ) -> Option<IdType> {
// 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 self.class == *DELEGATE_LAST_CLASS_LOADER {
if let Some(new_ty) = self.renamed_classes.get(ty) { if let Some(new_ty) = self.renamed_classes.get(ty) {
return Some(new_ty.clone()); return Some(new_ty.clone());