Cross Platform Mobipocket Reader Hack
From Projects
NOTE: This hack is effectively dead since iRex took down access to the iLiad image files and modified their sources so they won't run on anything but the iLiad. Sorry, it was fun while it lasted.
However, don't hesitate to contact me if you want to discuss other options (hack [at] saudette.net).
Contents |
Introduction
Please read the Disclaimer below before proceeding with this hack.
The problem I am addressing with this hack is the lack of a usable Mobipocket Reader for several unsupported platforms (GNU/Linux, *BSD, *NIX, Mac OS X, etc). I recently found that the iRex_iLiad runs a Mobipocket Reader written in Java, and this hack describes how to use this reader on any Java capable platform.
I have successfully tested this hack on GNU/Linux (gNewSense), Mac OS X (10.4.9), and Windows XP SP2.
Best of all, this works with both encrypted (DMR'ed) and non-encrypted Mobipocket books!
If you have any questions or comments, please contact me (hack [at] saudette.net).
Steps
The steps in this hack assume a GNU/Linux platform, and basic knowledge of GNU/Linux system administration.
Obtaining the Software
As I point out in the Disclaimer below, I don't have the right to distribute the Mobipocket Reader software, but I can tell you where to get it.
Start by downloading the iLiad restore image from the iRex developers website: cf-card-contents.zip (26mb)
Unzip the downloaded file:
unzip cf-card-contents.zipGunzip the file
app.image.gz:
gunzip app.image.gzThis gives you a file
app.image, which is just a
dd'ed image of the root filesystem of the iRex iLiad.
Mount this image:
mkdir /mnt/iliad mount -o loop -t ext2 app.image /mnt/iliad
Get the files we need from this mounted image:
mkdir /opt/mobipocket (or wherever you want) cp /mnt/iliad/home/intent/*.jar /opt/mobipocket
Unmount the image:
cd /opt/mobipocket umount /mnt/iliad
Now you can breathe easy, the hard part is over.
Preparing Your System
There are a few things we need to hack on your system before you can run Mobipocket Reader for the first time. I stress that these hacks are on your system because we are in no way modifying the Mobipocket or iLiad software.
First, we have to create some directories that Mobipocket Reader is expecting to exist:
mkdir -p /opt/mobipocket/ROOTDIR/mnt/free mkdir -p /opt/mobipocket/ROOTDIR/proc/sysset
This is where things get a little iffy, and I must choose my words carefully.
Put your system's MAC address in this file:
echo -n "XXXXXXXXXXXX" > /opt/mobipocket/ROOTDIR/proc/sysset/euid
WARNING: The MAC address used in this example is invalid and should not be used on your system. This file MUST contain YOUR system's MAC address in order to ensure that a unique Mobipocket PID is generated for the Mobipocket Reader. You then register this PID with Mobipocket in order to read their encrypted (DRM'ed) books.
Even if you don't want to read the encrypted (DRM'ed) Mobipocket books, you still need to create this file with your MAC address, otherwise, Mobipocket Reader won't start.
The first time you run this Mobipocket reader (it's coming, be patient), a file is generated containing your Mobipocket PID:
cat /opt/mobipocket/ROOTDIR/mnt/free/Mobipocket_PID.txt
Lastly, if you don't have Java installed, do it now. I used version 1.5.0_12 from Sun.
Running the Software
Now get yourself a Mobipocket book to test this out with. Mobipocket and Fictionwise both have a number of free, unencrypted books in Mobipocket format.
Run this command to start Mobipocket Reader:
java -classpath MobipocketCoreReader.jar:kxml2-2.3.0.jar:irex.jar com.irex.mobipocket.reader.IrexReader file.prc
Where file.prc is the name of the Mobipocket book
Assuming everything goes well, you will have some output on the console and hopefully a Java GUI will pop up with your book displayed! If not, try looking at the Troubleshooting section of this tutorial.
Using the Software
Right off the bat, you'll notice there are no controls for this reader.
This is what I've learned from trial and error:
Key Commands:
- Page-Down - next page
- Page-Up - previous page
- Home - goto the first page
- F1 - jump 5 pages forward
- F2 - jump 5 pages back
- F4 or F5 - sometimes kill the program, sometimes not
All the other standard Mobipocket features (increase font, decrease font, etc) are controlled through a UDP socket running on port 50079. Very interesting. Here are the socket commands I've figured out so far.
Socket Commands:
- 0,0,x - change to page number
x
- 6,11,0 - increase font
- 6,12,0 - decrease font
- 6,63,0 - back (after you follow a link, this takes you back)
You can pickup on some of these commands by looking at the console. I wrote a quick UDP program for running through all the x,y,z commands, and observed what happened. Some crashed the reader, so play at your own risk.
Trying It All Together
Some scripts and tools to make using the software a little easier.
Here is a simple (poorly written) driver program for issuing the socket commands explained above: MobipocketDriver_v3.zip. Feel free to improve this program and make it more usable. Contact me with any contributions (hack [at] saudette.net).
Simple shell script to start my driver program along with the Mobipocket Reader:
#!/bin/sh
JAVA="java" # Currently only 0 (off) and 1 (on) DEBUG="1"
# Take the first argument as the Mobipocket book you want to read # Pipe the output from Mobipocket Reader to MobipocketDriver so it # can handle page numbers and console output control $JAVA -classpath MobipocketCoreReader.jar:kxml2-2.3.0.jar:irex.jar com.irex.mobipocket.reader.IrexReader $1 | $JAVA MobipocketDriver $DEBUG
Notice how the debug console output from the Mobipocket Reader is being piped into my MobipocketDriver program. This is how I get current page information. It's a hack, but it works.
Troubleshooting
- Look for the obvious, is there something on the console telling you what went wrong? There is plenty of good information on the console.
- If you get a stack trace, your version of Java might not be compatible. I know the "GNU interpreter for Java bytecode" (gij) wasn't able to run the Mobipocket Reader, and I'm not sure about anything other than the version of Sun's Java that I used (1.5.0_12).
- If the page shows up blank, the book might be corrupt. Try another book. If the book was encrypted, you might not have your PID right. You need to re-download any Mobipocket books after registering your PID with Mobipocket.
- Sometimes, when you change font sizes, the screen goes white, just change the font size a few times to get it back.
- As far as I can tell, you only run one instances of the Mobipocket Reader at a time because it tries to create a UDP socket on port 50079.
- Sometimes it helps to restart the program a number of times. Seems that there's a race condition that causes it to not respond to any input.
Disclaimer
I can not distribute this Java based Mobipocket Reader software directly, as I do not have the right to distribute this propriety software. However, it is well within my rights to tell people where to get this software, and how to use it. I have taken special care not to subvert any DRM (Digital Restrictions Management) or copy protection mechanisms associated with the Mobipocket format, as this would be in violation of the DMCA (Digital Millennium Copyright Act).
I do no condone the theft of any copy-righted material. Please buy books if you want to read them, or better yet, use and support your local library.
I am not affiliated with Mobipocket or iRex Technologies and any trademark or rights are reserved by each respective company.