-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added get_device_by_id to the device_manager and example (#117)
* Add get_device_by_id to the device_manager and example * fixed typo in rust doc that caused doc test to fail * Fixed format with rust fmt * fixed unnecessary cast --------- Co-authored-by: Andras <[email protected]>
- Loading branch information
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "usb_device" | ||
version = "0.1.0" | ||
authors = ["Andras Marczell <[email protected]>"] | ||
edition = "2018" | ||
license = "wxWindows" | ||
publish = false | ||
|
||
[dependencies] | ||
frida = { path = "../../../frida" } | ||
frida-sys = { path = "../../../frida-sys" } | ||
lazy_static = "1.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use frida::DeviceType; | ||
|
||
fn main() { | ||
let frida = unsafe { frida::Frida::obtain() }; | ||
let device_manager = frida::DeviceManager::obtain(&frida); | ||
|
||
// get the first usb device (assuming there is one attached) | ||
let device = device_manager.get_device_by_type(DeviceType::USB).unwrap(); | ||
assert_eq!(device.get_type(), DeviceType::USB); | ||
println!( | ||
"found {} with type: {}", | ||
device.get_name(), | ||
device.get_type() | ||
); | ||
|
||
// get the device id and use it to obtain a the device by the id | ||
let device_id = device.get_id(); | ||
let device = device_manager.get_device_by_id(device_id).unwrap(); | ||
assert_eq!(device.get_id(), device_id); | ||
println!("found {} with id: {}", device.get_name(), device.get_id()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters