diff --git a/native/src/boot/bootimg.cpp b/native/src/boot/bootimg.cpp index a6f88c615..bb6076768 100644 --- a/native/src/boot/bootimg.cpp +++ b/native/src/boot/bootimg.cpp @@ -520,12 +520,12 @@ bool boot_img::verify(const char *cert) const { return rust::verify_boot_image(*this, cert); } -int split_image_dtb(const char *filename) { +int split_image_dtb(const char *filename, bool skip_decomp) { mmap_data img(filename); if (int off = find_dtb_offset(img.buf(), img.sz()); off > 0) { format_t fmt = check_fmt_lg(img.buf(), img.sz()); - if (COMPRESSED(fmt)) { + if (!skip_decomp && COMPRESSED(fmt)) { int fd = creat(KERNEL_FILE, 0644); decompress(fmt, fd, img.buf(), off); close(fd); diff --git a/native/src/boot/magiskboot.hpp b/native/src/boot/magiskboot.hpp index fbc06c40f..8712428ed 100644 --- a/native/src/boot/magiskboot.hpp +++ b/native/src/boot/magiskboot.hpp @@ -18,7 +18,7 @@ int unpack(const char *image, bool skip_decomp = false, bool hdr = false); void repack(const char *src_img, const char *out_img, bool skip_comp = false); int verify(const char *image, const char *cert); int sign(const char *image, const char *name, const char *cert, const char *key); -int split_image_dtb(const char *filename); +int split_image_dtb(const char *filename, bool skip_decomp = false); int dtb_commands(int argc, char *argv[]); static inline bool check_env(const char *name) { diff --git a/native/src/boot/main.cpp b/native/src/boot/main.cpp index 81ffdd97b..9ac263e44 100644 --- a/native/src/boot/main.cpp +++ b/native/src/boot/main.cpp @@ -84,8 +84,10 @@ Supported actions: Do dtb related actions to . See "dtb --help" for supported actions. - split - Split image.*-dtb into kernel + kernel_dtb + split [-n] + Split image.*-dtb into kernel + kernel_dtb. + If '-n' is provided, decompression operations will be skipped; + the kernel will remain untouched, split in its original format. sha1 Print the SHA1 checksum for @@ -150,7 +152,13 @@ int main(int argc, char *argv[]) { printf("%02x", i); printf("\n"); } else if (argc > 2 && action == "split") { - return split_image_dtb(argv[2]); + if (argv[2] == "-n"sv) { + if (argc == 3) + usage(argv[0]); + return split_image_dtb(argv[3], true); + } else { + return split_image_dtb(argv[2]); + } } else if (argc > 2 && action == "unpack") { int idx = 2; bool nodecomp = false;