As being a hard core developer I had a look into the THM files. I STFW but could not find any resources explaining the file format. So I explored it a bit myself. Here is what I found together with some Ruby code.
Sony Ericsson Theme File (.THM) Format
The file contains several files concatenated together with some kind of header before the data.
- At
0x0000
a null-terminated string with the name of the original file. Remaining bytes are all null. This is read withname = data[ofs..ofs+0x63].strip
. - At
0x0064
several null-or-blank-terminated strings containing octal numbers. The number fields may contain blanks which are treated as separators as well. Parse them withnumbers = data[ofs+0x64..ofs+0x100]. scan(/[0-7]+/). collect { |n| n.to_i(8) }
- The only important number is the fourth (
body_len = numbers[3]
), which is the length of the data body in bytes. If this number is not positive then the file is corrupt. - At
0x0101
there is most of the time the stringustar
and at0x0129
nogroup
, but we do not need them. - At
0x0200
starts the data:body = data[ofs+0x200...ofs+0x200+body_len]
. - After
0x0200+body_len
the space is filled with nulls until the next address continuing a zero low-byte. We just skip them untildata[ofs] != 0
. - Repeat these steps until EOF.
Theme.xml
. This is an XML configuration file and looks something like<Sony_Ericsson_theme version="4.5"> <Background Color="0xb5f8fd"/> <Background_image Source="desktop.png"/> <Desktop Color="0xb5f8fd"/>Sometimes it's not called in this way, but any XML file will do. The
Color
looks like a regular HTML Colour Code. The Source
is a reference to an image stored inside the theme file. The important image types areStandby_image
- main image.Desktop_image
- background in the menu.Popup_image
- background of popup.- There are a lot more, but often these three images are reused in smaller themes.
File.open(filename,'wb') {|io| io.write body}
). Then browsing these preview images with some image utility and deleting unwanted ones is a piece of cake. The whole Ruby program is here. Have fun!
3 comments:
You know, the .thm files are actually plain old .tar files. You can open them with any decent decompression program (in Windows, I personally use IZArc)
Once open, you get that XML file you saw plus (possibly) a bunch of .png, .jpg .gif, or .swf files. It's really nothing special.
Oh, and btw... see if this link works for you: Themes Developer guide
Thanks José, knowing that it's a TAR would have saved me some work. (But know I know I reverse engineered tar format ;-) I'm wondering why the chose such an old file format...
Post a Comment