Create Paste
Top Pastes
Recent Pastes
Settings
Account
Untitled Paste
Anonymous
Views
3
Visibility
Private
Expires
Never
Created
November 2022
View Raw
Download
//------------------------------------------------ //--- 010 Editor v13.0 Binary Template // // File: Xiaomi AX9000 firmware // Authors: // Version: 0.1 // Purpose: // Category: // File Mask: // ID Bytes: // History: //------------------------------------------------ /** Use https://github.com/jrspruitt/ubi_reader **/ LittleEndian(); #define BLOB_NUM 8 typedef uint64 uint64_t; typedef uint32 uint32_t; typedef uint16 uint16_t; typedef unsigned char uint8_t; typedef struct { char magic[4]; uint32_t signature_offset; uint32_t crc32; } xiaomi_header; typedef struct { uint16_t unused; uint16_t device_id; uint32_t blob_offsets[BLOB_NUM]; } xiaomi_subheader_v1; typedef struct { uint32_t unused1; uint64_t device_id; /* RA70 */ uint64_t region; /* EU */ uint64_t unused2[2]; uint32_t blob_offsets[BLOB_NUM]; } xiaomi_subheader_v2; typedef struct { uint32_t magic; uint32_t flash_offset; uint32_t size; uint16_t type; uint16_t unused; char name[32]; uint8_t data[size]; } xiaomi_blob_header; typedef struct { uint32_t size; uint32_t padding[3]; uint8_t content[size]; /* 256 */ } xiaomi_signature_header; xiaomi_header hdr; if (Strncmp(hdr.magic, "HDR1", sizeof(hdr.magic)) == 0) { Printf("Found HDR1 image\n"); xiaomi_subheader_v1 subheader; } else if (Strncmp(hdr.magic, "HDR2", sizeof(hdr.magic)) == 0) { Printf("Found HDR2 image\n"); xiaomi_subheader_v2 subheader; } else { Printf("Found unsupported image\n"); Exit(1); } local uint64_t curr = FTell(); FSeek(hdr.signature_offset); xiaomi_signature_header sig; FSeek(curr); local uint32_t i; for (i = 0; i < BLOB_NUM; i++) { if (subheader.blob_offsets[i] == 0) { continue; } FSeek(subheader.blob_offsets[i]); xiaomi_blob_header blob; }