Wednesday, May 13, 2009

How to classdump SpringBoard header files and patch it

To classdump the SpringBoard header,

class-dump-x /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/System/Library/CoreServices/SpringBoard.app/SpringBoard -H -o Springboard

class-dump-x is available in Mac OS X and iPhone here

class-dumped header files are not directly usable and you should use this patch script to change the import statement of the dumped header files.

springboardheaderpatch.sh Select all

#/bin/sh
cd SpringBoard
perl -w -i -p -e "s/#import \"ISDownload.h\"/#import \<iTunesStore\/ISDownload.h\>/g" *.h
perl -w -i -p -e "s/#import \"ISNetworkMonitor-Protocol.h\"/#import \<iTunesStore\/ISNetworkMonitor-Protocol.h\>/g" *.h
perl -w -i -p -e "s/#import \"NSArray.h\"/#import \<Foundation\/NSArray.h\>/g" *.h
perl -w -i -p -e "s/#import \"NSCharacterSet.h\"/#import \<Foundation\/NSCharacterSet.h\>/g" *.h
perl -w -i -p -e "s/#import \"NSDictionary.h\"/#import \<Foundation\/NSDictionary.h\>/g" *.h
perl -w -i -p -e "s/#import \"NSMutableArray.h\"/#import \<Foundation\/NSMutableArray.h\>/g" *.h
perl -w -i -p -e "s/#import \"NSObject.h\"/#import \<Foundation\/NSObject.h\>/g" *.h
perl -w -i -p -e "s/#import \"NSObject-Protocol.h\"/#import \<Foundation\/NSObject-Protocol.h\>/g" *.h
perl -w -i -p -e "s/#import \"NSOperation.h\"/#import \<Foundation\/NSOperation.h\>/g" *.h
perl -w -i -p -e "s/#import \"NSString.h\"/#import \<Foundation\/NSString.h\>/g" *.h
perl -w -i -p -e "s/#import \"NSUserDefaults.h\"/#import \<Foundation\/NSUserDefaults.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBAlert.h\"/#import \<SpringBoard\/SBAlert.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBAlertDisplay.h\"/#import \<SpringBoard\/SBAlertDisplay.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBAlertInputView.h\"/#import \<SpringBoard\/SBAlertInputView.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBAlertItem.h\"/#import \<SpringBoard\/SBAlertItem.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBAlertWindow.h\"/#import \<SpringBoard\/SBAlertWindow.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBApplication.h\"/#import \<SpringBoard\/SBApplication.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBApplicationIcon.h\"/#import \<SpringBoard\/SBApplicationIcon.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBCallAlertDisplay.h\"/#import \<SpringBoard\/SBCallAlertDisplay.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBDismissOnlyAlertItem.h\"/#import \<SpringBoard\/SBDismissOnlyAlertItem.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBDisplay.h\"/#import \<SpringBoard\/SBDisplay.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBIcon.h\"/#import \<SpringBoard\/SBIcon.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBIconList.h\"/#import \<SpringBoard\/SBIconList.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBPhoneAlertItem.h\"/#import \<SpringBoard\/SBPhoneAlertItem.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBPlatformController.h\"/#import \<SpringBoard\/SBPlatformController.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBRingingAlertItem.h\"/#import \<SpringBoard\/SBRingingAlertItem.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBSIMLockEntryAlertDisplay.h\"/#import \<SpringBoard\/SBSIMLockEntryAlertDisplay.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBSIMToolkitAlert.h\"/#import \<SpringBoard\/SBSIMToolkitAlert.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBSIMToolkitGetInputDisplay.h\"/#import \<SpringBoard\/SBSIMToolkitGetInputDisplay.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBSIMToolkitTextAlertDisplay.h\"/#import \<SpringBoard\/SBSIMToolkitTextAlertDisplay.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBSlidingAlertDisplay.h\"/#import \<SpringBoard\/SBSlidingAlertDisplay.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBSoundPreferences.h\"/#import \<SpringBoard\/SBSoundPreferences.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBStatusBarContentView.h\"/#import \<SpringBoard\/SBStatusBarContentView.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBStatusBarInCallView.h\"/#import \<SpringBoard\/SBStatusBarInCallView.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBTVOutController.h\"/#import \<SpringBoard\/SBTVOutController.h\>/g" *.h
perl -w -i -p -e "s/#import \"SBUSSDAlert.h\"/#import \<SpringBoard\/SBUSSDAlert.h\>/g" *.h
perl -w -i -p -e "s/#import \"SpringBoard.h\"/#import \<SpringBoard\/SpringBoard.h\>/g" *.h
perl -w -i -p -e "s/#import \"TPPhonePad.h\"/#import \<TelephonyUI\/TPPhonePad.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIAlertSheetTableCell.h\"/#import \<UIKit\/UIAlertSheetTableCell.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIApplication.h\"/#import \<UIKit\/UIApplication.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIControl.h\"/#import \<UIKit\/UIControl.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIImageView.h\"/#import \<UIKit\/UIImageView.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIModalView.h\"/#import \<UIKit\/UIModalView.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIModalViewDelegate-Protocol.h\"/#import \<UIKit\/UIModalViewDelegate-Protocol.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIPageControl.h\"/#import \<UIKit\/UIPageControl.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIPasscodeField.h\"/#import \<UIKit\/UIPasscodeField.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIPreferencesTableCell.h\"/#import \<UIKit\/UIPreferencesTableCell.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIPushButton.h\"/#import \<UIKit\/UIPushButton.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIScroller.h\"/#import \<UIKit\/UIScroller.h\>/g" *.h
perl -w -i -p -e "s/#import \"UITextField.h\"/#import \<UIKit\/UITextField.h\>/g" *.h
perl -w -i -p -e "s/#import \"UITextFieldDelegate-Protocol.h\"/#import \<UIKit\/UITextFieldDelegate-Protocol.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIView.h\"/#import \<UIKit\/UIView.h\>/g" *.h
perl -w -i -p -e "s/#import \"UIWindow.h\"/#import \<UIKit\/UIWindow.h\>/g" *.h



