diff --git a/examples/core/list_exports/README.md b/examples/core/list_exports/README.md index 49efcdc..342f5ca 100644 --- a/examples/core/list_exports/README.md +++ b/examples/core/list_exports/README.md @@ -4,15 +4,14 @@ Once ran you should expect an output similar to the next one: ``` [*] Frida version: 16.4.8 [*] Device name: Local System -[*] Attached to PID 7581 - Log(MessageLog { level: Info, payload: "Logging message from JS" }) - Log(MessageLog { level: Warning, payload: "Warning message from JS" }) - Log(MessageLog { level: Debug, payload: "Debug message from JS" }) - Log(MessageLog { level: Error, payload: "Error message from JS" }) [*] Script loaded. -Some(["increment", "getvalue"]) -Some(["increment", "getvalue"]) -Some(["increment", "getvalue"]) +["increment", "getvalue"] +["increment", "getvalue"] +["increment", "getvalue"] [*] Script unloaded [*] Session detached Exiting... diff --git a/examples/core/list_exports/src/main.rs b/examples/core/list_exports/src/main.rs index 6b4ee0e..68d300f 100644 --- a/examples/core/list_exports/src/main.rs +++ b/examples/core/list_exports/src/main.rs @@ -7,37 +7,21 @@ lazy_static! { } fn main() { - let args: Vec = std::env::args().collect(); - - if args.len() < 2 { - println!("Usage: {} ", args[0]); - return; - } - let device_manager = frida::DeviceManager::obtain(&FRIDA); - let local_device = device_manager.get_device_by_type(frida::DeviceType::Local); - let pid: u32 = args[1].parse().unwrap(); + let local_device = device_manager.get_local_device(); if let Ok(device) = local_device { println!("[*] Frida version: {}", frida::Frida::version()); println!("[*] Device name: {}", device.get_name()); // Attach to the program - let session = match device.attach(pid) { - Ok(s) => s, - Err(_) => { - println!("Error attaching to process {}", pid); - return; - } - }; + let session = device.attach(0).unwrap(); if session.is_detached() { println!("Session is detached"); return; } - println!("[*] Attached to PID {}", pid); - let script_source = r#" var globalVar = 0; console.log("Logging message from JS"); diff --git a/frida/src/script.rs b/frida/src/script.rs index 249b412..d163087 100644 --- a/frida/src/script.rs +++ b/frida/src/script.rs @@ -246,7 +246,7 @@ impl<'a> Script<'a> { } /// List all the exported attributes from the script's rpc - pub fn list_exports(&mut self) -> Result>> { + pub fn list_exports(&mut self) -> Result> { let json_req = { let name = "frida:rpc".into(); let id = self.inc_id().into(); @@ -263,7 +263,7 @@ impl<'a> Script<'a> { let (_, rx) = &self.callback_handler.channel; let rpc_result = rx.recv().unwrap(); - let func_list: Option> = match rpc_result { + let func_list: Vec = match rpc_result { Message::Send(r) => { let tmp_list: Vec = r .payload @@ -274,13 +274,9 @@ impl<'a> Script<'a> { .map(|i| i.as_str().unwrap_or("").to_string()) .collect(); - if !tmp_list.is_empty() { - Some(tmp_list) - } else { - None - } + tmp_list } - _ => None, + _ => Vec::new(), }; Ok(func_list)