} %end
-// notification widgets ("wee apps" or "bulletin board sections") are capable of crashing SpringBoard
-// unfortunately, which ones are in use are stored in SpringBoard's defaults, so we need to turn them off
-
-%hook BBSectionInfo
-- (BOOL) showsInNotificationCenter {
- return NO;
-} %end
-
-
-// we don't want this state persisted back to disk, however: that is just really really irritating
-
-%hook BBServer
-- (void) _writeBehaviorOverrides {}
-- (void) _writeSectionOrder {}
-- (void) _writeClearedSections {}
-- (void) _writeSectionInfo {}
-%end
-
-
// on iOS 6.0, Apple split parts of SpringBoard into a daemon called backboardd, including app launches
// in order to allow safe mode to propogate into applications, we need to then tell backboardd here
// XXX: (all of this should be replaced, however, with per-process launchd-mediated exception handling)
return %orig(modified);
} %end
+
+// this highly-general hook replaces all previous attempts to protect SpringBoard from spurious code
+// the main purpose is to protect SpringBoard from non-Substrate "away view plug-ins" and "wee apps"
+
+const char *dylibs_[] = {
+ "/usr/lib",
+ "/System/Library/Frameworks",
+ "/System/Library/PrivateFrameworks",
+ "/System/Library/CoreServices",
+ "/System/Library/AccessibilityBundles",
+ NULL,
+};
+
+MSHook(void *, dlopen, const char *path, int mode) {
+ // we probably don't need this whitelist, but it has the nifty benefit of letting Cycript inject
+ // that said, older versions of iOS (before 3.1) will need a special case due to now shared cache
+
+ for (const char **dylib = dylibs_; *dylib != NULL; ++dylib) {
+ size_t length(strlen(*dylib));
+ if (strncmp(path, *dylib, length) != 0)
+ continue;
+ if (path[length] != '/')
+ continue;
+ goto load;
+ }
+
+ // if the file is not on disk, and isn't already loaded (LC_ID_DYLIB), it is in the shared cache
+ // files loaded from the shared cache are "trusted". ones that don't exist are clearly harmless.
+ // this allows us to load most of the dynamic functionality of SpringBoard without going nuts ;P
+
+ if (access(path, F_OK) == 0)
+ mode |= RTLD_NOLOAD;
+
+ load:
+ return _dlopen(path, mode);
+}
+
+
%ctor {
NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
+ MSHookFunction(&dlopen, MSHake(dlopen));
+
// on iOS 6, backboardd is in charge of brightness, and freaks out when SpringBoard restarts :(
// the result is that the device is super dark until we attempt to update the brightness here.