summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2015-08-21 05:53:29 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2015-08-21 05:56:41 -0700
commit7b496abd3d9cbe500279e025860ed8a345d665b4 (patch)
tree169208b06b78b8df6f398cb021f58aedde6afc0f
parent15babeef559bba763d48d47f65dff17b0c56a7e7 (diff)
downloadldid-7b496abd3d9cbe500279e025860ed8a345d665b4.tar.gz
ldid-7b496abd3d9cbe500279e025860ed8a345d665b4.tar.zst
ldid-7b496abd3d9cbe500279e025860ed8a345d665b4.zip
Separate lookup of LC_ENCRYPTION_INFO from usages.
-rw-r--r--ldid.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/ldid.cpp b/ldid.cpp
index 3b21b8a..384b27c 100644
--- a/ldid.cpp
+++ b/ldid.cpp
@@ -1097,6 +1097,8 @@ int main(int argc, const char *argv[]) {
struct linkedit_data_command *signature(NULL);
_foreach (mach_header, fat_header.GetMachHeaders()) {
+ struct encryption_info_command *encryption(NULL);
+
if (flag_A) {
if (mach_header.GetCPUType() != flag_CPUType)
continue;
@@ -1143,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<struct linkedit_data_command *>(load_command);
+ else if (cmd == LC_ENCRYPTION_INFO)
+ encryption = reinterpret_cast<struct encryption_info_command *>(load_command);
else if (cmd == LC_UUID) {
volatile struct uuid_command *uuid_command(reinterpret_cast<struct uuid_command *>(load_command));
@@ -1172,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<struct encryption_info_command *>(load_command));
+ }
+ }
+
+ if (flag_d) {
+ _assert(encryption != NULL);
- if (flag_D)
- encryption_info_command->cryptid = mach_header.Swap(0);
+ 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) {
- 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));
- }
- }
+ if (flag_D) {
+ _assert(encryption != NULL);
+ encryption->cryptid = mach_header.Swap(0);
}
if (flag_e) {