diff --git a/native/jni/magiskboot/bootimg.cpp b/native/jni/magiskboot/bootimg.cpp index 8f5bbb197..3a2e66b4f 100644 --- a/native/jni/magiskboot/bootimg.cpp +++ b/native/jni/magiskboot/bootimg.cpp @@ -440,6 +440,10 @@ void repack(const char* orig_image, const char* out_image) { // Print new image info boot.print_hdr(); + // Try to fix the header + if (boot.header_version() && boot.header_size() == 0) + boot.header_size(sizeof(boot_img_hdr)); + // Main header memcpy(boot.map_addr + header_off, boot.hdr, boot.hdr_size()); diff --git a/native/jni/magiskboot/bootimg.h b/native/jni/magiskboot/bootimg.h index d150160db..093d911ae 100644 --- a/native/jni/magiskboot/bootimg.h +++ b/native/jni/magiskboot/bootimg.h @@ -207,6 +207,8 @@ static_cast(hdr)->x) hdr_set(recovery_dtbo_size, uint32_t); hdr_get(recovery_dtbo_offset, uint32_t); hdr_set(recovery_dtbo_offset, uint32_t); + hdr_get(header_size, uint32_t); + hdr_set(header_size, uint32_t); uint32_t header_version() { if (IS_PXA)