-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_lc_version_min_iphoneos.py
More file actions
executable file
·41 lines (32 loc) · 1.06 KB
/
patch_lc_version_min_iphoneos.py
File metadata and controls
executable file
·41 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
import struct
import sys
#hack to patch the LC_VERSION_MIN_IPHONEOS load command
#of armv6 binaries produced with Xcode 4.4.1 (iOS 5.1 SDK)
#this script sets the version info to iOS 10 so that when run on
#iOS 7/8, the new UITableView style is used, and the
#binary still works on the original iphone running iOS 3
#before (otool -lv)
# cmd LC_VERSION_MIN_IPHONEOS
# cmdsize 16
# version 5.1
# sdk 5.1
#after
# version 10.0
# sdk 10.0
LC_VERSION_MIN_IPHONEOS = 0x25
if len(sys.argv) != 2:
print "Usage: %s macho_binary" % sys.argv[0]
exit(0)
filename = sys.argv[1]
f = open(filename, "r+b", 0)
magic,cputype,_,_,ncmds,sizeofcmds,flags = struct.unpack("<LLLLLLL", f.read(7*4))
assert (magic == 0xfeedface)
for i in xrange(ncmds):
cmd, cmdsize = struct.unpack("<LL", f.read(8))
if cmd == LC_VERSION_MIN_IPHONEOS and cmdsize == 16:
print "Patching LC_VERSION_MIN_IPHONEOS command"
f.write(struct.pack("<LL", 0x0A0000, 0x0A0000)) #iOS 10 version/sdk
break
f.seek(f.tell() + cmdsize - 8)
f.close()