mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Add list_processes
This commit is contained in:
@@ -65,6 +65,14 @@ pub struct ExecutableUrl {
|
|||||||
pub relative: String,
|
pub relative: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Clone, Debug)]
|
||||||
|
pub struct ProcessToken {
|
||||||
|
#[serde(rename = "processIdentifier")]
|
||||||
|
pub pid: u32,
|
||||||
|
#[serde(rename = "executableURL")]
|
||||||
|
pub executable_url: Option<ExecutableUrl>,
|
||||||
|
}
|
||||||
|
|
||||||
impl<R: ReadWrite> AppServiceClient<R> {
|
impl<R: ReadWrite> AppServiceClient<R> {
|
||||||
pub async fn new(stream: R) -> Result<Self, IdeviceError> {
|
pub async fn new(stream: R) -> Result<Self, IdeviceError> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -166,4 +174,27 @@ impl<R: ReadWrite> AppServiceClient<R> {
|
|||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn list_processes(&mut self) -> Result<Vec<ProcessToken>, 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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ async fn main() {
|
|||||||
.help("The bundle ID to launch"),
|
.help("The bundle ID to launch"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.subcommand(Command::new("processes").about("List the processes running"))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
if matches.get_flag("about") {
|
if matches.get_flag("about") {
|
||||||
@@ -121,6 +122,9 @@ async fn main() {
|
|||||||
.expect("no launch");
|
.expect("no launch");
|
||||||
|
|
||||||
println!("{res:#?}");
|
println!("{res:#?}");
|
||||||
|
} else if matches.subcommand_matches("processes").is_some() {
|
||||||
|
let p = asc.list_processes().await.expect("no processes?");
|
||||||
|
println!("{p:#?}");
|
||||||
} else {
|
} else {
|
||||||
eprintln!("Invalid usage, pass -h for help");
|
eprintln!("Invalid usage, pass -h for help");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user