]> git.saurik.com Git - afc2d.git/blobdiff - extrainst.mm
Use Substrate to modify Services.plist on iOS 8+.
[afc2d.git] / extrainst.mm
index e0a4efe5b438da56b9955788226e035226e92a88..21e7796f46facf9b046736d3a80719643e27b1fe 100644 (file)
@@ -81,25 +81,35 @@ int main(int argc, const char *argv[]) {
 
     NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
 
-    if (kCFCoreFoundationVersionNumber >= 847.24)
+    if (kCFCoreFoundationVersionNumber >= 800)
         if (NSString *error = download()) {
             fprintf(stderr, "error: %s\n", [error UTF8String]);
             return 1;
         }
 
-    NSString *path(@"/System/Library/Lockdown/Services.plist");
-    NSMutableDictionary *services([NSMutableDictionary dictionaryWithContentsOfFile:path]);
+    if (kCFCoreFoundationVersionNumber < 1000) {
+        NSString *path(@"/System/Library/Lockdown/Services.plist");
 
-    [services setObject:@{
-        @"AllowUnactivatedService": @true,
-        @"Label": @"com.apple.afc2",
-        @"ProgramArguments": @[@"/usr/libexec/afc2d", @"-S", @"-L", @"-d", @"/"],
-    } forKey:@"com.apple.afc2"];
+        NSMutableDictionary *services([NSMutableDictionary dictionaryWithContentsOfFile:path]);
+        if (services == nil) {
+            fprintf(stderr, "cannot read Services.plist\n");
+            return 1;
+        }
+
+        [services setObject:@{
+            @"AllowUnactivatedService": @true,
+            @"Label": @"com.apple.afc2",
+            @"ProgramArguments": @[@"/usr/libexec/afc2d", @"-S", @"-L", @"-d", @"/"],
+        } forKey:@"com.apple.afc2"];
+
+        if (![services writeToFile:path atomically:YES]) {
+            fprintf(stderr, "cannot write Services.plist\n");
+            return 1;
+        }
+    }
 
-    [services writeToFile:path atomically:YES];
     system("/bin/launchctl stop com.apple.mobile.lockdown");
 
     [pool release];
-
     return 0;
 }