4 releases

0.2.0 Dec 18, 2024
0.1.2 Dec 18, 2024
0.1.1 Sep 5, 2024
0.1.0 Sep 5, 2024

#1265 in Parser implementations

Download history 244/week @ 2024-09-02 4/week @ 2024-09-09 9/week @ 2024-09-16 12/week @ 2024-09-23 4/week @ 2024-09-30 14/week @ 2024-11-04 13/week @ 2024-11-18 211/week @ 2024-12-16

212 downloads per month

MIT/Apache

22KB
366 lines

abootimg-oxide

Crates.io Documentation

Android boot image (boot.img) parser written in Rust

Thank you to cfig/Android_boot_image_editor's documentation about the layout of boot images!

TODO: reimplement mkbootimg

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

A parser for Android boot image headers (e.g. boot.img or vendor_boot.img).

This can be used to extract or patch e.g. the kernel or ramdisk.

Byte array fields ([u8; N]) can be used as null-terminated strings.

Examples

use std::fs::File;
use abootimg_oxide::{BufReader, Header};

let mut r = BufReader::new(File::open("boot_a.img").unwrap());
let hdr = Header::parse(&mut r).unwrap();
println!("{hdr:#?}");

// Extract the kernel
use std::io::{self, BufWriter, Read, Seek, SeekFrom};

let mut w = BufWriter::new(File::create("boot_a_kernel").unwrap());
let r = r.get_mut();
r.seek(SeekFrom::Start(hdr.kernel_position() as u64))
    .unwrap();
io::copy(&mut r.take(hdr.kernel_size() as u64), w.get_mut()).unwrap();

Dependencies

~2MB
~44K SLoC