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) — Enablesbinrw’sstdfeature. See its documentation for more. Disabling this feature will make this crateno_std-compatible, while still requiringalloc.hash— Provide theHeaderV0::compute_hash_digesthelper
§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§
Structs§
- Header
V0 - Standard Android boot image header versions 0, 1 and 2
- Header
V3 - Standard Android boot image header versions 3 and 4
- OsPatch
- OS patch level
- OsVersion
- OS version
- OsVersion
Patch - OS version and patch level
- Vendor
Header - Android vendor boot image header version 3 and 4
- Vendor
Header V4 - V4-specific fields of the Android vendor boot image header
Enums§
- Either
Header - Either variants of Android boot image header.
- Header
- Standard Android boot image header for versions 0 through 4
- Header
V0Versioned - Version-specific part of boot image headers v0-v2