From 7fbe1d8a43e585a2111e898e7e18379038b7829f Mon Sep 17 00:00:00 2001 From: Jackson Coxson Date: Sat, 19 Jul 2025 11:43:57 -0600 Subject: [PATCH] Add list_processes --- .../src/services/core_device/app_service.rs | 31 +++++++++++++++++++ tools/src/app_service.rs | 4 +++ 2 files changed, 35 insertions(+) diff --git a/idevice/src/services/core_device/app_service.rs b/idevice/src/services/core_device/app_service.rs index c3ddce1..baaaa08 100644 --- a/idevice/src/services/core_device/app_service.rs +++ b/idevice/src/services/core_device/app_service.rs @@ -65,6 +65,14 @@ pub struct ExecutableUrl { pub relative: String, } +#[derive(Deserialize, Clone, Debug)] +pub struct ProcessToken { + #[serde(rename = "processIdentifier")] + pub pid: u32, + #[serde(rename = "executableURL")] + pub executable_url: Option, +} + impl AppServiceClient { pub async fn new(stream: R) -> Result { Ok(Self { @@ -166,4 +174,27 @@ impl AppServiceClient { Ok(res) } + + pub async fn list_processes(&mut self) -> Result, IdeviceError> { + let res = self + .inner + .invoke("com.apple.coredevice.feature.listprocesses", None) + .await?; + + println!("{}", pretty_print_plist(&res)); + + let res = match res + .as_dictionary() + .and_then(|x| x.get("processTokens")) + .and_then(|x| plist::from_value(x).unwrap()) + { + Some(r) => r, + None => { + warn!("CoreDevice res did not contain parsable processToken"); + return Err(IdeviceError::UnexpectedResponse); + } + }; + + Ok(res) + } } diff --git a/tools/src/app_service.rs b/tools/src/app_service.rs index 0d24210..45d0955 100644 --- a/tools/src/app_service.rs +++ b/tools/src/app_service.rs @@ -57,6 +57,7 @@ async fn main() { .help("The bundle ID to launch"), ), ) + .subcommand(Command::new("processes").about("List the processes running")) .get_matches(); if matches.get_flag("about") { @@ -121,6 +122,9 @@ async fn main() { .expect("no launch"); println!("{res:#?}"); + } else if matches.subcommand_matches("processes").is_some() { + let p = asc.list_processes().await.expect("no processes?"); + println!("{p:#?}"); } else { eprintln!("Invalid usage, pass -h for help"); }