10-11-2012, 01:02 PM | #811 |
Enthusiast
Posts: 36
Karma: 41848
Join Date: Mar 2011
Device: iRex
|
Ok, this is probably naive, but if JBPatch was written and compiled for K4 in Java 1.4 and K3 also uses Java 1.4, what is going to have to be adjusted? (Apart from the patches and UI.)
Early in this post you wrote that JBPatch would produce no effect if installed on K3... Clearly compiling is not the issue. |
10-11-2012, 01:29 PM | #812 | |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Okay I just read the entire JB Patch wiki page. Again.
"No effect" in the sense that the various specific classes that you are trying to address would be different ones on the KK. so whilst JBPatch may go ahead and attempt to patch a bunch of non-existant files - the net result would be zero changes. I'll just quote the very end of the page Quote:
I think that this is a very exciting development (It being for a 3) and there are some options for UI IMHO. : ) Last edited by twobob; 10-11-2012 at 01:34 PM. Reason: links to make life easy for future readers. |
|
10-11-2012, 02:37 PM | #813 | |
(offline)
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
Quote:
First: the UI parts will not work, because the K3 does *not* include the common Swing classes, like JButton. Instead, Amazon decided to use their own replacements, like "KButton". But as said, this is not so important yet, and I really urge you to ignore the UI stuff for the time being. Second: I simply don't know if the method to "hook" into the system is the same. As said, I only have a K5 at this moment, and I can only describe how it works on this system. The rest of this post will try to make this clear. So, to start off at the very beginning... How does JBPatch really work? It works by modifying the binary code of class files, right before it is actually interpreted as bytecode. For an easier-to-understand example: suppose that the Kindle could only display text files. JBPatch would be the part that can modify text files after they are loaded, but before they are displayed. So, it could, for example, modify all occurences of "red" to return "blue" instead. When loading a file that contains information about Moscow, the text would then suddenly read something like "The Blue Square (Russian: Красная площадь, tr. Krásnaja Plóščaď; IPA: [ˈkrasnəjə ˈploɕːətʲ]) is a city square in Moscow, Russia". Essentially, every patch does just this: it replaces some known parts of what it was given by something else. There could be another patch which would replace all mentions of "Square" by "Triangle"... well, you get the idea. Of course, it's slightly more technical, but yeah, that actually is the idea of how JBPatch works. Why can JBPatch work at all? This is really rather tough to explain, and it can't be done in one or two paragraphs here. Essentially, it has to do with the way that classes are loaded in Java, and with the fact that ClassLoaders are organized hierarchically. You can find all the required information by asking your favorite search engine about "classloader hierarchy java" or similar. But in short, it's all about getting control (as early as possible) over the class loading procedure. In other words: the JBPatch ClassLoader (called PatchingClassLoader) will try to take control over all class loading, as soon as it is loaded (instantiated) itself. How does the PatchingClassLoader take control? This one is relatively easy. By using the Java Reflection API, the PatchingClassLoader can "hook" in between its own actual (parent) ClassLoader, and that ClassLoader's real parent ClassLoader (To make this clear: yes, it is "parasitically" hooking in between its own "parent" and "grandparent" classloader!) . This, in turn, means that all future classes which are requested to be loaded by the parent ClassLoader will now go through the PatchingClassLoader. And that's exactly what we want - and we need to take that control as early as possible. How does JBPatch make sure that it gets control early enough? This is really the crucial thing: getting control early enough. And it's also exactly the thing why I can't promise anything for JBPatch on devices where I have not tested it myself. Because it doesn't make sense to list things that don't work... I will list the things that DO work. On the Kindle Touch: - the entire system is based on Concierge OSGi. - /opt/amazon/ebook/bin/init.xargs contains the line "-Dch.ethz.iks.concierge.strictStartup=true" - so just adding -istart jbpatch.jar as the first line is enough. That jar file must of course contain the relevant OSGi Bundle manifest entries, but that's easy. - the jbpatch.jar file will be loaded as the very first file, and it will install the PatchingClassLoader as soon as it is loaded. This, in turn, allows JBPatch to control all subsequent class loading. So, to summarize it all: to make JBPatch work on a different Firmware, you will need to (a) either verify that the method also works on that device, or (b) find another method to make it work on that device. Even in case it doesn't lead to anything at all... I hope that the above information was informative. Last edited by ixtab; 10-11-2012 at 03:22 PM. |
|
10-11-2012, 03:20 PM | #814 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
it was
|
10-11-2012, 03:22 PM | #815 |
Official Lurker
Posts: 1,050
Karma: 7096675
Join Date: Apr 2012
Device: Kindle 3.4
|
The K3 has /opt/amazon/ebook/bin/start.sh , i think... I think it contains the -i thingies and whatnot.... its been a while...
|
10-11-2012, 03:27 PM | #816 |
(offline)
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
(removed)
Last edited by ixtab; 10-11-2012 at 06:00 PM. |
10-11-2012, 03:30 PM | #817 |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
This thing?
|
10-11-2012, 03:32 PM | #818 |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
|
10-11-2012, 03:41 PM | #819 |
(offline)
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
|
10-11-2012, 03:52 PM | #820 |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
|
10-12-2012, 05:10 AM | #821 | |
Enthusiast
Posts: 36
Karma: 41848
Join Date: Mar 2011
Device: iRex
|
Quote:
If that is indeed the case, I imagine, the JBPatch code would require some more extensive adaptation for the patching class loader to work on K3, right? In case it helps, on K3 the framework is started as follows: jvm_opt="$jvm_heap_options \ -Dsun.awt.exception.handler=$EVENT_QUEUE_EXCEPTION_ HANDLER \ -Xbootclasspath/a:$java_locale_data:$java_charset_data \ -Dsun.boot.library.path=$java_home/lib \ -cp $clazzpath:$ebook_home/lib/portability-impl.jar" app_opt=" -Ddebug=1 \ -Dcheck_comm_stack=true \ -Dsun.net.client.defaultReadTimeout=120000 \ -Dhttp.keepalive.timeout=60000 \ -DUI_TIMEOUT=0 \ -Dhttp.maxConnections=16 \ -Dallow_demo=false \ -Djava.awt.SyncOnPaint=false \ -Dextkeyboard=false \ -Dconfig=$configdir/framework.luigi.conf \ -DPLATFORM_CLASS_FILE=/opt/amazon/ebook/config/platform.conf \ -DENABLE_SEARCH_INDEXING_THREAD=true \ -Dpolicy.home=$securitydir \ -Djava.security.manager \ -Djava.awt.DebugPaint=false \ -DUSE_KWGRAPHICS=false" opts="$jvm_opt $jit_opt $jvmpihprof_opt $jvmtihprof_opt $debug_opt $app_opt" app=com.lab126.linux.arm.LuigiServiceProvider LD_PRELOAD=$java_home/lib/libmicrowindowsawt.so $java $opts $app 2>&1 List of java archive files on the device: [root@kindle ebook]# find / -name *.jar /opt/amazon/ebook/booklet/XymlBooklet.jar /opt/amazon/ebook/booklet/Search.jar /opt/amazon/ebook/booklet/PictureViewer.jar /opt/amazon/ebook/booklet/AudioPlayer.jar /opt/amazon/ebook/booklet/MobiReader.jar /opt/amazon/ebook/booklet/msp.jar /opt/amazon/ebook/booklet/AudiblePlayer.jar /opt/amazon/ebook/booklet/Home.jar /opt/amazon/ebook/booklet/Browser.jar /opt/amazon/ebook/booklet/KindletBooklet-1.2.jar /opt/amazon/ebook/booklet/language.jar /opt/amazon/ebook/sdk/lib/xercesImpl.jar /opt/amazon/ebook/sdk/lib/log4j-1.2.15.jar /opt/amazon/ebook/sdk/lib/xml-apis.jar /opt/amazon/ebook/lib/framework-impl.jar /opt/amazon/ebook/lib/json_simple-1.1.jar /opt/amazon/ebook/lib/KindleDeviceServicesAbstraction-1.0.jar /opt/amazon/ebook/lib/framework-api.jar /opt/amazon/ebook/lib/JFEP-0.1.0.jar /opt/amazon/ebook/lib/xyml.jar /opt/amazon/ebook/lib/utilities.jar /opt/amazon/ebook/lib/MobipocketCoreReader.jar /opt/amazon/ebook/lib/jdbm.jar /opt/amazon/ebook/lib/KindleDeviceServicesShasta-1.0.jar /opt/amazon/ebook/lib/lucene-analyzers-2.4.1.jar /opt/amazon/ebook/lib/portability-impl.jar /opt/amazon/ebook/lib/KindletImplementation-1.2.jar /opt/amazon/ebook/lib/ReaderSDK.jar /opt/amazon/ebook/lib/portability.jar /opt/amazon/ebook/lib/icu4j.jar /opt/amazon/ebook/lib/lucene-snowball-2.4.1.jar /opt/amazon/ebook/lib/lucene-core-2.4.1.jar /opt/amazon/ebook/lib/kxml2.jar /opt/amazon/ebook/lib/PDFReader-impl.jar /opt/amazon/ebook/lib/SearchSDK.jar /opt/amazon/ebook/lib/KindleGUIAbstraction-1.0.jar /opt/amazon/ebook/lib/KindleGUIShasta-1.0.jar /opt/amazon/ebook/lib/backport-util-concurrent-3.1.jar /opt/amazon/ebook/lib/MobiCore-impl.jar /opt/amazon/ebook/lib/Kindlet-1.2.jar /opt/amazon/ebook/lib/json.jar /opt/amazon/ebook/lib/booklet.jar /opt/amazon/ebook/lib/KindletBookletDRM-1.0.jar /opt/amazon/ebook/lib/kindlePageNumbersDeviceReader.jar /opt/amazon/ebook/lib/Journal-update.jar /opt/amazon/ebook/lib/mobi8sdk.jar /opt/amazon/ebook/lib/HTMLReader-impl.jar /usr/java/lib/jaas.jar /usr/java/lib/sunrsasign.jar /usr/java/lib/charsets.jar /usr/java/lib/security/local_policy.jar /usr/java/lib/security/US_export_policy.jar /usr/java/lib/localedata.jar /usr/java/lib/jce.jar /usr/java/lib/jsse-cdc.jar /usr/java/lib/ext/sunjce_provider.jar /usr/java/lib/basis.jar |
|
10-12-2012, 06:37 AM | #822 | |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
Except that in the actual script, the jar search is restricted to three directories, not what was used to produce the list snipped from this quote. |
|
10-12-2012, 06:42 AM | #823 | |
(offline)
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
Quote:
Should be about 10 lines of code... |
|
10-12-2012, 07:08 AM | #824 | |
(offline)
Posts: 2,907
Karma: 6736092
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
Quote:
Code:
package com.mobileread.ixtab.jbpatch.bootstrap; import java.lang.reflect.Method; public class K3Startup { public static void main(String[] args) { try { // set up JBPatch classloader PatchingClassLoader.inject(); new Stage2().run(); // invoke "real" startup class Class startup = Class.forName("com.lab126.linux.arm.LuigiServiceProvider"); Method main = startup.getMethod("main", new Class[] {String[].class}); main.invoke(null, new Object[] {args}); } catch (Throwable t) { t.printStackTrace(); } } } Of course, this requires the framework startup script to be changed to use com.mobileread.ixtab.jbpatch.bootstrap.K3Startup as the main class, and the jbpatch jar to be in the classpath (I suggest /opt/amazon/ebook/lib/jbpatch.jar) If the framework starts up normally, you can then check /tmp/jbpatch.log to see if JBPatch is working correctly. Last edited by ixtab; 10-23-2012 at 02:16 PM. |
|
10-12-2012, 08:21 AM | #825 | |
Enthusiast
Posts: 36
Karma: 41848
Join Date: Mar 2011
Device: iRex
|
Quote:
|
|
Tags |
jbpatch, kindle touch hacks |
Thread Tools | Search this Thread |
|