| View previous topic :: View next topic |
| Author |
Message |
Cristian Streng Founder
Joined: 28 Oct 2005 Posts: 4585
Phone Type: (many)
|
Posted: Wed Aug 08, 2007 8:19 am Post subject: Put any j2me application on a Helio (Ocean) phone |
|
|
An anonymous MGMaps user has recently sent me a version of Mobile GMaps built for Helio. (Thanks!) It consists of three files:- an .html file to be stored on a server and accessed over-the-air from the phone. It's a simple WAP page with a link to mgmaps.dd including a "type" parameter to specify the MIME type. See http://wap.mgmaps.com/helio.html.
- a .dd file to replace the .jad descriptor file, see http://wap.mgmaps.com/mgmaps.dd. Besides the info kept from the original .jad file, the MIDlet-Jar-URL and MIDlet-Jar-Size refer to mgmaps.smf, there's a mandatory MIDlet-Install-Notify parameter to a URL that ends with "/WIPI/status", and there are a few additional DD-* parameters. Of those, the "DD-ProgName" replicated as "DD-Player-ProgName" should contain the name of the folder the program gets installed to, composed of a "CID" (content provider ID, 5 chars) and a "SID (software ID, 5 chars). The values of those don't really matter, as long as they are different for different applications.
- an .smf file to replace the .jar, see http://wap.mgmaps.com/mgmaps.smf. This is the most interesting part, as the .smf file is simply a wrapper that adds a 16-byte header and a 16-byte footer to the jar contents. After a quick look, the format is quite simple (stored in little-endian format):
| Code: |
header:
dword 0xDEADFACE
dword (jar file length+0x20 = smf file length)
dword 0
dword (jar file length)
footer:
dword 1
dword 0
dword 2
dword 0
|
Between the header and the footer you'll find the original .jar contents, proof:
| Code: | bash-3.1$ dd bs=1 skip=16 if=mgmaps.smf of=mgmaps.smf.data count=163838
163838+0 records in
163838+0 records out
163838 bytes (164 kB) copied, 0.752 seconds, 218 kB/s
bash-3.1$ diff mgmaps.smf.data mgmaps.jar
bash-3.1$
|
What's all this info for? You guessed right, it's now relatively easy to pack any custom java application into dd/smf files. You just need to build the smf file by adding the header and footer to the jar file, build the dd from the jad by adding the DD-* entries, and make them available for download over-the-air on your server. You can already find Opera Mini (google for 'opera mini helio') and I'm sure more applications will come out shortly.
Cristian |
|
| Back to top |
|
 |
tfreeman11 Newbie
Joined: 09 Aug 2007 Posts: 1
Phone Type: Unknown
|
Posted: Thu Aug 09, 2007 5:29 pm Post subject: J2ME Apps on Helio Ocean |
|
|
Cristian,
Check your inbox I sent you a PM. |
|
| Back to top |
|
 |
Cristian Streng Founder
Joined: 28 Oct 2005 Posts: 4585
Phone Type: (many)
|
Posted: Fri Aug 10, 2007 6:17 am Post subject: |
|
|
A few more notes. The .jar file is basically a zip archive. The header and footer for the .smf are just bytes - sequences of bytes that get prepended at the beginning of the .jar file and appended at the end. By doing this, of course it is no longer a zip file.
Now... in order to edit the .smf file you need a binary (hex) editor. I got the first one I found, http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm#download. Open the jar file -- I'm using mgmaps.jar v1.36 as an example, file size is 163838 bytes. Switch off Overwrite mode in the Tools menu. Now you need to insert the header = 16 bytes at the beginning of the file. For mgmaps you'd enter:
CE FA AD DE (this is the DEADFACE magic number in little-endian format)
1E 80 02 00 (convert the jar file size to hex 163838 = 27FFE(hex), 27FFE + 20 = 2801E, then represent it as little-endian)
00 00 00 00 (zeroes)
FE 7F 02 00 (27FFE, the jar file size)
The footer is simpler, it's always the same, you just need to be careful that the editor can't append at the end of the file, it inserts before the last byte. Scroll to the end of the file, retype "00" (or the last byte of the jar in general) then add 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00. Finally press Delete to delete the last "00", it was kept when you retyped it. Save the file, check that the file is now 32 bytes larger than the original, and change the extension to .smf.
As for the .dd, it's a text file, you can compare it with the original jad to see the changes. Starting with the .jad you need to change the midlet-version and make sure version number "elements" have 3 digits each (1.36.00 becomes 001.036.000), change MIDlet-Jar-URL and enter the full URL to the .smf file, change the MIDlet-Jar-Size and put in the new size, add the DD-* parameters -- you can copy all of them from mgmaps except for DD-ProgName and DD-Player-ProgName (see the initial post), change/add the MIDlet-Install-Notify to point to a URL that ends with /WIPI/status -- I don't know if it even needs to be valid.
You also need to put the .dd and .smf files on a web server, and make sure the link to the .dd in the referencing page includes type="application/x-wipij-dd". For more info, view source on http://wap.mgmaps.com/helio.html. |
|
| Back to top |
|
 |
