check classloader string representation

This commit is contained in:
Jean-Marie Mineau 2025-04-25 16:56:46 +02:00
parent 566b423c6b
commit 59d6caabd8
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
5 changed files with 194 additions and 14 deletions

View file

@ -12,6 +12,8 @@ pub struct RuntimeData {
pub dyn_code_load: Vec<DynamicCodeLoadingData>,
/// The id of the class loader of the apk (the main classloader)
pub apk_cl_id: Option<String>,
/// Additionnal classloader data.
pub classloaders: Vec<ClassLoaderData>,
}
impl RuntimeData {
@ -87,6 +89,14 @@ impl RuntimeData {
}
data
}
/// Get classloader data, indexed by id.
pub fn get_classloader_data(&self) -> HashMap<String, ClassLoaderData> {
self.classloaders
.iter()
.map(|data| (data.id.clone(), data.clone()))
.collect()
}
}
/// Structure storing the runtime information of a reflection call using
@ -187,3 +197,18 @@ pub struct DynamicCodeLoadingData {
/// The path to the files storing the .dex/.apk/other bytecode loaded.
pub files: Vec<PathBuf>,
}
/// Structure storing the runtime information of a classloader.
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct ClassLoaderData {
/// Id of the classloader. This value is unique for *one* run of the apk.
pub id: String,
/// The Id of the parent classloader if it exists.
pub parent_id: Option<String>,
/// The string representation of the classloader. Not verry relayable but our best option to
/// distinguish classloader at runtime.
#[serde(rename = "str")]
pub string_representation: String,
/// The class of the class loader.
pub cname: String, // TODO: IdType,
}