Skip to main content

Crate abootimg_oxide

Crate abootimg_oxide 

Source
Expand description

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.

Header denotes the standard boot.img boot image’s header with the file signature ANDROID!. VendorHeader denotes the vendor_boot.img vendor boot image’s header with the file signature VNDRBOOT.

§Examples

use std::fs::File;
use abootimg_oxide::{binrw::io::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().into()), w.get_mut()).unwrap();

§Features

  • std (enabled by default) — Enables binrw’s std feature. See its documentation for more. Disabling this feature will make this crate no_std-compatible, while still requiring alloc.
  • hash — Provide the HeaderV0::compute_hash_digest helper

§Note about Seek requirement

binrw requires the Seek trait to be implemented on readers and writers.

Only the read portion of Header seeks. For other functionality, you can use the binrw::io::NoSeek adapter to be able to read and write to and from unseekable streams.

Re-exports§

pub use binrw::io::BufReader;std
pub use binrw;

Structs§

HeaderV0
Standard Android boot image header versions 0, 1 and 2
HeaderV3
Standard Android boot image header versions 3 and 4
OsPatch
OS patch level
OsVersion
OS version
OsVersionPatch
OS version and patch level
VendorHeader
Android vendor boot image header version 3 and 4
VendorHeaderV4
V4-specific fields of the Android vendor boot image header

Enums§

EitherHeader
Either variants of Android boot image header.
Header
Standard Android boot image header for versions 0 through 4
HeaderV0Versioned
Version-specific part of boot image headers v0-v2