Skip to content
Snippets Groups Projects
Commit 213ce4a5 authored by marilop's avatar marilop
Browse files

Delete elfheader.rs

parent 08e179dc
No related branches found
No related tags found
No related merge requests found
fn section_header_table( buff: Vec::<u8> ){
println!("Description of Section Header Table");
let mut m1: Vec<u8> = buff[0x28..0x2c].to_vec();
m1.reverse();
println!("Starts at: {:02x?}{:02x?}{:02x?}{:02x?}", m1[0], m1[1], m1[2], m1[3]);
println!("Size: {}",&buff[0x3a]);
println!("Number of sections: {}",&buff[0x3c])
}
/*
*
* Source https://stackoverflow.com/questions/38161695/how-can-i-optimize-reading-a-utf-8-string-from-a-file-with-a-known-offset-and-si
*
*
*
*/
fn test(file: &mut File, offset: u64, length: usize) -> Result<String, String> {
try!(file.seek(SeekFrom::Start(offset)).map_err(|err| err.to_string()));
let mut res = String::new();//or you can use ::with_capacity(length);
try!(file.take(length as u64)
.read_to_string(&mut res)
.map_err(|err| err.to_string())
.and_then(|x| if x!=length {Err("wrong num bytes".to_string())}else{Ok(x)})
);
Result::Ok(res)
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment