diff options
Diffstat (limited to 'third_party/rust/goblin/examples/rdr.rs')
-rw-r--r-- | third_party/rust/goblin/examples/rdr.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/third_party/rust/goblin/examples/rdr.rs b/third_party/rust/goblin/examples/rdr.rs new file mode 100644 index 0000000000..b5aaefe2c0 --- /dev/null +++ b/third_party/rust/goblin/examples/rdr.rs @@ -0,0 +1,25 @@ +use goblin::error; +use std::path::Path; +use std::env; +use std::fs::File; +use std::io::Read; + +fn run () -> error::Result<()> { + for (i, arg) in env::args().enumerate() { + if i == 1 { + let path = Path::new(arg.as_str()); + let mut fd = File::open(path)?; + let buffer = { let mut v = Vec::new(); fd.read_to_end(&mut v).unwrap(); v}; + let res = goblin::Object::parse(&buffer)?; + println!("{:#?}", res); + } + } + Ok(()) +} + +pub fn main () { + match run() { + Ok(()) => (), + Err(err) => println!("{:#}", err) + } +} |