eculocate

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

main.rs (776B)


      1 const PARTITION_BYTES: &[u8] = include_bytes!("../part.bin");
      2 
      3 fn main() {
      4     let chunks = PARTITION_BYTES.chunks(32);
      5     for chunk in chunks {
      6         if chunk == &[0xFF; 32] {
      7             break;
      8         }
      9 
     10         let magic = &chunk[0..2];
     11         if magic != &[0xAA, 0x50] {
     12             continue;
     13         }
     14 
     15         let p_type = &chunk[2];
     16         let p_subtype = &chunk[3];
     17         let p_offset = u32::from_le_bytes(chunk[4..8].try_into().unwrap());
     18         let p_size = u32::from_le_bytes(chunk[8..12].try_into().unwrap());
     19         let p_name = core::str::from_utf8(&chunk[12..28]).unwrap();
     20         let p_flags = u32::from_le_bytes(chunk[28..32].try_into().unwrap());
     21 
     22         println!("{magic:?} {p_type} {p_subtype} {p_offset} {p_size} {p_name} {p_flags}");
     23     }
     24 }