Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 04-16-2012, 05:12 AM   #1
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Cool JBPatch

Version 4.0.0 (2013-04-13)
  • Fix Reader layout and add hyphenation support for .mobi/.azw books (does not apply to KF8/.azw3 books -- see here for an alternative solution for azw3)
  • Change display margins
  • Look up words in all applicable dictionaries, instead of only one
  • Modify "Device Info" page to include JBPatch information
  • Customize reader font sizes (FW 5.1.x; notes for newer firmwares are here)
  • Customize progress display while reading books (FW 5.1.x only)
  • Book Cover View on Home screen and in Collections (FW 5.1.x only)
  • Support all orientations in the Java UI (including upside-down), working for Home Screen, Kindlets, ... (FW 5.1.x only)
  • Password-protect books (FW 5.1.x only)
  • Text-To-Speech on all books, regardless of language or DRM (FW 5.1.x only)
  • Better scrollbars, actually usable with a finger, and working in menus (FW 5.1.x only)
  • Automatically install the developer keys when required (certificate bundle version 2012-10-02) (FW 5.1.x only)
  • Modify Collection Count Behavior, accounting for nested collections (FW 5.1.x only)
  • ... and potentially many more

For instance, here are images showing the hyphenation (animated), the dictionaries patch (animated), the progress bar, and the cover view:
Click image for larger version

Name:	hyphenation.gif
Views:	12217
Size:	79.0 KB
ID:	90081Click image for larger version

Name:	dictionaries.gif
Views:	11163
Size:	71.3 KB
ID:	93570Click image for larger version

Name:	progressbar.gif
Views:	11179
Size:	44.2 KB
ID:	91269Click image for larger version

Name:	coverview.gif
Views:	15614
Size:	84.4 KB
ID:	90133

...and here are a few screenshots of the JBPatch User Interface:
Click image for larger version

Name:	jbpatchui_overview.gif
Views:	15131
Size:	21.2 KB
ID:	89401Click image for larger version

Name:	jbpatchui_conf.gif
Views:	14650
Size:	31.6 KB
ID:	89402Click image for larger version

Name:	jbpatchui_system.gif
Views:	10189
Size:	37.3 KB
ID:	89403

Description:

JBPatch (Java Bytecode Patch) is a framework which allows to replace/modify Kindle functionality, without having to physically modify the files present on the device. Patches are pluggable, meaning that everybody can create modifications, and you can install as many (or as few) as you want. This can only modify Java-based functionality, but that covers 100% of the UI of Kindle 1 - 4, and still about 75% of Kindle 5 (Kindle Touch / Paperwhite). Patches are generally expected to be rather small, and to modify very specific aspects. However, they can in principle be arbitrarily complex -- everything is possible!

So far, only patches for Kindle Touch and Paperwhite have been released. The general approach should work on other models though. If you find this interesting, and could test it on other devices, you're more than welcome to try it out, and to comment here. (UPDATE: thanks to arikfunke, a bare-bones JBPatch now works on the K3!)

Requirements:
  • Kindle Touch, Firmware 5.1.0 - 5.3.2.1, or Kindle Paperwhite, Firmware 5.3.1 - 5.3.4. However, the only firmwares that are actively supported are 5.1.2 (Kindle Touch) and 5.3.4 (Paperwhite). See this post, and the notes further below, for the reasons. To prevent your Kindle from automatically installing a newer firmware, use dsmid's BackDoorLock.
  • Of course, the jailbreak is required.
  • In addition, the user interface requires the Kindlet Jailbreak (mirror: update_k5_ALL_PW_ALL_kindlet_jailbreak_install.bin from prerequisites-all-supported-devices.zip in KUAL thread).
  • If you get a "Your device is not authorized as a Test Kindle" message when opening the UI, install the Developer Certificates Bundle (mirror: update_k5_ALL_PW_ALL_devcerts_install.bin from prerequisites-all-supported-devices.zip in KUAL thread).

Downloads / Source Code:
Download the file attached to this post to get the latest release version, and install as described in the contained README file.

Source code is available from here.

Localizations:
JBPatch is completely localizable, but the download only includes english translations. Translations for other languages can be downloaded from here. Those files are updated hourly if changes to the translations are detected. More information is available in the Wiki.

