And we’re back

May 6th, 2008

Sorry to those who tried to visit us this morning, we had a little bit of downtime. Thankfully, things seem to be functional again.

Admittedly, things have been quiet on our end of the wire these last few weeks. I’ll see if I can use a cattle prod to coax the others into posting what they’ve been up to.

As for me, I’m finishing up my last two final exams here at Rensselaer Polytechnic Institute, and I plan on spending some time in the coming weeks getting comfortable with iPhone OS development and back into the groove of coding for OS X. Last year, Jon, Joe, and I shot ideas back and forth for some consumer products, so I think I’ll go over the list and see what’s worth fleshing out.


Review of Vista SP 1

March 19th, 2008

The Internets are abuzz with the news that Microsoft has finally released the first service pack to its widely successful Windows Vista, just one year (plus change) after it first hit retail store shelves.

As a user of Windows Vista Ultimate, I watched the service pack through its beta period with interest. As I’ve mentioned before, Windows and I don’t always see eye-to-eye, so I decided it best to refrain from installing an unstable, pre-release quality operating system on my production machine — a MacBook Pro.

So, I grabbed the Service Pack 1 updater from Microsoft. Weighing in at over 400 MB, the download took roughly an hour to complete. I giddily started the installation at a quarter past 11 PM; after a few reboots during the install process, I was greeted with a fresh view of Windows:

It isn’t often that a 255 by 139 pixel screenshot conveys so many layers of information. Your eye might first be drawn to the third line of text, suggesting that I have pirated Windows. Not so — in fact, my cell phone shows that I placed a 6 minute, 17 second call to Microsoft’s activation center at 8:50 PM, when I activated Windows for the nth time. The update seems to have deactivated my install; I haven’t tried to activate for the (n + 1)th time to see if it will work.

Second, you might notice that the time is 3:06 AM. That’s right — it took four hours to get me back into Windows. Consider that a fresh Windows Vista install takes around 45 minutes (if I remember correctly); OS X takes around 20. Never mind why I’m up at 3 AM on a school night, four hours is a ridiculous amount of time for a system update.

Third, the well-informed reader will note that the build number in the screenshot, 6000, does not match the build number of Windows Vista SP 1, which is 6001. That’s right. After four excruciating hours, the install failed — with no particularly informative error message. I can’t find the exact error number in my Windows logs, but there are thousands of entries at 3:01:37, all reading

Windows Servicing failed to complete the process of setting package
Package_82_for_KB936330~31bf3856ad364e35~x86~~6.0.1.18000 () into Staged(Staged) state

Finally, we note that the screenshot has a hideous red outline. I couldn’t figure out how the equivalent of print screen on my MacBook Pro keyboard, so I used the “Snipping Tool.”


Hijacking JavaScript Functions

February 11th, 2008

I spent several hours last week tracking down an obnoxious bug in WebKit JavaScriptCore’s Function.toString() implementation where multiple var declarations on a single line would get grouped with parentheses (Radar, Trac, Bugzilla). The incredible WebKit team made a working patch within 23 hours of my report, kudos to them.

Joe and I very much enjoy hijacking code. While this may become a recurring theme on this blog, right now I’m just going to share how to do it in JavaScript. Let’s say one of the .js files included from your page declares the function foo() as

function foo() {
    var x = "spinach";
    alert(x);
}

If you run foo(), it will obviously display a dialog reading “spinach”. But for some reason or other, you need it to say “eggplant” instead, but you can’t alter the original code. Furthermore, pretend we’re in a situation where it’s inconvenient to reimplement the function. No problem — we can just hijack it and modify the code:

