diff --git a/native/jni/magiskboot/bootimg.cpp b/native/jni/magiskboot/bootimg.cpp index cf1a93ee7..7a1047f55 100644 --- a/native/jni/magiskboot/bootimg.cpp +++ b/native/jni/magiskboot/bootimg.cpp @@ -294,7 +294,7 @@ void boot_img::parse_image(uint8_t *addr, format_t type) { hdr->print(); - size_t off = hdr->page_size(); + size_t off = hdr->hdr_space(); hdr_addr = addr; get_block(kernel); get_block(ramdisk); @@ -474,9 +474,9 @@ void repack(const char* src_img, const char* out_img, bool skip_comp) { restore_buf(fd, boot.map_addr, ACCLAIM_PRE_HEADER_SZ); } - // Copy a page for header + // Copy header off.header = lseek(fd, 0, SEEK_CUR); - restore_buf(fd, boot.hdr_addr, boot.hdr->page_size()); + restore_buf(fd, boot.hdr_addr, boot.hdr->hdr_space()); // kernel off.kernel = lseek(fd, 0, SEEK_CUR); diff --git a/native/jni/magiskboot/bootimg.hpp b/native/jni/magiskboot/bootimg.hpp index 6b35eb70f..9be673b33 100644 --- a/native/jni/magiskboot/bootimg.hpp +++ b/native/jni/magiskboot/bootimg.hpp @@ -243,6 +243,7 @@ struct dyn_img_hdr { } virtual size_t hdr_size() = 0; + virtual size_t hdr_space() { return page_size(); } const void *raw_hdr() const { return raw; } void print(); @@ -367,6 +368,8 @@ struct dyn_img_vnd_v3 : public dyn_img_hdr { impl_val(header_size) impl_val(dtb_size) + size_t hdr_space() override { auto sz = page_size(); return do_align(hdr_size(), sz); } + // Make API compatible char *extra_cmdline() override { return &vnd->cmdline[BOOT_ARGS_SIZE]; } };