Here is another version that will dump and patch the 3.0 SDK SpringBoard headers using sed instead of perl

springboard30.sh Select all

#/bin/sh
SDKVER=3.0
rm -f pringBoard/* SpringBoard/*
class-dump-x /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk/System/Library/CoreServices/SpringBoard.app/SpringBoard -H -o pringBoard
mkdir -p SpringBoard
for i in pringBoard/*.h
do
sed "s/\(#import \)\"\(NS.*\.h\)\"/\1\<Foundation\/\2\>/g;"\
"s/\(#import \)\"\(UI.*\.h\)\"/\1\<UIKit\/\2\>/g;"\
"s/\(#import \)\"\(IS.*\.h\)\"/\1\<iTunesStore\/\2\>/g;"\
"s/\(#import \)\"\(SB.*\.h\)\"/\1\<SpringBoard\/\2\>/g;"\
"s/\(#import \)\"\(TP.*\.h\)\"/\1\<TelephonyUI\/\2\>/g;"\
"s/\(#import \)\"\(SpringBoard.*\.h\)\"/\1\<SpringBoard\/\2\>/g;"\
"s/\(#import \)\"\(SPDaemon.*\.h\)\"/\1\<SpringBoard\/\2\>/g;"\
"s/\(#import \)\"\(VS.*\.h\)\"/\1\<VoiceServices\/\2\>/g;"\
"s/\(#import \)\"\(APS.*\.h\)\"/\1\<ApplePushService\/\2\>/g" $i > S$i
done
grep "import \".*h\"" SpringBoard/*.h



class dump and patch the 3.0 SDK UIKit headers using sed in iPhone

uikit30.sh Select all

#/bin/sh
class-dump /System/Library/Frameworks/UIKit.framework/UIKit -H -o IKit
mkdir -p UIKit
for i in IKit/*.h
do
sed "s/\(#import \)\"\(NS.*\.h\)\"/\1\<Foundation\/\2\>/g;"\
"s/\(#import \)\"\(UI.*\.h\)\"/\1\<UIKit\/\2\>/g;"\
"s/\(#import \)\"\(IS.*\.h\)\"/\1\<iTunesStore\/\2\>/g;"\
"s/\(#import \)\"\(SB.*\.h\)\"/\1\<SpringBoard\/\2\>/g;"\
"s/\(#import \)\"\(TP.*\.h\)\"/\1\<TelephonyUI\/\2\>/g;"\
"s/\(#import \)\"\(SpringBoard.*\.h\)\"/\1\<SpringBoard\/\2\>/g;"\
"s/\(#import \)\"\(SPDaemon.*\.h\)\"/\1\<SpringBoard\/\2\>/g;"\
"s/\(#import \)\"\(VS.*\.h\)\"/\1\<VoiceServices\/\2\>/g;"\
"s/\(#import \)\"\(APS.*\.h\)\"/\1\<ApplePushService\/\2\>/g;"\
"s/\(#import \)\"\(WebView.*\.h\)\"/\1\<WebKit\/\2\>/g;"\
"s/\(#import \)\"\(WebFrame.*\.h\)\"/\1\<WebKit\/\2\>/g;"\
"s/\(#import \)\"\(CA.*ayer.*\.h\)\"/\1\<QuartzCore\/\2\>/g;"\
"s/\(#import \)\"\(DOM.*\.h\)\"/\1\<WebKit\/\2\>/g" $i > U$i
done
grep "import \".*h\"" UIKit/*.h

1 comment:

Anonymous said...

class-dump gives error "Error: Cannot find offset for address in dataOffset for addr"
hi All,

I am trying to dump the springboard headers from my mac

using following command

class-dump /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/CoreServices/SpringBoard.app/SpringBoard -H

but I am getting the following error :
2010-09-13 16:14:23.325 class-dump[1955:10b] Error: Cannot find offset for address 0x38a56a2c in dataOffsetForAddress:

I downloaded the class-dump command line tool from http://www.codethecode.com/projects/class-dump/ and copied the class-dump file to my usr/bin/ directory

So anyone please let me know what went wrong???

Regards,
Syamooo