summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2015-10-18 13:47:25 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2015-10-18 13:47:25 -0700
commit56f0487d8d14839f877618dee2ebc0ae63b82f7b (patch)
tree5b9a78caa5430e174e0c9f6281a58087295ebce1
parentf5db0fc2c3ba3137c5e8b76d577ccd58ae342a63 (diff)
downloadldid-56f0487d8d14839f877618dee2ebc0ae63b82f7b.tar.gz
ldid-56f0487d8d14839f877618dee2ebc0ae63b82f7b.tar.zst
ldid-56f0487d8d14839f877618dee2ebc0ae63b82f7b.zip
Add -u, which prints the current_version of UIKit.
-rw-r--r--ldid.cpp28
1 files changed, 28 insertions, 0 deletions
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<struct linkedit_data_command *>(load_command);
else if (cmd == LC_ENCRYPTION_INFO || cmd == LC_ENCRYPTION_INFO_64)
encryption = reinterpret_cast<struct encryption_info_command *>(load_command);
+ else if (cmd == LC_LOAD_DYLIB) {
+ volatile struct dylib_command *dylib_command(reinterpret_cast<struct dylib_command *>(load_command));
+ const char *name(reinterpret_cast<const char *>(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<struct dylib_command *>(load_command));