]> git.saurik.com Git - afc2d.git/commitdiff
Use Substrate to modify Services.plist on iOS 8+. master v1.1
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 24 Oct 2014 09:59:04 +0000 (02:59 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 24 Oct 2014 10:03:52 +0000 (03:03 -0700)
afc2dService.mm [new file with mode: 0644]
afc2dService.plist [new file with mode: 0644]
control.in
extrainst.mm
make.sh

diff --git a/afc2dService.mm b/afc2dService.mm
new file mode 100644 (file)
index 0000000..0e8eecd
--- /dev/null
@@ -0,0 +1,47 @@
+/* AFC2 - the original definition of "jailbreak"
+ * Copyright (C) 2014  Jay Freeman (saurik)
+*/
+
+/* GNU General Public License, Version 3 {{{ */
+/*
+ * Cydia is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Cydia is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cydia.  If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#include <CydiaSubstrate/CydiaSubstrate.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <Foundation/Foundation.h>
+
+%hook CFPropertyListRef CFPropertyListCreateWithData(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags options, CFPropertyListFormat *format, CFErrorRef *error) {
+    CFPropertyListRef list(%original(allocator, data, options, format, error));
+    NSDictionary *dict((NSDictionary *) list);
+
+    if ([dict objectForKey:@"com.apple.afc"] != nil) {
+        NSMutableDictionary *copy([dict mutableCopy]);
+        CFRelease(list);
+        list = (CFPropertyListRef) copy;
+
+        [copy setObject:@{
+            @"AllowUnactivatedService": @true,
+            @"Label": @"com.apple.afc2",
+            @"ProgramArguments": @[@"/usr/libexec/afc2d", @"-S", @"-L", @"-d", @"/"],
+        } forKey:@"com.apple.afc2"];
+    }
+
+    return list;
+}
+
+MSInitialize {
+    MSHookFunction(&CFPropertyListCreateWithData, MSHake(CFPropertyListCreateWithData));
+}
diff --git a/afc2dService.plist b/afc2dService.plist
new file mode 100644 (file)
index 0000000..7bab7a2
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>Filter</key>
+       <dict>
+               <key>CoreFoundationVersion</key>
+               <array>
+                       <real>1000</real>
+               </array>
+               <key>Executables</key>
+               <array>
+                       <string>lockdownd</string>
+               </array>
+       </dict>
+</dict>
+</plist>
index e707f2de16e32f0def1489fa9289d7659e27d07e..23fa0bd26a14b1a80e52c5ae46408b5f3b0251f8 100644 (file)
@@ -5,6 +5,7 @@ Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
 Version: ${ver}
 Pre-Depends: dpkg (>= 1.14.25-8)
+Depends: firmware (<< 8.0) | mobilesubstrate
 Conflicts: us.scw.afctwoadd, net.angelxwind.afc2ios70, afc2.25pp, afc2.25pp7, afc2.91, app.taig.afc2
 Replaces: us.scw.afctwoadd, net.angelxwind.afc2ios70, afc2.25pp, afc2.25pp7, afc2.91, app.taig.afc2
 Provides: us.scw.afctwoadd, net.angelxwind.afc2ios70, afc2.25pp, afc2.25pp7, afc2.91, app.taig.afc2
index 9c4764e65663d7db4c4531c41e5f142d03ba4333..21e7796f46facf9b046736d3a80719643e27b1fe 100644 (file)
@@ -87,19 +87,29 @@ int main(int argc, const char *argv[]) {
             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;
 }
diff --git a/make.sh b/make.sh
index 29972fc8c2bc38d6f8840fa5740bcfb00d4c990d..7e32a60b76a423662f8c203a1f9d576e30a09a6b 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -3,6 +3,11 @@ set -e
 ver=$(git describe --tags --dirty="+" --match="v*" "${flags[@]}" | sed -e 's@-\([^-]*\)-\([^-]*\)$@+\1.\2@;s@^v@@;s@%@~@g')
 sudo rm -rf _
 mkdir -p _/DEBIAN
+ms=_/Library/MobileSubstrate/DynamicLibraries
+mkdir -p "${ms}"
+cp -a afc2dService.plist "${ms}"
+plutil -convert binary1 "${ms}"/afc2dService.plist
+cycc -i2.0 -o"${ms}"/afc2dService.dylib -s afc2dService.mm -- -framework Foundation
 cycc -i2.0 -o_/DEBIAN/extrainst_ -- extrainst.mm -lz -framework Foundation
 cycc -i2.0 -o_/DEBIAN/postrm -- postrm.mm -lz -framework Foundation
 sed -e 's/\${ver}/'"${ver}"'/' control.in >_/DEBIAN/control