09-30-2010, 11:24 AM | #1 |
Enthusiast
Posts: 26
Karma: 326
Join Date: Sep 2010
Device: kindle
|
Working kindlet development without the KDK
Hi, I have managed to persuade my Kindle 3 to load and run a (very simple) kindlet I've written. I do not have access to the KDK: I am using jars I pulled off the kindle itself to develop against.
The trickiest bit was figuring out how to sign a "developer" kindlet properly. There are details and a demo kindlet source and binary here: http://adq.livejournal.com BTW: thanks for the jailbreak and usbnetwork patches; they're really cleanly done, and saved me loads of time! |
09-30-2010, 01:12 PM | #2 |
Enjoying the show....
Posts: 14,270
Karma: 10462843
Join Date: Jun 2008
Location: Arizona
Device: A K1, Kindle Paperwhite, an Ipod, IPad2, Iphone, an Ipad Mini & macAir
|
Welcome to MobileRead, adq.
|
Advert | |
|
09-30-2010, 03:38 PM | #3 |
Enthusiast
Posts: 30
Karma: 10
Join Date: Jan 2008
Device: K3-3G, HTC HD2
|
Looks like a great start without the KDK, well done!
Hope it encourages some other developers to do some interesting things :-) G |
09-30-2010, 07:03 PM | #4 |
Enthusiast
Posts: 26
Karma: 326
Join Date: Sep 2010
Device: kindle
|
Ta. Some (probably obvious) ideas:
* Better manga reader - the built in one seems rather buggy! * Something like chrome-to-phone to get links onto the kindle more easily. * I think the kindle has some sort of USB host capability. I'm not yet sure if the external USB connector is switchable, but if it is, attaching a mobile phone with camera would make an instant document scanner... Myself, I'm now in the middle of writing a infocom text adventure kindlet for it; I think the kindle is ideally suited for that! |
09-30-2010, 09:58 PM | #5 |
Member
Posts: 21
Karma: 44
Join Date: Sep 2010
Device: Kindle 3
|
Really nice work.
I noticed that there are some very functional java decompilers available, such as this guy. It's true that the Amazon's binaries are obfuscated, but there are still some informative strings remaining in there. I'll be looking into recompiling the original java binaries, which, if possible, would open the door to modifying the original Kindle software. Though I haven't explored the low-level workings on this yet, one idea that comes to mind is removing the need for signing kindlets - the Home app could instead detect and load jar files directly. Just a thought. |
Advert | |
|
10-01-2010, 08:47 AM | #6 |
Enthusiast
Posts: 26
Karma: 326
Join Date: Sep 2010
Device: kindle
|
I'd suggest http://www.reversed-java.com/fernflower/
Its online only, but gives the most complete output You'll need to deobfuscate as the method names are all conflicting and many are invalid. I have a nearly working one, but its broken because it doesn't yet deal with preserving the names of overridden methods. I'd not stuck a link to it on my blog yet because of this issue. http://code.google.com/p/adqmisc/sou.../trunk/jrename The idea is - deobfuscate, decompile, then load into eclipse as a project and use its code refactoring tools to rename things as you figure out what is doing what. Last edited by adq; 10-01-2010 at 08:51 AM. |
10-04-2010, 01:00 PM | #7 |
Junior Member
Posts: 4
Karma: 10
Join Date: Oct 2010
Location: Warsaw, Poland
Device: kindle 3
|
Thanks adq!
I wonder, if it's possible to build application using some existing cdc sdk . I've tried to build kindlet with cdc_1.0.jar library, but i'm getting error - "An error occured opening thee file". |
10-04-2010, 10:40 PM | #8 |
Member
Posts: 21
Karma: 44
Join Date: Sep 2010
Device: Kindle 3
|
adq, first of all - Wow! I'm impressed with all the work you've done, and in such short time. Thank you for sharing it.
I took a look at the deobfuscator and the fernflower decompiler tonight. My goal was to compile one of the simpler booklet jars: msp.jar (minesweeper). I was unsuccessful, though I think I got a good feel for the process. I'm not sure if you've been able to recompile any of the jars yet, and I'm wondering if I made a mistake somewhere along the way. Though I'm familiar with Java, I'm more of a C# and C/C++ developer, so I'm not entirely familiar with Eclipse and some of the workings of Java. Anyway, here's what I did:
Is this generally the procedure you had in mind for deobfuscating / decompiling the files? I'm wondering if, instead of deobfuscating and referencing the lib jar files, I should have instead expanded them into their class files and deobfuscated / referenced those instead. |
10-05-2010, 12:53 PM | #9 |
Junior Member
Posts: 3
Karma: 10
Join Date: Oct 2010
Device: Kindle 3G+WiFi
|
Excellent find. This will get the MPD client I had in mind for a long time done real sone
Should you be evaluating connecting to some non-standard port (such as MPD in my case) it truly is a shame that they only seem to support http and https. However, what you can still do stuff like this: Code:
KTextArea ktx = new KTextArea(); @Override public void start() { try { ctx.getRootContainer().add(ktx); ctx.getConnectivity().submitConnectivityRequest( new ConnectivityHandler() { @Override public void disabled(NetworkDisabledDetails arg0) throws InterruptedException { // TODO Auto-generated method stub } @Override public void connected() throws InterruptedException { try { URL testUrl = new URL("http", "192.168.2.100", 6600, ""); URLConnection con = testUrl.openConnection(); DataInputStream dis = new DataInputStream(con .getInputStream()); String inputLine; while ((inputLine = dis.readLine()) != null) { ktx.append(inputLine); } } catch (Exception e) { ktx.append("exception: " + e.getMessage()); } } }); } catch (Exception e) { System.out.println("Error Connecting:" + e.getMessage()); e.printStackTrace(); } } But after that Mind that the nasty downside to this is that you can't be on usbnet while doing this... Seems that the Kindle thinks that there is no W-Lan connection if usb0 is up Sucks from my point of view, especially as we have to do the connection via that connectivity handler but it can't be helped i guess. Last edited by th0br0; 10-05-2010 at 01:42 PM. |
10-08-2010, 08:48 PM | #10 |
Enthusiast
Posts: 26
Karma: 326
Join Date: Sep 2010
Device: kindle
|
Hiya, sorry been busy kindle hacking for the last few days. I have my infocom interpreter app up and running. please see http://adq.livejournal.com/108011.html for details There's a link to the SVN repos for the source in there as well...
|
10-08-2010, 08:53 PM | #11 | |
Enthusiast
Posts: 26
Karma: 326
Join Date: Sep 2010
Device: kindle
|
Quote:
What I did was unzip absolutely everything into one directory, then deobfuscate it all into another directory. After that I kinda had to zip up subdirectories and run them through fernfllower individually, because of the limits. I'm really just interested in finding out how to use their APIs right now, rather than recompiling stuff, so this works ok for that. My decompiler does still have bugs in it I noticed, I'll try and fix them sometime, but I'm now busy with KIF. Another suggestion would be to use a bytecode disassembler to disassemble the stuff; I think that generally doesn't have the same problem the obfuscated names that decompiled code does, but obviously you're then just looking at raw java VM assembler... |
|
10-08-2010, 11:57 PM | #12 |
Member
Posts: 21
Karma: 44
Join Date: Sep 2010
Device: Kindle 3
|
Ah ha. Well that's what I suspected might be necessary, if the deobfuscator would make sure naming was consistent across class files if you process them in batch. Do you know if this is the case, and did you have any success with recompilation using your method? It might be worthwhile for me to add batch jar file processing, as decompressing and then recompressing class files seem to be pretty inconvenient, as you alluded to.
Actually, the first thing I did was run the jar files through a disassembler, but my goal is to be able to add new features into the original Kindle software, and attempting this in Java VM assembly isn't my idea of fun. |
10-09-2010, 05:51 AM | #13 |
Enthusiast
Posts: 26
Karma: 326
Join Date: Sep 2010
Device: kindle
|
If you unzip everything and deobs it in one go, the names should be consistent except for occasional deobfuscator bugs.
Yeah, I was using the deobs/decompile it to figure out what I wanted to know; if I actually wanted to change things, I'd probably use a disassembler/assembler. |
02-02-2011, 09:34 PM | #14 |
Junior Member
Posts: 4
Karma: 10
Join Date: Feb 2011
Device: iPad, Kindle
|
Sorry to revive an old thread but I've been trying to run various kindlets (downloaded from the Kindle store) through Fernflower and keep getting an "Invalid archive file" error. Am I missing a step?
|
02-02-2011, 10:37 PM | #15 |
I <3 my Kindle
Posts: 528
Karma: 51332
Join Date: Nov 2010
Location: United States
Device: Kindle 3G + WiFi
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Kindle KDK and Simulator | ulver | Kindle Developer's Corner | 2 | 09-16-2011 04:54 PM |
Anybody got the KDK yet? | AndyG | Kindle Developer's Corner | 9 | 10-26-2010 07:20 AM |
Working my Way through The Busy Coder's Guide to Android Development | kennyc | Android Developer's Corner | 22 | 09-25-2010 12:58 PM |
KDK Access? | JiYu | Kindle Developer's Corner | 4 | 09-18-2010 04:21 PM |
Amazon's email about the KDK. KDK isn't here... yet. | ziplizard | Amazon Kindle | 3 | 05-14-2010 12:25 AM |