Skip to content

Commit

Permalink
Add get_remote_device (#133)
Browse files Browse the repository at this point in the history
* Add get_remote_device

* Refactor error management style in get_remote_device

* Fix lint checker
  • Loading branch information
SajjadPourali authored Jul 11, 2024
1 parent 818a23c commit f2487bc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions frida/src/device_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,28 @@ impl<'a> DeviceManager<'a> {
return Ok(Device::from_raw(device_ptr));
}

/// Returns the remote device with the specified host.
pub fn get_remote_device(&'a self, host: &str) -> Result<Device<'a>> {
let mut error: *mut frida_sys::GError = std::ptr::null_mut();
let host_cstring = CString::new(host).map_err(|_| Error::CStringFailed)?;

let device_ptr = unsafe {
frida_sys::frida_device_manager_add_remote_device_sync(
self.manager_ptr,
host_cstring.as_ptr(),
std::ptr::null_mut(),
std::ptr::null_mut(),
&mut error,
)
};

if !error.is_null() {
return Err(Error::DeviceLookupFailed);
}

return Ok(Device::from_raw(device_ptr));
}

/// Returns the device with the specified id.
///
/// # Example
Expand Down

0 comments on commit f2487bc

Please sign in to comment.