Friday, May 30, 2008

Remove and reenter the Mac Office 2008 product key

This is needed after you have installed Mac Office 2008 SP1

Remove and reenter the Mac Office 2008 product key
If your copy of Office 2008 was installed with an invalid product key, or if you mistakenly used the same product key to install Office 2008 on more than one computer, you must remove the invalid product key and enter a valid product key to use Office 2008.

(1) In the Finder, select /Applications/Microsoft Office 2008/Office/OfficePID.plist
, and then on the File menu, click Move to Trash.

(2) Select /Users/yourusername/Library/Preferences/Microsoft/Office 2008/Microsoft Office 2008 settings.plist
, and then on the File menu, click Move to Trash.

(3) On the Apple menu, click Restart.

(4) After your computer restarts, open any Office 2008 application.

(5) The Office Setup Assistant opens.

(6) Accept the software license agreement, and then enter your valid product key.

Sunday, May 25, 2008

Mac OS X Leopard runs IE6 (Active X) natively

You don't need VMWare, bootcamp nor Parellel Desktop. And it is free. You can run IE6 with Active X support in Mac OS X under X11

see this instruction

If you need to install additional fonts, put them here

Internet Explorer

I use these commands to install Chinese Font inside

cd Desktop/Internet Explorer
ln -s /System/Library/Fonts/儷黑\ Pro.ttf .

Saturday, May 24, 2008

iPhone Open Toolchain Header runs UIShowCase

The missing UIKit clasees of open toolchain headers for IPhone SDK is now partially solved. You can now build UIShowCase in your Open Toolchain Template in iPhone SDK.

Read this

Wednesday, May 14, 2008

What is needed to be an iPhone programmer (firmware 2.0 OS)

Even if you are not a registered iPhone developer of Apple (US$99 program), you still can code and test your iPhone program in firmware 2.0

This is how:

(1) You need a machine running Mac OS X 10.5.2 with Intel CPU because you need to run iPhone SDK for the iPhone OS 2.0
there are several possibilities, e.g.
(a) you can get a Intel Mac with Mac OS X 10.5.2 (which I think is the easiest one and save a lot of troubles, thus you can put omore time in the learning of iPhone programming)
(b) Use the VMWare image (and use VMWare Workstation/Player for PC), read this, and install iPhone SDK in it. You need C2D Intel CPU and lots of RAM (2G) in your existing PC.
(c) Install OSX86 on PC (you must be a power user), read this forum on how

(2) Get the iPhone SDK from Apple which is free after registration with Apple.

(3) You need to read some books on Objective C and Foundation framework of Mac OS X, I think Oreilly has good source of books in this subject. This site also gives some tutorial exmaples on cocoa programming

(4) Get a pwned iPhone with iPhone OS 2.0 firmware beta 3 (build 5A240d)
read this for the pwnage tools

(5) Read this Forum and use the Xcode template (open toolchain header) here to start some coding and testing on iPhone

(6) get some project code (based on open toolchain) from the right menu of this blog to compile and test run on iPhone

(7) start coding your own idea in your own iPhone project.

Saturday, May 10, 2008

Rainbow screen of death

class-dump for iPhone SDK header file

with this wonderful tool, you don't need to worry about header files problem any more
put the class-dump binary (Mac OS X) in your bin and do this

class-dump -H /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/UIKit.framework/UIKit

you will get the most updated header files in your current directory from the SDK

Tuesday, May 6, 2008

Two versions of Hello World (SDK headers vs Open Tool Chain headers)

It is possible to use Open Tool Chain Header with the SDK and the iPhone OS 2.0 SDK headers, this example gives these two version to compare

iPhone OS 2.0 SDK headers version
Code: Select all