// First, get the code to the function
// Here we strip off the "function foo() { ... }"
var c_foo = foo.toString().replace(/^[^{]*{/|>, '').replace(/}$/|>, '');
 
// Now perform whatever modifications we need
c_foo = c_foo.replace('spinach', 'eggplant');
 
// Now overwrite the function with a new Function object using our code
foo = new Function(c_foo);

Now whenever foo() is called, it will use our modified code. Of course, in this simple example we could have just redeclared foo(), but this becomes far more feasible with more complex code.

As an interesting aside, when you call toString() on a function, it’s not actually printing out the function as it was declared (hence, the bug I mentioned at the top of the post). In the case of JavaScriptCore (used by Safari), a function is broken into a graph of various nodes representing keywords, loops, strings constants, and so on. When you convert the function to a string, it traverses the graph and constructs a more familiar representation of it. As such, it’s kind of a handy way to reformat obfuscated (or just hard to read) code, but you’ll lose commenting.


Boot Camp Drivers from OS X

January 17th, 2008

Windows and I don’t have a very friendly relationship. Over the course of a year, I might reinstall my copy of Windows XP SP 2 half a dozen times because, inevitably, some .dll, .sys, or .act file has managed to ruin it for everyone by going and getting corrupted. This has happened so many times that I now have to call Microsoft every time I want to activate Windows (twice for each install, since I also use VMWare) and listen to a bot read off a thousand-digit number in groups of five.

The most recent argument between Windows and me happened on Tuesday; an annoying freeze led to a nightmarish six hour battle. Sadly, Windows emerged the victor by dying completely and thoroughly. Time for a reinstall, which means tracking down all of the .dll, .sys, and .act files that I need…

As you may know, Boot Camp comes with drivers to increase compatibility with Apple hardware. During the betas, they were stored in a disk image inside the application bundle; in Leopard, the drivers are stored on the Leopard install DVD. The DVD is a hybrid disc, meaning it has partitions for both Windows and Mac OS X. By default, OS X will only mount the HFS+ partition (containing the installer), and Windows will only mount the ISO 9660 partition (containing the Boot Camp drivers).

So if you don’t have your install disc and no writable DVD-DL is within arm’s reach, is it possible to get OS X to mount the ISO 9660 partition from the ADC disk image and copy the drivers to a thumb drive? Indeed it is.

(As an aside, you can view the partition map of the disk image by running hdiutil pmap2 leopard_9a581_userdvd.dmg)

If we use hdiutil to attach the image as a block device, it’s possible to get the ISO 9660 part to mount by using the cd9660.util program.

$ hdiutil attach leopard_9a581_userdvd.dmg -nomount
expected   CRC32 $0108CBDC
/dev/disk3          	Apple_partition_scheme
/dev/disk3s1        	Apple_partition_map
/dev/disk3s2        	Apple_Driver_ATAPI
/dev/disk3s3        	Apple_HFS
$ mkdir /Volumes/Drivers
$ /System/Library/Filesystems/cd9660.fs/cd9660.util -m disk3 /Volumes/Drivers

And when you’re done:

$ umount /Volumes/Drivers
$ rm -Rf /Volumes/Drivers

That’s all for today. If you need me, I’ll be on the phone with Microsoft…


MacWorld Follow-up

January 15th, 2008

On the first, I posted some unfounded rumors about QuickTime updates during MacWorld. As promised, now that the keynote is over I’ll analyze how accurate my predictions are. (Since I’m trying to build a good track record, I will conveniently itemize those predictions in such a way that it looks like I did better than I really did.)

  1. New version of QuickTime
    Yes! After the keynote, QuickTime 7.4 was released via Software Update.
  2. Free QuickTime Pro
    No! The Apple Store still lists the upgrade at $29.99.
  3. Free MPEG-2 Component
    No! It retains a $19.99 price tag.
  4. VC-1 Support
    Sort of! While QuickTime itself did not gain VC-1, this was apparently introduced in the Leopard DVDPlayback framework. Run strings -3 /System/Library/Frameworks/DVDPlayback.framework/DVDPlayback | grep “VC1″ for some evidence of this.
  5. Acquisition of Telestream
    No! Well, at least there have been no announcements of this nature.
  6. 64-bit Compatible QuickTime APIs
    Sort of! Apparently I need to brush up on my QuickTime APIs. Apple has been doing this with QTKit, which offers 64-bit wrappers to 32-bit QuickTime functions. I’ll count this one against me for ignorance.
  7. 64-bit QuickTime for Windows
    Yes! iTunes 7.6 now supports Windows Vista 64-bit, according to the requirements, and properly supports syncing with iPhones.
  8. Keynote’s Overall Digital Media Theme
    Yes! The MacBook Air, AppleTV updates, and iTMS movie rentals were all part of this theme.

So there we have it! I got 3.5/8 predictions correct which gives me a higher prediction accuracy than ThinkSecret will have all year.


Clocks with Google Chart API

January 7th, 2008

Have you seen Google’s Chart API? Send it a formatted GET request and it will spit out a pretty graph. The API is fairly powerful, supporting dozens of options and five different chart types, including Venn diagrams and pie charts.

What you may not know is that there is an undocumented “clock” chart type. It’s used by Google when you do time zone queries, such as time in ithaca, ny. The little icon that appears next to the result actually displays the correct local time; what’s more, the clock border is silver for night and gold for day. Here’s the URL of the image:

http://www.google.com/chart?chs=40×30&chc=localtime&cht=cf&chd=s:Wp&sig=-r0X-_m3bpzbNNulLXfJyr7SDTI

(Pay no attention to the fact that the URL is expired and go grab yourself a fresh one with a query like the one above.)

The cht (chart type) parameter is cf, likely short for “clock face.” The data, above Wp, is the encoded time; according to the encoding spec, W is 22 and p is 41, so the time is 10:41 PM. chc is not a documented parameter, and only seems to apply to the clock chart type.

But wait, something’s amiss — if you try to fiddle with the URL above, you’ll notice you can’t change any of the parameters or you get back a 400 Bad Request error. What’s the deal? It looks like Google has added a cryptographic signature in the sig parameter; if you change the URL string, you invalidate the signature and Google refuses to generate the clock.

Fear not, you can still generate your own clocks — just drop the sig and chc parameters and everything will work just fine. Note that the clock image is just a 40×30 bitmap; you can’t scale it or change the background.


Another year, another keynote

January 1st, 2008

Well, it’s finally January 1st, a day that I celebrate by writing the date wrong, a sacred tradition that lasts through mid-July. Today also means that my birthday is just around the corner, and friend of the family Steve Jobs is out picking a present for me.

Two years ago, he announced the first Intel-based MacBook Pro and iMac; for my eighteenth birthday, he unveiled the Apple TV and a lesser-known handheld device called the iPhone. So what does Uncle Steve have in store for me this year?

The rumor sites are forecasting the usual design refreshes and new products and services (Apple phone, touchscreen iPod, Newton rebirth, ultra-portable laptop, …). I’m not in-the-know, so I can’t make any authoritative comments on these things, but I certainly won’t pass up the fun of generating new baseless rumors in authoritative tone:

Apple will be releasing an update to QuickTime Player which will deliver numerous new features. To start, Apple will remove the license fee for Pro (on Mac, at least). This comes after we saw fullscreen mode lose its Pro status in July, while other Pro-only features have shown up iLife and other free programs (see Siracusa’s rant circa 2005). The MPEG-2 Playback component will also become free, and will be included as part of the main QuickTime package.

Moving on to more important matters, Jobs will announce support for a new codec: VC-1, a standard of both Blu-ray, which Apple has backed since 2005, as well as rival HD-DVD; if Macs are to be equipped with either flavor come the 15th, VC-1 is a necessity. To this end, Apple may announce the acquisition of Telestream, which authors the Flip4Mac WMV playback suite. Historically, Apple revealed its Pixlet codec at WWDC 2003, and showed off H.264 support at NAB 2004.

While it may not be announced at MacWorld, developers will be happy to see the QuickTime APIs become fully 64-bit compatible, with a large number of functions becoming deprecated in favor of more modern Core Video equivalents. This will serve as a segue into more enhancements as LLVM (another Siracusa hat tip) allows playback to be more finely tuned to the OS and hardware. It remains to be seen how Windows will be treated; 64-bit users have long suffered without compatible versions of QuickTime and iTunes, but the API changes will push the Mac and Windows branches further apart in terms of functionality.

The changes to QuickTime will be part of the keynote’s overall digital media theme, although it will inevitably be a minor player as movie rentals, iTunes’ expanded DRM-free offerings, and others take center stage.

2003 was “the year of the notebook,” 2005 was “the year of high definition video,” 2007 was “one of the most exciting new product years in Apple’s history.” Based on this trend, I can safely conclude that 2008 won’t be the year of anything, but 2009 should be a real blast.

I’ll see you in the near future when I reveal disturbing facts about cell phone text messaging. Be sure to tune your feed reader to my frequency to get up-to-the-minute updates.


Toys for Christmas

December 25th, 2007

Dear readers, gather ’round, we’ve got something to share:
Click on Toybox above and see what’s in there.
We’re sure you’ll enjoy at least one of these things,
Our greatest inventions, fit for you kings.

There’s one to label your episodes of M*A*S*H,
And another, a CGS private function stash.
And a third, if you’re not yet licking your lips:
We’ll give you a way to make Dashboard web clips!

We’ll be away for the week, but please let us know
How you all liked the teasers we’ve had to show.
Even if you didn’t, post a comment anyways.
Well, we’re out — Happy Holidays.


Am I drunk?

November 8th, 2007

A few weeks ago I wrote about a hidden preference pane that ships with Leopard, Archives.prefPane.

As an anonymous reader pointed out this afternoon, the post made an unexpected shift when I put up a screenshot of DiskImages.prefPane and continued to discuss it rather than Archives.prefPane. Apparently I was more than a little absent-minded — even the file name of the image is “archiveprefpane.png”!

I’ve corrected the old post, so I’ll leave you with the assurance that I’ll pay closer attention next time!


Hidden Archive Settings in OS X

October 29th, 2007

If you were to run find / -iname *.prefPane on your freshly installed copy of Leopard, you might notice this show up in the results:

/System/Library/CoreServices/Archive Utility.app/Contents/Resources/Archives.prefPane

Installing this preference pane allows you to change settings relating to archive creation and expansion handled by Archive Utility (formerly BOMArchiveHelper).

This joins the other known hidden prefPane introduced in 10.4, DiskImages.prefPane (hat tip to Mac OS X Hints for beating me to the punch by a year and a half).