Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ decrypt_macho(const char *inputFile, const char *outputFile)
DLOG("copying original data of size 0x%zx...", base_size);
memcpy(dupe, base, base_size);

int ret = 0;
if (*(uint32_t *)base == FAT_CIGAM || *(uint32_t *)base == FAT_MAGIC) {
bool isBe = *(uint32_t *)base == FAT_CIGAM;
struct fat_header *fat_header = (struct fat_header *) base;
Expand All @@ -323,14 +324,17 @@ decrypt_macho(const char *inputFile, const char *outputFile)
auto curFatArch = &fatarches[fat_i];
DLOG(" handling fat arch %d, cpuType 0x%x, cpuSubType 0x%x, fileOff 0x%x, size 0x%x, align 0x%x", fat_i,
fatInt(curFatArch->cputype), fatInt(curFatArch->cpusubtype), fatInt(curFatArch->offset), fatInt(curFatArch->size), fatInt(curFatArch->align));
decrypt_macho_slide(f, base + fatInt(curFatArch->offset), dupe + fatInt(curFatArch->offset), fatInt(curFatArch->offset));
ret = decrypt_macho_slide(f, base + fatInt(curFatArch->offset), dupe + fatInt(curFatArch->offset), fatInt(curFatArch->offset));
if (ret) {
break;
}
}
} else {
DLOG(" not fat binary, directly decrypting it!");
decrypt_macho_slide(f, base, dupe, 0);
ret = decrypt_macho_slide(f, base, dupe, 0);
}

munmap(base, base_size);
munmap(dupe, dupe_size);
return 0;
return ret;
}