binaryconstruct Junior
Joined: 16 Aug 2007 Posts: 4
Phone Type: Unknown
|
Posted: Fri Aug 17, 2007 12:45 am Post subject: SMF/DD/HTML packer for jar files |
|
|
Here is Helio Application Packer, which is basically the above post compiled into C# code. Win exe and Source are available.
http://www.binaryconstruct.com/extras.html
Cristian Streng, your post is what made this application packer possible. Thank you for finding this and making it public! |
|
| Back to top |
|
 |
Cristian Streng Founder
Joined: 28 Oct 2005 Posts: 4585
Phone Type: (many)
|
Posted: Fri Aug 17, 2007 5:17 am Post subject: Re: SMF/DD/HTML packer for jar files |
|
|
Thanks, looks very nice - I'll be using it to pack MGMaps. A couple of suggestions for future versions:- it would be nice to have an option to manually set the CID and SID in the DD-ProgName and DD-Player-ProgName parameters. I suppose that the SID and CID should remain the same when upgrading an application, right? I don't know how they are currently generated - are they randomly set? or some kind of hash over the file contents/file name?
- folder chooser for output should start in the current folder like the file chooser for the .jar does
Regards,
Cristian |
|
| Back to top |
|
 |
binaryconstruct Junior
Joined: 16 Aug 2007 Posts: 4
Phone Type: Unknown
|
Posted: Sat Aug 18, 2007 4:00 am Post subject: packager |
|
|
Will do. Those are nice suggestions.
I'm having some trouble with the packager, it seems the DD files it is generating are not valid. Would you be willing to take a look at some and tell me what your think? I can prepare some samples I am having problems with if you will.
Thanks |
|
| Back to top |
|
 |
Cristian Streng Founder
Joined: 28 Oct 2005 Posts: 4585
Phone Type: (many)
|
Posted: Sat Aug 18, 2007 6:34 am Post subject: Re: packager |
|
|
| binaryconstruct wrote: | Will do. Those are nice suggestions.
I'm having some trouble with the packager, it seems the DD files it is generating are not valid. Would you be willing to take a look at some and tell me what your think? I can prepare some samples I am having problems with if you will.
Thanks |
Yes, I'll take a look. I'll also try it with MGMaps - however I don't have a Helio device so the testing should still be done by you or some other users. |
|
| Back to top |
|
 |
binaryconstruct Junior
Joined: 16 Aug 2007 Posts: 4
Phone Type: Unknown
|
Posted: Sun Aug 19, 2007 12:22 am Post subject: new code |
|
|
Thanks Cristian.
I haven't had any time to prepare any samples, but I did add your suggestions. |
|
| Back to top |
|
 |
Cristian Streng Founder
Joined: 28 Oct 2005 Posts: 4585
Phone Type: (many)
|
Posted: Wed Aug 22, 2007 4:41 am Post subject: Re: new code |
|
|
| binaryconstruct wrote: | Thanks Cristian.
I haven't had any time to prepare any samples, but I did add your suggestions. |
I had a look over the generated .smf files, it seems they are 1 byte larger than they should... you are adding an extra "00" byte before the 16-byte footer of the file, just remove that and everything should be fine.
If the generated files work well anyway just ignore my message  |
|
| Back to top |
|
 |
binaryconstruct Junior
Joined: 16 Aug 2007 Posts: 4
Phone Type: Unknown
|
Posted: Wed Aug 22, 2007 5:06 am Post subject: thanks for the help |
|
|
| Thanks for your help! |
|
| Back to top |
|
 |
|