The abovementioned page only contains downloads for languages that are officially supported on the Kindle Touch. Links to "unofficial" language packs can be found below:
  • chinese (by szfisher)
  • hungarian (by hanog; translations only for the subset of patches supported on FW 5.3.x)

GUI Launcher Integration (KT):
If you wish to access JBPatch from the GUI Launcher, you can use this file. This is not required, just an optional feature.

New Patches:
As said, this is a pluggable mechanism, and you can enable as many patches as you want. Patches can be developed by everyone, but some reverse engineering skills are required. Here are some HOWTOs which walk you through the process of creating a patch: simple, more complex. Note that these are referring to a previous version of JBPatch. For newer versions, slightly more effort is required to accommodate for the UI requirements (but not for the actual patching itself).

Documentation / Contributions:
The primary source of documentation is now this Wiki page. The intention of that page is to consolidate the information contained in this thread in an organized and easily-accessible manner. In other words: everybody is more than welcome to modify the Wiki page and to improve its usefulness, by adding or clarifying topics, or by contributing new patches and localizations.

The Wiki page and this thread are meant to complement each other: think of the thread as the place where ongoing topics are discussed, while the Wiki page serves as a "one-stop-shop" for information. IMO, this merges the best of both worlds: cutting-edge, but sometimes "chaotic" discussions in the forums (chaotic in the sense that information tends to get lost, or difficult to find, as the discussion progresses), plus easily-accessible information on the Wiki. Of course, you are welcome to propagate important changes in the Wiki to this thread, and vice-versa.

Version History and Release Announcements:
Spoiler:

Installation/Update Notes:
  • Don't uninstall previous versions before updating. Just install the new version on top of the older one (but read all of the following notes).
  • If you are upgrading from any version lower than 4.0.0: While this isn't absolutely required, I strongly recommend to uninstall, then reinstall JBPatch.
  • If you are upgrading from a version between 2.2.0 and 3.2.0: no further action required.
  • If you are upgrading from a version between 2.0.0 and 2.1.2: all bundled patches are automatically updated, but you have to re-download any "non-bundled" patches. If you don't know what "non-bundled" even means, you can probably just ignore this notice.
  • If you are upgrading from version 1.3.1 or earlier: please remove all files in the opt/jbpatch/ directory (if it exists) before installing this version.
  • If you experience issues with the user interface after updating JBPatch (or a single patch), your localization files are probably out of date. The easiest way to fix this is to copy the most recent localization files to the device.
  • Update error 3 on installation?
    Spoiler:
    Use the "Update your Kindle" entry from the Settings menu, not the "Restart" one.

Other Notes:
  • Questions: Feel free to post your questions in this thread. However, please try not to ask questions which have already been answered many times before. No, I'm not asking you to read the thousands of posts in this thread, but please read at least the *entire* Wiki page, and use the forum's search function, before asking your question.
  • Patch requests: If you have a proposal about how an existing patch can be improved, or an idea for an entirely new patch, please post them in this thread.
    Unfortunately, because of Amazon's recent policy of aggressively re-obfuscating (almost) the entire framework with every new firmware release, chances that new patches will be developed are... rather small. More information here and here. Sorry, folks. If you want to complain, complain to Amazon.
  • Links: You are free to share and redistribute the JBPatch files in whichever way you please. However, note that the download links provided here are NOT stable links. In other words: DO NOT SHARE DIRECT DOWNLOAD LINKS to the files in this post; instead, link to THIS THREAD.
  • Kindle 3 users: Although not officially supported, JBPatch also works on the K3!

Spoiler:
This is completely off-topic - but since you already clicked on the "spoiler" button, you can as well watch the video, too. I think you'll like it

If you like JBPatch:
I sincerely hope that you find JBPatch useful. If you like the enhancements that it offers to your Kindle experience, you are more than welcome to donate a little something... but don't give your money to me. Please donate for a much more important cause, namely: for a Literacy project in Laos. You will make not only me happy. Thank you!

Make sure to download the correct file for your device!
  • Kindle Touch, Firmware 5.1.x: download *_fw510.zip
  • Kindle Touch, Firmware 5.3.2 or 5.3.2.1: download *_fw532.zip
  • Kindle Paperwhite, Firmware 5.3.x: download *_fw531.zip
