-
-#define Dylib_ "/Library/MobileSubstrate/MobileSubstrate.dylib"
-
-MSInitialize {
- NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
-
- NSLog(@"MS:Warning: Entering Safe Mode");
-
- char *dil(getenv("DYLD_INSERT_LIBRARIES"));
- if (dil == NULL)
- NSLog(@"MS:Error: DYLD_INSERT_LIBRARIES is unset?");
- else {
- NSArray *dylibs([[NSString stringWithUTF8String:dil] componentsSeparatedByString:@":"]);
- NSUInteger index([dylibs indexOfObject:@ Dylib_]);
- if (index == NSNotFound)
- NSLog(@"MS:Error: dylib not in DYLD_INSERT_LIBRARIES?");
- else if ([dylibs count] == 1)
- unsetenv("DYLD_INSERT_LIBRARIES");
- else {
- NSMutableArray *value([[[NSMutableArray alloc] init] autorelease]);
- [value setArray:dylibs];
- [value removeObjectAtIndex:index];
- setenv("DYLD_INSERT_LIBRARIES", [[value componentsJoinedByString:@":"] UTF8String], !0);
- }
- }
-
- [pool release];
-}