Categories
Explained

Quicksilver Trick: Strip Clipboard Formatting

It’s been a while since I did a Quicksilver one-off, but with all the [recent](http://lifehacker.com/software/quicksilver/hack-attack-a-beginners-guide-to-quicksilver-247129.php) [crazy](http://www.43folders.com/2007/03/05/tms-comma-trick/) [hype](http://www.lifehacker.com/software/quicksilver/hack-attack-the-quicksilver-video-extravaganza-250949.php) for QS beginning once again, it seems like a good time. Plus, this literally just happened.

Do you know what my biggest pet peeve in OS X has been? It’s that it’s too smart for it’s own good.

Let me be more specific: when you copy something to the clipboard, it almost always holds the rich text formatting of the app you copied it from. If you paste it into another rich text app, you end up with something that looks like this:

This, undeniably, **sucks**. Yes, there are a few times where you want the format to copy, but this is rarely the case with most apps. I’d say maybe 5% of the time this is useful, and 95% of the time it makes me want to snap my MacBook Pro in half.

My solution to date has always been “copy from source app, paste into TextMate, copy back out of TextMate, paste into target”. I love TextMate, but this is needless abuse of a lovely app.

Was talking to Mikey (he of [Think](http://www.freeverse.com/think/)) this morning, and he explained the issue thusly:

>”It’s a side effect of copying rich text to the pasteboard server. The app copying it doesn’t know you’re going to take it to another app, and the other app doesn’t know where it came from – just that it’s on the pb.”

And then he threw out *his* solution to the problem:

$ pbpaste | pbcopy

And I thought, “well, I could alias that I guess, but then I’ve gotta keep jumping into terminal and typing. And I really want a hotkey for this. You know, like a QS trig…”

Oh. Right.

So, friends, if you too are affected by the horribly crippling brilliance of OS X’s rich text pasteboard, simply make the trigger shown at right. If you don’t know how to do this:

1. Invoke QS.
2. Type Command-‘ (that’s a single quote) to go to the Trigger preferences.
3. Create a new trigger by clicking the + button.
4. When the trigger pane drops down, press the period key to enter text mode.
5. Type “pbpaste | pbcopy” into the text field. (Or, for the slightly meta, you can copy and paste it from this post.)
6. Press tab – select “Run Command in Shell” as the action if it’s not already selected.
7. Save the trigger and then assign a hotkey as normal.

I bound mine to Shift-Option-Command-V, since I’ll tend to hit it right before I paste something out. You can choose whatever you find most comfortable.
In case it’s not clear, this takes the contents of your clipboard and pastes them right back into the clipboard. Because this is being run as a shell command, the formatting falls right off.

If you’re entirely unfamiliar with triggers, you might be in need of a read of my [trigger tutorial](https://vjarmy.com/archives/2006/01/quicksilver_gold_trigger.php).

Thanks again to [Mikey](http://www.mikey-san.net/) for his help in turning the lightbulb on over my head.

FIRST EDIT: I’ve been reminded (thanks, Suw!) that you need to have the Terminal Plugin installed to have access to the Run Command In Shell action. Also, note that this trigger does *not* paste for you; it merely strips off formatting while still in the clipboard.

Categories
Explained

Dissecting iPod Games

Over at [random()type](http://www.randomtype.com/?p=190), someone noticed that dropping an iPod game onto Stuffit Expander results in a decompressed bundle.
I have purchased six iPod Games at this point, so I figured some poking around may be useful for the sake of science.

The files are compressed using standard ZIP compression.

# Standard Files

There are a handful of files that are common across all games:

`/Executables/`

This folder contains two files for each game: a .bin file, and a .sinf. The name of the bin file is of the following construction:

`Gamename_PlatformID_PlatformVersion_BuildID.bin`

The name of the sinf file is exactly the same as that of the bin file – include the .bin extension – with an extra .sinf extension.

The .bin is the executable, as shown in the manifest below; the .sinf file appears to have something to do with the FairPlay DRM as my name is recorded in the file.

Nothing useful comes out if you try and run strings on the binary.

`/iTunesArtwork`

This is presumable the “album art” photo that shows up when you view a game in iTunes. [Ben Sinclair noted](http://bensinclair.com/article/whats-inside-an-ipod-game) that it’s a JPEG file.

`/iTunesMetaData`

This file contains resource-fork style data with the metadata that shows up when you get info on a game in iTunes.

`/Manifest.plist`

The manifest file describes all of the files internal to the bundle. All files get a Digest (not md5, can’t determine the algorithm), a Path, and a Size.

There are two extra plist keys used for the binary: one called *DRM* (set to true) and one labeled *Verify* (also set to true).

At the end of the manifest is an array with the key of “Platforms”. This contains keys that we’ve seen before – *BuildID*, *PlatformID*, *PlatformVersion*, and *Size* – as well as ExecutablePath (specifies the binary) and *LaunchingArtwork* (specifies the file to display while the game loads).

`/Manifest.plist.p7b`

This is the PKCS #7 format certificate for the Manifest.plist file. This is undoubtedly to check the integrity of your Manifest.plist. Certificate is signed by the [Apple Root CA](https://www.apple.com/certificateauthority/).

`/Resources/`

The Resources folder is used locally by iTunes to show the help screen when you view it in your library. There is typically a JPEG, which is what displays to the user, as well as an XML file (Description.xml) which basically sets the layout.

Resources contains separate folders for each localization. Note that all the localizations are listed in the manifest, so trying to remove them would probably break your game if iTunes is actively checking the bundle integrity.

# Bundles Tidyness, Audio, and Images

It’s a crap shoot. Some games have very tidy bundles – Apple’s two games in particular – and some are a mess, like Mini Golf.

All of the in-game audio tends to be as a .wav or a .m4a, and there’s no copy protection on them. If you’re dying to hear that Tetris remix somewhere outside the game, well, there you go.

Other files are in a wide range of formats – ipd, pix, raw, lcd5, ro, anm, and so on.

# Strings

## Cubis2

Cubis2 has localized strings files, but without delimiters, it’s difficult to tell what they’re for.

## Mini Golf

Mini Golf’s bundle is a mess because all the course data is loose in the root folder. This includes localizations like hole names. Yeesh.

## Tetris

Tetris has Strings.dta, which is tab delimited and contains all the strings for all the languages. Very easy to read, and amusing to read the rules of Tetris in multiple languages.

## Texas Hold Em

This one was a lot of fun.

Holdem has a Localization folder, and three files full of strings. Apparently there are a number of secret characters – two aliens (one “with a crazy inappropriate name” of BUTCH, on “with big mouth” named MOUTH), three robots, and five dogs – a rottweiler, a bull mastiff, a pug, a bulldog, and in what may be the funniest easter egg I’ve seen from Apple in a while, a chihuahua named BERTRAM. There’s also a secret cheat menu as evidenced in strings.strings,

Also in strings.strings are a list of locations in the game, including an Apple Conference Room, The Dog House, and Zythlgrak (in the Alpha Centauri System, natch).
There’s also a strings file for the tutorial, which includes a number of strings with graphic placement data named things like “DO NOT LOCALIZE ME 16”. This is additionally funny since all of them are preceded with a comment of “do not localize this”. Perhaps I should localize it.

There’s also a string titled “YOU LOST POT”. Snicker.

## Vortex

Vortex has a text.strings file that mentions a cheat mode. Oddly, it’s not constructed at all in the same way as Texas Hold Em, and is considerably less fun.

## Zuma

All of Zuma’s text is in graphic form, so no stringy goodness.

—-

# Summing Up

* Modifying the games is difficult at best, if not impossible, because of the checksumming of every file in the bundle, and then the certificate against the manifest.
* Game resource files, particularly audio, aren’t obfuscated and can be extracted successfully.
* Homebrew is probably an impossibility at this point because of the expectation of a signed cert from Apple.
* The fact that there are platform identifiers in the plists makes me wonder what Apple’s future plans entail. Maybe this would just be for later iPod revisions, or maybe they’re just looking forward. Still, quite interesting.

If you find anything else interesting, let me know, and I’ll add it to the post.

Categories
Explained

SK3: Screenshots Shortcut

SK3: Screenshots Shortcut

Shift-Menu-Right Shoulder takes screenshots. Whee!