From 56f0487d8d14839f877618dee2ebc0ae63b82f7b Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 18 Oct 2015 13:47:25 -0700 Subject: Add -u, which prints the current_version of UIKit. --- ldid.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ldid.cpp b/ldid.cpp index 9619daf..0d240c2 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -227,6 +227,16 @@ struct load_command { #define LC_DYLD_INFO_ONLY uint32_t(0x22 | LC_REQ_DYLD) #define LC_ENCRYPTION_INFO_64 uint32_t(0x2c) +union Version { + struct { + uint8_t patch; + uint8_t minor; + uint16_t major; + } _packed; + + uint32_t value; +}; + struct dylib { uint32_t name; uint32_t timestamp; @@ -2057,6 +2067,8 @@ int main(int argc, char *argv[]) { bool flag_A(false); bool flag_a(false); + bool flag_u(false); + uint32_t flag_CPUType(_not(uint32_t)); uint32_t flag_CPUSubtype(_not(uint32_t)); @@ -2158,6 +2170,10 @@ int main(int argc, char *argv[]) { } break; #endif + case 'u': { + flag_u = true; + } break; + case 'I': { flag_I = argv[argi] + 2; } break; @@ -2240,6 +2256,18 @@ int main(int argc, char *argv[]) { signature = reinterpret_cast(load_command); else if (cmd == LC_ENCRYPTION_INFO || cmd == LC_ENCRYPTION_INFO_64) encryption = reinterpret_cast(load_command); + else if (cmd == LC_LOAD_DYLIB) { + volatile struct dylib_command *dylib_command(reinterpret_cast(load_command)); + const char *name(reinterpret_cast(load_command) + mach_header.Swap(dylib_command->dylib.name)); + + if (strcmp(name, "/System/Library/Frameworks/UIKit.framework/UIKit") == 0) { + if (flag_u) { + Version version; + version.value = mach_header.Swap(dylib_command->dylib.current_version); + printf("uikit=%u.%u.%u\n", version.major, version.minor, version.patch); + } + } + } #ifndef LDID_NOFLAGT else if (cmd == LC_ID_DYLIB) { volatile struct dylib_command *dylib_command(reinterpret_cast(load_command)); -- cgit v1.2.3-56-ge451