]> git.saurik.com Git - winterboard.git/commitdiff
Add a new UIImages dumping mechanism.
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 20 Oct 2011 01:45:04 +0000 (01:45 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 20 Oct 2011 01:45:04 +0000 (01:45 +0000)
.gitignore
Library.mm
UIImages.mm [deleted file]
makefile

index cb2732594dd0e2e78dca134f400b97500930adf2..2d07efa77a674c5255882fdd665418300ea01d06 100644 (file)
@@ -4,5 +4,4 @@ WinterBoard.dylib
 WinterBoardSettings
 *.deb
 Optimize
-UIImages
 winterboard
index 6b1d4fa4b3575d11fba545ed25481232fc8c9134..e97e739cdfaf2a56c5887217b695fad7fe2cff64 100644 (file)
@@ -193,6 +193,7 @@ static BOOL (*_GSFontGetUseLegacyFontMetrics)();
     (_GSFontGetUseLegacyFontMetrics == NULL ? YES : _GSFontGetUseLegacyFontMetrics())
 
 static bool Debug_ = false;
+static bool UIDebug_ = false;
 static bool Engineer_ = false;
 static bool SummerBoard_ = true;
 static bool SpringBoard_;
@@ -1546,7 +1547,18 @@ MSHook(UIImage *, _UIImageWithName, NSString *name) {
         if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true))
             image = $getImage$(path);
         [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
-        return image == nil ? __UIImageWithName(name) : image;
+        if (image != nil)
+            return image;
+
+        image = __UIImageWithName(name);
+
+        if (UIDebug_) {
+            NSString *path([@"/tmp/UIImages/" stringByAppendingString:name]);
+            if (![Manager_ fileExistsAtPath:path])
+                [UIImagePNGRepresentation(image) writeToFile:path atomically:YES];
+        }
+
+        return image;
     }
 }
 // }}}
@@ -1855,5 +1867,8 @@ MSInitialize {
     }
     // }}}
 
+    if (Debug_ && [Manager_ fileExistsAtPath:@"/tmp/UIImages"])
+        UIDebug_ = true;
+
     [pool release];
 }
diff --git a/UIImages.mm b/UIImages.mm
deleted file mode 100644 (file)
index f83b772..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#import <Foundation/Foundation.h>
-#import <CoreGraphics/CoreGraphics.h>
-
-#import <UIKit/UIKeyboard.h>
-#import <UIKit/UIImage.h>
-
-extern "C" {
-    #include <mach-o/nlist.h>
-}
-
-extern "C" NSData *UIImagePNGRepresentation(UIImage *image);
-
-template <typename Type_>
-static void nlset(Type_ &function, struct nlist *nl, size_t index) {
-    struct nlist &name(nl[index]);
-    uintptr_t value(name.n_value);
-    if ((name.n_desc & N_ARM_THUMB_DEF) != 0)
-        value |= 0x00000001;
-    function = reinterpret_cast<Type_>(value);
-}
-
-int main(int argc, char *argv[]) {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    struct nlist nl[4];
-
-    memset(nl, 0, sizeof(nl));
-    nl[0].n_un.n_name = (char *) "___mappedImages";
-    nl[1].n_un.n_name = (char *) "__UISharedImageInitialize";
-    nl[2].n_un.n_name = (char *) "_LoadMappedImageRef";
-    nlist("/System/Library/Frameworks/UIKit.framework/UIKit", nl);
-
-    NSMutableDictionary **images;
-    nlset(images, nl, 0);
-
-    void (*__UISharedImageInitialize)(bool);
-    nlset(__UISharedImageInitialize, nl, 1);
-
-    CGImageRef (*_LoadMappedImageRef)(CFStringRef);
-    nlset(_LoadMappedImageRef, nl, 2);
-
-    __UISharedImageInitialize(false);
-
-    NSArray *keys = [*images allKeys];
-    for (int i(0), e([keys count]); i != e; ++i) {
-        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-        NSString *key = [keys objectAtIndex:i];
-        CGImageRef ref;
-        if (_LoadMappedImageRef == NULL)
-            ref = reinterpret_cast<CGImageRef>([*images objectForKey:key]);
-        else
-            ref = _LoadMappedImageRef(reinterpret_cast<CFStringRef>(key));
-        UIImage *image = [UIImage imageWithCGImage:ref];
-        NSData *data = UIImagePNGRepresentation(image);
-        [data writeToFile:[NSString stringWithFormat:@"%@", key] atomically:YES];
-        [pool release];
-    }
-
-    [pool release];
-    return 0;
-}
index 3735b69314083d5ef7b0e1a283b0f5128cdc3d3b..429d9528d20b5f7140fca8e5c094c0e214a63e5b 100644 (file)
--- a/makefile
+++ b/makefile
@@ -6,10 +6,10 @@ endif
 
 substrate := -I../mobilesubstrate -L../mobilesubstrate -lsubstrate
 
-all: WinterBoard WinterBoard.dylib UIImages WinterBoardSettings Optimize
+all: WinterBoard WinterBoard.dylib WinterBoardSettings Optimize
 
 clean:
-       rm -f WinterBoard WinterBoard.dylib UIImages
+       rm -f WinterBoard WinterBoard.dylib
 
 WinterBoardSettings: Settings.mm makefile
        $(target)g++ -dynamiclib -g0 -O2 -Wall -o $@ $(filter %.mm,$^) -framework UIKit -framework CoreFoundation -framework Foundation -lobjc -framework CoreGraphics -framework Preferences -F$(PKG_ROOT)/System/Library/PrivateFrameworks
@@ -19,10 +19,6 @@ WinterBoard.dylib: Library.mm WBMarkup.mm WBMarkup.h makefile ../mobilesubstrate
        $(target)g++ -dynamiclib -g0 -O2 -Wall -o $@ $(filter %.mm,$^) -framework CoreFoundation -framework Foundation -lobjc -I/apl/inc/iPhoneOS-2.0 -framework CoreGraphics -framework ImageIO -framework GraphicsServices -framework Celestial $(substrate) -framework UIKit -framework WebCore -framework WebKit -F$(PKG_ROOT)/System/Library/PrivateFrameworks
        ldid -S $@
 
-UIImages: UIImages.mm makefile
-       $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc -I/apl/inc/iPhoneOS-2.0 $(substrate)
-       ldid -S $@
-
 WinterBoard: Application.mm makefile
        $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc -framework CoreGraphics -I/apl/sdk -framework Preferences -F$(PKG_ROOT)/System/Library/PrivateFrameworks
        ldid -S $@
@@ -53,7 +49,7 @@ package: all
        find winterboard -name .svn | while read -r line; do rm -rf "$${line}"; done
        cp -a extrainst_ preinst prerm winterboard/DEBIAN
        sed -e 's/VERSION/$(shell ./version.sh)/g' control >winterboard/DEBIAN/control
-       cp -a Test.sh Icon-Small.png icon.png icon-72.png icon@2x.png WinterBoard.dylib WinterBoard UIImages Info.plist winterboard/Applications/WinterBoard.app
+       cp -a Test.sh Icon-Small.png icon.png icon-72.png icon@2x.png WinterBoard.dylib WinterBoard Info.plist winterboard/Applications/WinterBoard.app
        file="winterboard_$$(grep ^Version: winterboard/DEBIAN/control | cut -d ' ' -f 2)_iphoneos-arm.deb"; echo "$$file"; ln -sf "$$file" winterboard.deb
        dpkg-deb -b winterboard winterboard.deb