Attached Files
File Type: zip jbpatch_4.0.0_fw510.zip (1.27 MB, 2906 views)
File Type: zip jbpatch_4.0.0_fw531.zip (1.21 MB, 4270 views)
File Type: zip jbpatch_4.0.0_fw532.zip (1.21 MB, 3693 views)

Last edited by ixtab; 09-21-2013 at 03:04 PM.
ixtab is offline   Reply With Quote
Old 04-16-2012, 05:14 AM   #2
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
So I have come up with something that I'm pretty excited about.

Note that this is NOT ready for prime time yet (consider it alpha at most), so installation is manual. I have only tested this on Kindle Touch 5.1.0 (because that's the only device I have around).

For the time being, if you have a different version or model, you won't see any effect, so don't even bother to install it. But if you are on 5.1.0 and are curious, then:
  1. Rename the attached kpatcher.zip to kpatcher.jar and copy it to /opt/amazon/ebook/lib/
  2. Modify /opt/amazon/ebook/bin/init.xargs: insert the line "-istart kpatcher.jar" above the "-istart portability-impl.jar" (i.e., kpatcher.jar should be the first "istart" line).
  3. reboot, or simply killall cvm

Then, go to Menu > Settings, Menu > Legal and be prepared for a surprise

There is also Menu > Settings, Menu > Device Info to check out. And finally, try to enable TTS on a non-english (or TTS-disabled) book (and then go back to device info). Oh, and there's /tmp/kpatcher.log as well.

This is somewhat of a logical follow-up to this older post, but it is MUCH more powerful. In fact, with this approach, we can modify every single class in the framework, without having to overwrite Amazon's files or distributing copyrighted binary files. Yeeehaaa!

Note: As said, the "demo" works on KT 5.1.0 only. However, the general approach is suitable for all models (in fact, maybe even more for older models than for the Touch, because on older models the entire UI is in Java, which is not the case on KT).

Update: attachment removed. See first post for the newest version.

Last edited by ixtab; 04-29-2012 at 05:48 PM.
ixtab is offline   Reply With Quote
Advert
Old 04-16-2012, 06:14 AM   #3
diba
Addict
diba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolate
 
Posts: 396
Karma: 33660
Join Date: Jul 2011
Device: Kindle 3, Kindle 4, Kindle PW, Nexus7 3G
Amazing, could not resist to check immediatelly. How the f... do you do all this stuff?
diba is offline   Reply With Quote
Old 04-16-2012, 07:17 AM   #4
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Quote:
Originally Posted by diba View Post
Amazing, could not resist to check immediatelly. How the f... do you do all this stuff?
Well, it's a combination of curiosity, patience (to the point of masochism at times) and the will to break out of the Matrix and defeat the system... backed by 15+ years of reverse engineering experience, continuous learning and (in this case) relatively good knowledge of some of the more scary internals of Java.

Still, I would never have been able to do this without the truely excellent serp bytecode manipulation framework. In fact, I had used it for the first time for the localization, so without that, maybe this wouldn't even have crossed my mind. So you see, it's all a continuous process

BTW, it's astonishing with how little code (and relatively little effort, actually) this works. All of this together is only around 400 lines of code for now, and it's amazingly elegant (I think). You can simply decompile the code and you'll see

In short, the way that it works is by injecting a ClassLoader in the hierarchy as early as possible, which can then intercept all class load requests. And instead of loading classes normally, it can modify them (using the mentioned serp library) before they are loaded. This means that as little or as many changes as you want can be made. For example, the actual "TTS enabling" patch changes exactly one opcode, and consists of 7 lines of code in total.

Note that this is not fully dynamic, because classes cannot be redefined at runtime, but only once at load time. This is a limitation of the underlying JVM itself. Still, we can essentially arbitrarily change all classes without needing to touch a single original file. (Well, yeah, one. The configuration file )

Last edited by ixtab; 04-16-2012 at 07:24 AM. Reason: typo
ixtab is offline   Reply With Quote
Old 04-16-2012, 12:57 PM   #5
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Short update:

I uploaded the source code a while ago (see first post). In the mean time, here is another version, which is closer to what I intend this to be. Individual patches can now be enabled/disabled by simply copying or removing files rom a folder.
The files more or less reflect my idea of where this should be going, but there's certainly more to do.

Oh, and I renamed it from kpatcher to jbpatcher ("Java Bytecode Patcher" instead of "Kindle Patcher", because the approach is not specific to the Kindle). So yes, entirely remove the previous stuff and install this one instead...

If you have any comments, let me know.

Update: attachment removed. See first post for the newest version.

Last edited by ixtab; 04-29-2012 at 05:48 PM.
ixtab is offline   Reply With Quote
Advert
Old 04-16-2012, 01:19 PM   #6
diba
Addict
diba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolate
 
Posts: 396
Karma: 33660
Join Date: Jul 2011
Device: Kindle 3, Kindle 4, Kindle PW, Nexus7 3G
Installed latest version, now i have "Your Kindle needs repair screen" ... (Ihr Kindle muss repariert werden) :-(
diba is offline   Reply With Quote
Old 04-16-2012, 01:45 PM   #7
diba
Addict
diba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolate
 
Posts: 396
Karma: 33660
Join Date: Jul 2011
Device: Kindle 3, Kindle 4, Kindle PW, Nexus7 3G
I am in diags mode, what is the command to enter getting out of this f...ing "repair" mode please?

update: diags, but actually can not access via WinSCP ...

done, diags, ssh, so anyboby telling me the command pls, already reading in the 25th post ...

Last edited by diba; 04-16-2012 at 01:52 PM.
diba is offline   Reply With Quote
Old 04-16-2012, 01:50 PM   #8
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Hmmm... I can't reproduce that. I just retried with the exact same files that I posted here....

But I do get something interesting as well when rebooting, namely /mnt/us/jbpatcher not being found.

Could it really be that the framework is starting even before all filesystems are correctly mounted?!
ixtab is offline   Reply With Quote
Old 04-16-2012, 01:54 PM   #9
diba
Addict
diba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolate
 
Posts: 396
Karma: 33660
Join Date: Jul 2011
Device: Kindle 3, Kindle 4, Kindle PW, Nexus7 3G
deleted

Last edited by diba; 04-17-2012 at 01:46 PM.
diba is offline   Reply With Quote
Old 04-16-2012, 01:57 PM   #10
diba
Addict
diba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolate
 
Posts: 396
Karma: 33660
Join Date: Jul 2011
Device: Kindle 3, Kindle 4, Kindle PW, Nexus7 3G
deleted

Last edited by diba; 04-17-2012 at 01:42 AM.
diba is offline   Reply With Quote
Old 04-16-2012, 01:58 PM   #11
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Hehe... no. I have actually never managed to get my Kindle into that state.

Still, just search for "repair" on https://wiki.mobileread.com/wiki/Kindle_Touch_Hacking ... That looks like what you are looking for.
ixtab is offline   Reply With Quote
Old 04-16-2012, 01:59 PM   #12
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Quote:
Originally Posted by diba View Post
Is it this one ?

dd if=/dev/zero of=/dev/mmcblk0p3 bs=4K
That is the radical solution which will remove all "cached" content and most settings. It'll probably work. But try the other one first ...
ixtab is offline   Reply With Quote
Old 04-16-2012, 02:01 PM   #13
diba
Addict
diba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolate
 
Posts: 396
Karma: 33660
Join Date: Jul 2011
Device: Kindle 3, Kindle 4, Kindle PW, Nexus7 3G
Can I just do it by entering this command or is it necessary to do it via the runme? As said I am in diagnostic and have ssh access.
diba is offline   Reply With Quote
Old 04-16-2012, 02:06 PM   #14
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
You can of course do it from diags, as long as you delete the right file on the right partition.

On the bright side... you have SSH control, so you can do things interactively....
ixtab is offline   Reply With Quote
Old 04-16-2012, 02:18 PM   #15
diba
Addict
diba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolatediba is generous with chocolate
 
Posts: 396
Karma: 33660
Join Date: Jul 2011
Device: Kindle 3, Kindle 4, Kindle PW, Nexus7 3G
so if I delete the /var/local/upstart/lab126_gui.restarts the KT should be ready to restart?
diba is offline   Reply With Quote
Reply

Tags
jbpatch, kindle touch hacks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump


All times are GMT -4. The time now is 07:42 AM.


MobileRead.com is a privately owned, operated and funded community.