tihmstar / img4tool

A tool for manipulating IMG4, IM4M and IM4P files
GNU Lesser General Public License v3.0
270 stars 105 forks source link

img4tool doesn't properly handle the kernel when converting back to im4p from raw #28

Closed Cryptiiiic closed 4 years ago

Cryptiiiic commented 5 years ago

img4tool version: 0.162-d514ce57f4a104aebe4ba8c20cd7c45f33cf3a68

I run these two im4tool commands. ~/Downloads/img4tool -c kern.im4p -t rkrn -d KernelCacheBuilder-1469.260.15 kern.patched ~/Downloads/img4tool -c kern.img4 -s blob.shsh2 -p kern.im4p And then boot the kern img4. (Yes it boots fine for a compressed kernel) (I have a DEVELOPMENT iBEC so it prints the error)

iRecovery> bootx USB command: "bootx" Attempting to validate kernelcache @ 0x800000000 Unable to validate kernelcache payload error booting kernelcache -4 iRecovery>

In theory it should work but it doesn't. I'm not entirely sure what's causing this. The iBEC does have uncompressed kernel support. It fails on the validating macho probably. But it should be valid since 0x0 of kern.patched = bswap(0xFEEDFACF).

tihmstar commented 4 years ago

From my understanding iBoot does not support uncompressed kernels. One of the reasons compression is desireable is USB transfer times. Compressing kernels (and other files) is a planned feature

Cryptiiiic commented 4 years ago

@tihmstar I looked in iBEC and it had uncompressed kernel handling. But it was checking for a different macho magic than usual. I changed the kernel's to it but it still didn't work, there probably other specific header checks. Probably apple custom built kernel to be loaded uncompressed from iBoot.

tihmstar commented 4 years ago

should be fixed now in version 174 d91d5e8404c9a2c9b255e5a917cf81ee5e3ca578