X-Git-Url: https://git.saurik.com/ldid.git/blobdiff_plain/e4b7adc1e02c9f0e16cc9ae2841192b386f6d4ea..d840a088528979cddcf722a2a19abefc0151a1ed:/ldid.cpp?ds=sidebyside diff --git a/ldid.cpp b/ldid.cpp index 7998ede..e1fbda9 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -31,6 +31,8 @@ extern "C" { #include #include +#include + struct fat_header { uint32_t magic; uint32_t nfat_arch; @@ -1092,9 +1094,11 @@ int main(int argc, const char *argv[]) { printf("path%zu='%s'\n", filei, file.c_str()); FatHeader fat_header(Map(temp == NULL ? path : temp, !(flag_R || flag_T || flag_s || flag_S || flag_O || flag_D))); - struct linkedit_data_command *signature(NULL); _foreach (mach_header, fat_header.GetMachHeaders()) { + struct linkedit_data_command *signature(NULL); + struct encryption_info_command *encryption(NULL); + if (flag_A) { if (mach_header.GetCPUType() != flag_CPUType) continue; @@ -1141,6 +1145,8 @@ int main(int argc, const char *argv[]) { load_command->cmd = mach_header.Swap(LC_LOAD_DYLIB); else if (cmd == LC_CODE_SIGNATURE) signature = reinterpret_cast(load_command); + else if (cmd == LC_ENCRYPTION_INFO) + encryption = reinterpret_cast(load_command); else if (cmd == LC_UUID) { volatile struct uuid_command *uuid_command(reinterpret_cast(load_command)); @@ -1170,18 +1176,20 @@ int main(int argc, const char *argv[]) { dylib_command->dylib.timestamp = mach_header.Swap(timed); } - } else if (cmd == LC_ENCRYPTION_INFO) { - volatile struct encryption_info_command *encryption_info_command(reinterpret_cast(load_command)); + } + } - if (flag_D) - encryption_info_command->cryptid = mach_header.Swap(0); + if (flag_d) { + _assert(encryption != NULL); - if (flag_d) { - printf("cryptoff=0x%x\n", mach_header.Swap(encryption_info_command->cryptoff)); - printf("cryptsize=0x%x\n", mach_header.Swap(encryption_info_command->cryptsize)); - printf("cryptid=0x%x\n", mach_header.Swap(encryption_info_command->cryptid)); - } - } + printf("cryptoff=0x%x\n", mach_header.Swap(encryption->cryptoff)); + printf("cryptsize=0x%x\n", mach_header.Swap(encryption->cryptsize)); + printf("cryptid=0x%x\n", mach_header.Swap(encryption->cryptid)); + } + + if (flag_D) { + _assert(encryption != NULL); + encryption->cryptid = mach_header.Swap(0); } if (flag_e) {