// main.m
// HelloSDK
#import <UIKit/UIKit.h>
@interface MyView : UIView {
@implementation MyView
- (void)drawRect:(CGRect)rect {
[[UIColor whiteColor] set];
[@"Hello SDK" drawInRect:CGRectMake(0, 100, 320, 50)
withFont:[UIFont fontWithName:@"Marker Felt" size:50]

@interface HelloSDK2AppDelegate : NSObject {
UIWindow *window;
MyView *contentView;
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) MyView *contentView;

@implementation HelloSDK2AppDelegate
@synthesize window;
@synthesize contentView;

- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Create window
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

// Set up content view
self.contentView = [[[MyView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
[window addSubview:contentView];

// Show window
[window makeKeyAndVisible];

- (void)dealloc {
[contentView release];
[window release];
[super dealloc];

int main(int argc, char *argv[])
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"HelloSDK2AppDelegate");
[pool release];
return retVal;

Open Tool Chain headers version
Code: Select all


#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

// include for the sdk compiler and open toolchain headers
#ifndef UIKIT_UIFont_UIColor_H
#define UIKIT_UIFont_UIColor_H
typedef float CGFloat;
#import <UIKit/UIFont.h>
#import <UIKit/UIColor.h>

@interface HelloToolChain : UIApplication

@implementation HelloToolChain
- (void) applicationDidFinishLaunching: (NSNotification *)aNotification
UIWindow *window = [[UIWindow alloc] initWithContentRect: [UIHardware fullScreenApplicationContentRect]];
UITextLabel *label = [[UITextLabel alloc] initWithFrame: CGRectMake(0, 100, 320, 50)];
[label setFont:[UIFont fontWithName:@"Marker Felt" size:50]];
[label setCentersHorizontally: YES];
[label setText:@"Hello ToolChain"];
[label setBackgroundColor:[UIColor blackColor]];
[label setColor:[UIColor whiteColor]];
UIView *mainView = [[UIView alloc] initWithFrame: [UIHardware fullScreenApplicationContentRect]];
[mainView addSubview: label];
[mainView becomeFirstResponder];
[window orderFront: self];
[window makeKeyAndVisible];
[window setContentView: mainView];

int main(int argc, char *argv[]) {
int returnCode;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
returnCode = UIApplicationMain(argc, argv, [HelloToolChain class]);
[pool release];
return returnCode;

Monday, May 5, 2008

iPhone1,1_2.0_5A258f_Restore.ipsw decrypt method

Steps to decrypt the iPhone firmware 2.0 beta 4 (build 5A258f) and extract the files from ramdisk and rootfs
1. Decompress firmware (using unzip command)
2. Decrypt ramdisk (using dd command)
3. Extract rootfs decryption key (using strings command)
4. Decrypt rootfs (using vfdecrypt utility)
5. Extract important files (for Mac just double click the decrypted dmg file, for windows use PowerISO to open)

$ md5 iPhone1,1_2.0_5A258f_Restore.ipsw
MD5 (iPhone1,1_2.0_5A258f_Restore.ipsw) = f7a2937c32615545ba339c330356d9ad

Run these commands to get the ramdisk of iPhone firmware 2.0 beta 4 (build 5A258f)
$ unzip -o iPhone1,1_2.0_5A258f_Restore.ipsw 018-3587-8.dmg
$ echo `hexdump -s12 -n4 -e '"%d\n"' 018-3587-8.dmg ` / 32 | bc

The output is 610816 which will be used for the next command

strip off the first 32 bytes (0x20) and remove the trailing certificate information
$ dd if=018-3587-8.dmg of=018-3587-8.ramdisk.dmg bs=32 skip=1 count=610816 conv=sync

The baseband is in the following folder of the converted ramdisk (018-3587-8.ramdisk.dmg) mounted image

Run these commands to get the decrypt key of iPhone firmware 2.0 beta 4 (build 5A258f)
$ unzip -o iPhone1,1_2.0_5A258f_Restore.ipsw 018-3587-8.dmg
$ strings 018-3587-8.dmg | egrep "^[0-9a-fA-F]{72}$"

The decrypt key is

Run these commands to decrypt the rootfs of iPhone firmware 2.0 beta 4 (build 5A258f)
$ unzip -o iPhone1,1_2.0_5A258f_Restore.ipsw 018-3585-6.dmg

$ ./vfdecrypt -i 018-3585-6.dmg -o decrypted20b4.dmg -k 198d6602ba2ad2d427adf7058045fff5f20d05846622c186cca3d423ad03b5bc3f43c61c

For Mac OS, you need this (universal binary for PPC and Intel)

For windows OS, you need these

Here is the shell script to implement the above procedure and support the previous 8900 decrypt method in Mac OS X

if [ $# -lt 1 ]
echo "usage : $0 iPhone1,1_2.0_5A274d_Restore.ipsw"
exit 0
if [ -f "$IPSWNAME" ]
rm -f Restore.plist
unzip -o $IPSWNAME Restore.plist > /dev/null 2>/dev/null
if [ -f Restore.plist ]; then
DEVICECLASS=`defaults read $PWD/Restore DeviceClass`
PRODUCTVERSION=`defaults read $PWD/Restore ProductVersion`
BUILDVERSION=`defaults read $PWD/Restore ProductBuildVersion`
RESTORERAMDISK=`defaults read $PWD/Restore RestoreRamDisks | awk '/User/ { split($0, line, "\""); printf("%s\n", line[2]); }'`
SYSTEMRESTOREIMAGE=`defaults read $PWD/Restore SystemRestoreImages | awk '/User/ { split($0, line, "\""); printf("%s\n", line[2]); }'`
unzip -o $IPSWNAME $RESTORERAMDISK > /dev/null 2>/dev/null
FILEFORMAT=`hexdump -n4 -e '"%c%c%c%c\n"' $RESTORERAMDISK`
if [ "$FILEFORMAT" == "8900" ]
DECRYPTKEY=`strings $RESTORERAMDISK | egrep "^[0-9a-fA-F]{72}\$"`
if [ "$DECRYPTKEY" == "" ]; then
RAMDISKLENGTH=`hexdump -s12 -n4 -e '"%d\n"' $RESTORERAMDISK`
dd if=$RESTORERAMDISK of=$DEVICECLASS$PRODUCTVERSION$BUILDVERSION.stripped.dmg bs=512 skip=4 count=$RAMDISKCOUNT conv=sync > /dev/null 2>/dev/null
openssl enc -d -in $DEVICECLASS$PRODUCTVERSION$BUILDVERSION.stripped.dmg -out $DEVICECLASS$PRODUCTVERSION$BUILDVERSION.ramdisk.dmg -aes-128-cbc -K 188458A6D15034DFE386F23B61D43774 -iv 0 > /dev/null 2>/dev/null
dd if=$RESTORERAMDISK of=$DEVICECLASS$PRODUCTVERSION$BUILDVERSION.ramdisk.dmg bs=512 skip=4 conv=sync > /dev/null 2>/dev/null
RAMDISKLENGTH=`hexdump -s12 -n4 -e '"%d\n"' $RESTORERAMDISK`
dd if=$RESTORERAMDISK of=$DEVICECLASS$PRODUCTVERSION$BUILDVERSION.ramdisk.dmg bs=32 skip=1 count=$RAMDISKCOUNT conv=sync > /dev/null 2>/dev/null
DECRYPTKEY=`strings $DEVICECLASS$PRODUCTVERSION$BUILDVERSION.ramdisk.dmg | egrep "^[0-9a-fA-F]{72}\$"`
if [ "$DECRYPTKEY" == "" ]; then
echo "Decrypt failed : $IPSWNAME"
unzip -o $IPSWNAME $SYSTEMRESTOREIMAGE > /dev/null 2>/dev/null
./vfdecrypt -i $SYSTEMRESTOREIMAGE -o $DEVICECLASS$PRODUCTVERSION$BUILDVERSION.decrypted.dmg -k $DECRYPTKEY > /dev/null 2>/dev/null
echo "Invalid ipsw file $IPSWNAME"
if [ "$DDONE" == "1" ]; then
echo "Job Completed!!!"

If you find this info useful, please consider to $1 by clicking the Donate button.

iPhone PNG collections

see here

and here

Xcode workspace

In order to use the Xcode workspace more efficiently, these are the additional guides as most of the times, a programmer will work on the text/code editor

(1) Use the View -> Zoom Editor in
when you select a source file e.g. main.m

(2) Use split button (grey square on the right) to create text/code editor window to create additional text/code editor view
when you are editing the source file

(3) Use pragma marks in your code, so that you can jump quickly to your code in the text/code editor window using the navigation bar

#pragma mark -
#pragma mark PreferencesTable Datasource Methods
// MARK:
// TODO:
// !!!:
// ???:

(4) Highlight the identifier and press "command+ double click" to jump definition

(5) use shortcut key "esc" for code completion

(6) View -> Text -> Wrap Lines

(7) Use code folding in text/code editor

Please goto Help -> Xcode workspace guide in Xcode environment for details on how to perform these functions