Many thanks to JSWolf for helping me see what's going wrong with the 0.02 (& my 0.03 patch version) of the MobiDeDRM script.
Since I now have examples of files that work with 1 but not 2 and 2 but not 1, and a little more experience with the Mobipocket file format, I think I've got to the bottom of the problem, and so I now have a new set of patches for the original 0.02 code. Here's the instructions for my new patch, line by line.
Also thanks to others who helped find a problem with the 0.04 patch version. These instructions now convert 0.02 to 0.05.
change line 165:
print "MobiDeDrm v0.02. Copyright (c) 2008 The Dark Reverser"
print "MobiDeDrm v0.05. Copyright (c) 2008 The Dark Reverser"
just so that you don't get confused at the command line.
Add a tab and make changes to line 136:
[tab][tab]extra_data_flags, = struct.unpack('>L', sect[0xF0:0xF4])
to make it
[tab][tab][tab]extra_data_flags, = struct.unpack('>H', sect[0xF2:0xF4])
After line 135:
[tab][tab]records, = struct.unpack('>H', sect[0x8:0x8+2])
add in the following three lines
[tab][tab]mobi_length, = struct.unpack('>L',sect[0x14:0x18])
[tab][tab]extra_data_flags = 0
[tab][tab]if mobi_length >= 0xE4:
(note that tricky comma after the first instance of mobi_length)
And finally, after line 63:
[tab][tab]bitpos, result = 0,0
add in the following two lines:
[tab][tab]if size <= 0:
These changes should mean that any file that works with either 0.01 or 0.02 will work with 0.05. I'd love to hear about any problems.
Originally Posted by JSWolf
Actually, I've come across a couple of eBooks that your mod caused to actually break the eBooks so that it causes Mobipocket Reader to crash every time you try to view it.
I used MobiDeDRM.py version 0.01 on those eBooks without a hitch.