hashed

Despite earning my degree in computer engineering, I haven’t done anything useful with assembly language since I was a strapping young idealistic lad convinced that compilers lie along the road to inefficiency. Much has changed. Heck, I write Java code for a living now — pretty much the opposite of efficient. I have to have a gig of ram just to run that sucky ant program.

While hacking my MP3 player, I discovered that the filesystem uses hashing to quickly lookup file names, which brought up the question of which hash function it uses. While I suppose one could reverse the hash function knowing a very large set of inputs and outputs, I decided it would probably be much more expedient to just put my atrophied x86 asm knowledge to work for me.

This turned out to be a lot easier than I thought. It only took about 20 minutes and I never had to step through code in a debugger.

Step 1: Disassemble Windows program for loading files onto the device, including the data segment. Look for the offset of a useful printf format string (“hash is %d, expected %d”).
Step 2: Search disassembly for loading said offset in a call to printf. Not surprisingly, this is right after the computation of the hash.
Step 3: Examine nearby calls for things like shifts and mods (common hashing operations).
Step 4: Relearn the stupidities of the x86 ISA (ecx is a loop counter, eax and edx figure in mysteriously for divides, etc).
Step 5: Convinced that a nearby call is it, reimplement in C and test.

Booyeah.

Good Karma

Just to follow up the earlier post, I officially announce my Karma driver web page, including the kernel patch such as it is. I’ve worked out some more details about the disk so I expect to be able to mount it shortly. Peter from empeg declares it “could be useful.”

Karma

My poor MP3 player is destined to be relegated to the trash heap with all of the other Not-An-iPods. For good reason, really, since I have broken it in several different ways since I’ve had it: first the hard drive failed, then after replacing the unit, I dropped the new one and the scroll wheel broke off, and the battery leads came off the mainboard. I’ve soldered the battery back on and glued the scroll wheel back, so it continues to hobble along. Other than build quality, it is a fine MP3 player: it does OGG and FLAC, gapless, has a decent UI, fits nicely in one’s pocket.

What is most annoying about this device is that you have to use Rio’s software to transfer stuff to it over USB, and this only works in Windows. Otherwise, you are stuck using a Java app over ethernet in Linux which is sloooooooow. It would be nice if you could just use it like any old hard drive. Imagine being able to use a hard drive like a hard drive!

So, armed with the recent purchase of the book Linux Device Drivers, I have set out to reverse engineer this bad boy. It isn’t a straight up mass storage device, but if you poke around on it you can make it enter mass storage mode (also, you can make it reboot). From there, it should be a “simple” matter of using dd and figuring out the file system to make this thing a bit more user-friendly.

It took me a couple weeks of looking at hex dumps, but I’ve got phase one completed. Life is good.

Aug 17 08:09:10 dust kernel: usb 1-2: new high speed USB device using address 2
Aug 17 08:09:10 dust kernel: usb 1-2: Product: Rio Karma
Aug 17 08:09:10 dust kernel: usb 1-2: Manufacturer: Rio
Aug 17 08:09:10 dust kernel: usb 1-2: SerialNumber: 00000000000000000
Aug 17 08:09:15 dust kernel: scsi0 : SCSI emulation for USB Mass Storage devices
Aug 17 08:09:15 dust kernel: Vendor: Rio Model: Rio Karma Rev: 0101
Aug 17 08:09:15 dust kernel: Type: Direct-Access ANSI SCSI revision: 02
Aug 17 08:09:15 dust kernel: SCSI device sda: 39070080 512-byte hdwr sectors (20004 MB)

k-rad

build.ejb.classes:
[javac] Compiling 1337 source files to /home/bob/projects/...

Heh. In other news, I am playing around with greasemonkey. Finally, a use for javascript! I’ve already fixed the brain-dead handling of attachments with MS Outlook’s web interface, where it tells you that PDFs are too dangerous to launch directly, whereas you can click on Word and Excel files with no problems.

And with that I’m off to Ohio this weekend. If anyone can recommend roadside attractions along the PA turnpike, let’s hear ’em. Ok, didn’t think so.

Nonexistent comment

I have a few things in the hopper to post about, but I am really tired and lazy these days. So today I’ll just pretend to be writing in the nonexistent comments section of Ryan’s blog and say that the reason you can’t vote online yet is because it is a ridiculously bad idea. When the robots elect themselves, you’ll see.

Sun Microsystems suck

Can we start over and design the internet so that not everything in the world breaks when there is no reverse DNS?

Anyone else remember when a lame radio show about slashdot was called Geeks in Space? Oh, but I guess since GiS predated the iPod it didn’t have quite the same caché as its flat-white podcast brethren.

This whole word-coinage thing is getting out of hand. Every day some “blogger” “podcasts” “mashups” while “wardriving,” or worse, “warviewing.” WTF? Back in my day we only had thirty-seven words. We would have had thirty-eight but the Kaiser stole our word “twenty.”

Wormy

This is one of the most interesting papers I’ve seen. Some researchers investigated the Witty worm. They decoded the random number generator used by the worm for finding new hosts, and managed to figure out all sorts of things like how many disks a compromised host had, initially targeted hosts, even the machine that injected the worm into the internet. Ed Felten’s description. One of those guys is from G-Tech.

Next stop, prime factorization

Judging from my web server logs, I’ve achieved infinitesimally minor fame by being enshrined in the gallery of stupid XSL tricks for my square root nonsense. Recently, some guy emailed me:

Bob,

I don't know if you are still interested in a set of XSL stylesheets for standard math functions but I wrote several before I found the exslt.org website. I have: Square Root (similar to yours), Log, Log base 10 (calls Log), Sin, Cos.

Bruce

I bow before superior XSL greatness.

Aside: Does paid LJ have some decent search-my-own facility? I find myself having to grep backups from time to time since Google doesn’t index many of my entries.

My illegal computer

My PVR now does HDTV. Sort of. I bought the pre-ridiculous broadcast flag law HDTV receiver card from pcHDTV, before they become a gray-market commodity on eBay. It arrived last Friday in a box containing a brochure about the EFF, which I found a nice touch. Note to self: renew membership for this year.

Last night was the first chance I had to try it out. I downloaded kernel 2.6.12-rc2, compiled it, repeated the process until I figured out which modules I was supposed to use, then dmesg reported success. I proceeded to try to tune the six or seven channels I can receive in my area. I don’t have a real antenna so I used an old pair of rabbit ears that I had. Got locks on 3 or 4 channels, which is good. The signal was too noisy on all of them to actually capture anything, which is bad. I also tried tuning QAM over my (analog) cable with no luck. So I guess I’ll be buying an antenna soon. Then all I need to get is an HD television, a minor detail.

Having finished the issue, I do have to say that MAKE has too many articles of the following form, which is to say more than one: I found myself wondering how to do [some incredibly mundane task] on my [Powerbook|G5|ipod], then I located [overpriced commercial package] and it solved all my problems! What that has to do with making things, I don’t know.