⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 library.mm

📁 iPhone winterboard - theme customizer
💻 MM
📖 第 1 页 / 共 4 页
字号:
extern "C" NSData *UIImagePNGRepresentation(UIImage *);//static CGImageRef *(*_UIImageRefAtPath)(NSString *path, bool cache, UIImageOrientation *orientation);//_UIImageRefAtPath = (CGImageRef *(*)(NSString *, bool, UIImageOrientation *)) nl[3].n_value;static UIImage *(*_UIImageAtPath)(NSString *name, NSBundle *path);static UIImage *(*_UIImageWithName)(NSString *name);static UIImage *(*_UIImageWithNameInDomain)(NSString *name, NSString *domain);static NSBundle *(*_UIKitBundle)();static void (*_UISharedImageInitialize)(bool);static int (*_UISharedImageNameGetIdentifier)(NSString *);static UIImage *(*_UISharedImageWithIdentifier)(int);static UIImage *$_UIImageWithName(NSString *name) {    int id(_UISharedImageNameGetIdentifier(name));    if (Debug_)        NSLog(@"WB:Debug: UIImageWithName(\"%@\", %d)", name, id);    if (id == -1)        return _UIImageAtPath(name, _UIKitBundle());    else {        NSNumber *key([NSNumber numberWithInt:id]);        UIImage *image = [UIImages_ objectForKey:key];        if (image != nil)            return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;        if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) {            image = [[UIImage alloc] wb$initWithContentsOfFile:path];            if (image != nil)                [image autorelease];        }        if (image == nil)            image = _UISharedImageWithIdentifier(id);        [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];        return image;    }}static UIImage *$_UIImageWithNameInDomain(NSString *name, NSString *domain) {    NSString *key = [NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name];    UIImage *image = [PathImages_ objectForKey:key];    if (image != nil)        return reinterpret_cast<id>(image) == [NSNull null] ? nil : image;    if (Debug_)        NSLog(@"WB:Debug: UIImageWithNameInDomain(\"%@\", \"%@\")", name, domain);    if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Domains/%@/%@", domain, name]])) {        image = [[UIImage alloc] wb$initWithContentsOfFile:path];        if (image != nil)            [image autorelease];    }    if (image == nil)        image = _UIImageWithNameInDomain(name, domain);    [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];    return image;}#define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"#define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"static bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long, char *, bool &);static bool $_Z24GetFileNameForThisActionmPcRb(unsigned long a0, char *a1, bool &a2) {    bool value = _Z24GetFileNameForThisActionmPcRb(a0, a1, a2);    if (Debug_)        NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u) = %u", a0, value ? a1 : NULL, a2, value);    if (value) {        NSString *path = [NSString stringWithUTF8String:a1];        if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {            NSString *file = [path substringFromIndex:31];            NSLog(@"%@", file);            for (NSString *theme in themes_) {                NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);                if ([Manager_ fileExistsAtPath:path]) {                    strcpy(a1, [path UTF8String]);                    continue;                }            }        }    }    return value;}static void ChangeWallpaper(    CFNotificationCenterRef center,    void *observer,    CFStringRef name,    const void *object,    CFDictionaryRef info) {    if (Debug_)        NSLog(@"WB:Debug:ChangeWallpaper!");    UIImage *image;    if (WallpaperFile_ != nil) {        image = [[UIImage alloc] wb$initWithContentsOfFile:WallpaperFile_];        if (image != nil)            image = [image autorelease];    } else image = nil;    if (WallpaperImage_ != nil)        [WallpaperImage_ setImage:image];    if (WallpaperPage_ != nil)        [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];}#define Prefix_ "wb$"void WBRename(bool instance, const char *name, SEL sel, IMP imp) {    if (Class _class = objc_getClass(name)) {        if (!instance)            _class = object_getClass(_class);        MSHookMessage(_class, sel, imp, Prefix_);    } else if (Debug_)        NSLog(@"WB:Warning: cannot find class [%s]", name);}extern "C" void WBInitialize() {    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];    NSString *identifier([[NSBundle mainBundle] bundleIdentifier]);    NSLog(@"WB:Notice: WinterBoard");    struct nlist nl[8];    memset(nl, 0, sizeof(nl));    nl[0].n_un.n_name = (char *) "__UIImageAtPath";    nl[1].n_un.n_name = (char *) "__UIImageWithName";    nl[2].n_un.n_name = (char *) "__UIImageWithNameInDomain";    nl[3].n_un.n_name = (char *) "__UIKitBundle";    nl[4].n_un.n_name = (char *) "__UISharedImageInitialize";    nl[5].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier";    nl[6].n_un.n_name = (char *) "__UISharedImageWithIdentifier";    nlist(UIKit, nl);    _UIImageAtPath = (UIImage *(*)(NSString *, NSBundle *)) nl[0].n_value;    _UIImageWithName = (UIImage *(*)(NSString *)) nl[1].n_value;    _UIImageWithNameInDomain = (UIImage *(*)(NSString *, NSString *)) nl[2].n_value;    _UIKitBundle = (NSBundle *(*)()) nl[3].n_value;    _UISharedImageInitialize = (void (*)(bool)) nl[4].n_value;    _UISharedImageNameGetIdentifier = (int (*)(NSString *)) nl[5].n_value;    _UISharedImageWithIdentifier = (UIImage *(*)(int)) nl[6].n_value;    MSHookFunction(_UIImageWithName, &$_UIImageWithName, &_UIImageWithName);    MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &_UIImageWithNameInDomain);    if (dlopen(AudioToolbox, RTLD_LAZY | RTLD_NOLOAD) != NULL) {        struct nlist nl[2];        memset(nl, 0, sizeof(nl));        nl[0].n_un.n_name = (char *) "__Z24GetFileNameForThisActionmPcRb";        nlist(AudioToolbox, nl);        _Z24GetFileNameForThisActionmPcRb = (bool (*)(unsigned long, char *, bool &)) nl[0].n_value;        MSHookFunction(_Z24GetFileNameForThisActionmPcRb, &$_Z24GetFileNameForThisActionmPcRb, &_Z24GetFileNameForThisActionmPcRb);    }    WBRename(false, "UIImage", @selector(applicationImageNamed:), (IMP) &UIImage$applicationImageNamed$);    WBRename(false, "UIImage", @selector(defaultDesktopImage), (IMP) &UIImage$defaultDesktopImage$);    WBRename(false, "UIImage", @selector(imageAtPath:), (IMP) &UIImage$imageAtPath$);    WBRename(false, "UIImage", @selector(imageNamed:), (IMP) &UIImage$imageNamed$);    WBRename(false, "UIImage", @selector(imageNamed:inBundle:), (IMP) &UIImage$imageNamed$inBundle$);    //WBRename("UINavigationBar", @selector(initWithCoder:", (IMP) &UINavigationBar$initWithCoder$);    //WBRename("UINavigationBarBackground", @selector(initWithFrame:withBarStyle:withTintColor:", (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);    WBRename(true, "NSBundle", @selector(localizedStringForKey:value:table:), (IMP) &NSBundle$localizedStringForKey$value$table$);    WBRename(true, "NSBundle", @selector(pathForResource:ofType:), (IMP) &NSBundle$pathForResource$ofType$);    WBRename(true, "UIImage", @selector(initWithContentsOfFile:), (IMP) &$initWithContentsOfFile$);    WBRename(true, "UIImage", @selector(initWithContentsOfFile:cache:), (IMP) &UIImage$initWithContentsOfFile$cache$);    WBRename(true, "UINavigationBar", @selector(setBarStyle:), (IMP) &UINavigationBar$setBarStyle$);    WBRename(true, "UIToolbar", @selector(setBarStyle:), (IMP) &UIToolbar$setBarStyle$);    _UISharedImageInitialize(false);    Manager_ = [[NSFileManager defaultManager] retain];    UIImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];    PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16];    Strings_ = [[NSMutableDictionary alloc] initWithCapacity:0];    themes_ = [[NSMutableArray alloc] initWithCapacity:8];    if (NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {        [settings autorelease];        if (NSNumber *debug = [settings objectForKey:@"Debug"])            Debug_ = [debug boolValue];        NSArray *themes = [settings objectForKey:@"Themes"];        if (themes == nil)            if (NSString *theme = [settings objectForKey:@"Theme"])                themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:                    theme, @"Name",                    [NSNumber numberWithBool:true], @"Active",                nil]];        if (themes != nil)            for (NSDictionary *theme in themes) {                NSNumber *active = [theme objectForKey:@"Active"];                if (![active boolValue])                    continue;                NSString *name = [theme objectForKey:@"Name"];                if (name == nil)                    continue;                NSString *theme = nil;                #define testForTheme(format...) \                    if (theme == nil) { \                        NSString *path = [NSString stringWithFormat:format]; \                        if ([Manager_ fileExistsAtPath:path]) { \                            [themes_ addObject:path]; \                            continue; \                        } \                    }                testForTheme(@"/Library/Themes/%@.theme", name)                testForTheme(@"/Library/Themes/%@", name)                testForTheme(@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name)            }    }    Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];    for (NSString *theme in themes_)        if (NSDictionary *info = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]])            for (NSString *key in [info allKeys])                if ([Info_ objectForKey:key] == nil)                    [Info_ setObject:[info objectForKey:key] forKey:key];    if ([identifier isEqualToString:@"com.apple.MobileSMS"]) {        Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController");        MSHookMessage(mSMSMessageTranscriptController, @selector(loadView), (IMP) &mSMSMessageTranscriptController$loadView, Prefix_);    } else if ([identifier isEqualToString:@"com.apple.springboard"]) {        CFNotificationCenterAddObserver(            CFNotificationCenterGetDarwinNotifyCenter(),            NULL, &ChangeWallpaper, (CFStringRef) @"com.saurik.winterboard.lockbackground", NULL, 0        );        NSBundle *MediaPlayer = [NSBundle bundleWithPath:@"/System/Library/Frameworks/MediaPlayer.framework"];        if (MediaPlayer != nil)            [MediaPlayer load];        $MPVideoView = objc_getClass("MPVideoView");        WBRename(true, "WebCoreFrameBridge", @selector(renderedSizeOfNode:constrainedToWidth:), (IMP) &WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$);        WBRename(true, "SBApplication", @selector(pathForIcon), (IMP) &SBApplication$pathForIcon);        WBRename(true, "SBApplicationIcon", @selector(icon), (IMP) &SBApplicationIcon$icon);        WBRename(true, "SBBookmarkIcon", @selector(icon), (IMP) &SBBookmarkIcon$icon);        WBRename(true, "SBButtonBar", @selector(didMoveToSuperview), (IMP) &$didMoveToSuperview);        WBRename(true, "SBCalendarIconContentsView", @selector(drawRect:), (IMP) &SBCalendarIconContentsView$drawRect$);        WBRename(true, "SBContentLayer", @selector(initWithSize:), (IMP) &SBContentLayer$initWithSize$);        WBRename(true, "SBIconBadge", @selector(initWithBadge:), (IMP) &SBIconBadge$initWithBadge$);        WBRename(true, "SBIconController", @selector(appendIconList:), (IMP) &SBIconController$appendIconList$);        WBRename(true, "SBIconLabel", @selector(drawRect:), (IMP) &SBIconLabel$drawRect$);        WBRename(true, "SBIconLabel", @selector(initWithSize:label:), (IMP) &SBIconLabel$initWithSize$label$);        WBRename(true, "SBIconLabel", @selector(setInDock:), (IMP) &SBIconLabel$setInDock$);        WBRename(true, "SBIconModel", @selector(cacheImageForIcon:), (IMP) &SBIconModel$cacheImageForIcon$);        WBRename(true, "SBIconModel", @selector(getCachedImagedForIcon:), (IMP) &SBIconModel$getCachedImagedForIcon$);        WBRename(true, "SBSlidingAlertDisplay", @selector(updateDesktopImage:), (IMP) &SBSlidingAlertDisplay$updateDesktopImage$);        WBRename(true, "SBStatusBarContentsView", @selector(didMoveToSuperview), (IMP) &$didMoveToSuperview);        WBRename(true, "SBStatusBarContentsView", @selector(initWithStatusBar:mode:), (IMP) &SBStatusBarContentsView$initWithStatusBar$mode$);        WBRename(true, "SBStatusBarController", @selector(setStatusBarMode:orientation:duration:fenceID:animation:), (IMP) &SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$);        WBRename(true, "SBStatusBarOperatorNameView", @selector(operatorNameStyle), (IMP) &SBStatusBarOperatorNameView$operatorNameStyle);        WBRename(true, "SBStatusBarOperatorNameView", @selector(setOperatorName:fullSize:), (IMP) &SBStatusBarOperatorNameView$setOperatorName$fullSize$);        WBRename(true, "SBStatusBarTimeView", @selector(drawRect:), (IMP) &SBStatusBarTimeView$drawRect$);        English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];        if (English_ != nil)            English_ = [English_ retain];        Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];    }    Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain];    if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)        [Info_ setObject:[NSNumber numberWithBool:(            $getTheme$(Wallpapers_) == nil ||            [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||            [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil        )] forKey:@"UndockedIconLabels"];    if (Debug_)        NSLog(@"WB:Debug:Info = %@", [Info_ description]);    [pool release];}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -