[Android Software/Hacking General [Developers Only]] Modding.MyMind:
MKBOOTIMG-TOOLS

MY GITHUB SOURCE:

https://github.com/ModdingMyMind/mkbootimg_tools​

Original Author: xiaolu (GITHUB SOURCE: https://github.com/xiaolu/mkbootimg_tools)

Heavily Modified By:

Modding.MyMind

This project is originally based from xiaolu. To make this compatible for ARM I modified the script, compiled some binaries such as file, bash, grep, gzip, lzma, xz, mkbootimg, etc.

-- This project uses busybox but due to how stripped and limited busybox is it ultimately led to me having to compile a few binaries from source. These binaries must be part of the project in order for the project to be successful. For example, busybox grep will not always give accurate offsets for the android header. One of MANY bugs found with busybox.

This project supports device tree binaries found inside the Boot.img and Recovery.img.

This project supports multiple Ramdisk compressions.

-- This project will check the ramdisk compression and if it determines that the tool does not support that particular compression then it will display a hazard warning letting the user know that the compression is not supported and that the ramdisk currently cannot be decompressed or compressed until support has been officially added.

-- If the compression is supported it will display what type of compression the Ramdisk is and how many blocks it has when unpacked.

This project will determine your kernel size, ramdisk size, and TRUE OFFSETS (not just the standard mkbootimg.c offsets).

-- With respect to the offsets; You will learn that many available tools found available specifically handle images where the ANDROID! header is located at 0x0. Not all images are built like this from stock. This project will find the header, base, kernel offset, ramdisk offset, second offset, and tags offset. It will rebuild the image using DD to insure the android header is located at 0x0. The found offsets inside the image will be cross referenced to see if the OEM of that image built it using the standard mkbootimg.c. If it detects any offsets which are built using NON-standard offsets then it will display a warning as well as show you what the image TRUE offsets actually are. Those same offsets are then applied to properly rebuild your image to insure that it boots like it was intended to do.

-- The warning will let you know that you may modify mkbootimg.c with the NON-standard values if you wish to have a binary specific to your device. The offsets displayed are not the address. Because the offsets are determined and not the address this makes it possible for this project to not have to rebuild mkbootimg.c. When the project is used to rebuild your image using the mkbootimg args such as --ramdisk_offset, --kernel_offsets, etc, etc, this then tells mkbootimg.c to ignore the hardcoded offsets and only use the ones it has been instructed to use. This is even more successful by insuring the BASE is accurate and applying the base as one of the mkbootimg args (--base 0 <-- this is lazy and stupid).

The mkboot script requires two args whether unpacking the image or repacking the image.

-- mkboot boot.img bootfolder (This will unpack the image)

1. mkboot is the script.

2. boot.img is the actual image.

3. bootfolder will be created and become the project folder.

-- mkboot bootfolder newboot.img (This will repack the image)

1. mkboot is the script.

2. bootfolder is the project folder which has the needed files and information to repack.

3. This will be the name of the finished build.

UNPACK STANDARD IMAGE​

This image uses standard mkbootimg.c:

REPACK STANDARD IMAGE​

Image repacked with standard mkbootimg.c:

UNPACK NON-STANDARD IMAGE​

This image uses non-standard mkbootimg.c:

REPACK NON-STANDARD IMAGE​

Image repacked with non-standard mkbootimg.c:

UNPACK IMAGE WITH INCOMPATIBLE RAMDISK​

REPACK IMAGE WITH INCOMPATIBLE RAMDISK​