<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Matt Merry &#187; 2009 &#187; January &#187; 10</title>
	<atom:link href="http://www.mattmerry.com/blog/2009/01/10/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mattmerry.com/blog</link>
	<description>MattMerry.com</description>
	<pubDate>Thu, 19 Feb 2009 01:19:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<!-- podcast_generator="podPress/8.8" -->
		<copyright>&#xA9; </copyright>
		<managingEditor>matt@mattmerry.com ()</managingEditor>
		<webMaster>matt@mattmerry.com()</webMaster>
		<category></category>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary>MattMerry.com</itunes:summary>
		<itunes:author></itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name></itunes:name>
			<itunes:email>matt@mattmerry.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.mattmerry.com/blog/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://www.mattmerry.com/blog/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>Matt Merry</title>
			<link>http://www.mattmerry.com/blog</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>CMbP Sections Decoded</title>
		<link>http://www.mattmerry.com/blog/2009/01/10/cmbp-sections-decoded</link>
		<comments>http://www.mattmerry.com/blog/2009/01/10/cmbp-sections-decoded#comments</comments>
		<pubDate>Sat, 10 Jan 2009 21:47:47 +0000</pubDate>
		<dc:creator>Matt Merry</dc:creator>
		
		<category><![CDATA[SD14 Firmware Hacking]]></category>

		<category><![CDATA[CMbP]]></category>

		<category><![CDATA[decoding]]></category>

		<guid isPermaLink="false">http://www.mattmerry.com/blog/?p=38</guid>
		<description><![CDATA[I had some time over the holiday to dust off the SD14 firmware project. I was able to mostly decode the CMbP sections in the firmware. I&#8217;m not sure yet what they represent, but I&#8217;m able to understand most of the information in the section.
First, lets look at the CMbP Section starting at offset 0&#215;518 [...]]]></description>
			<content:encoded><![CDATA[<p>I had some time over the holiday to dust off the SD14 firmware project. I was able to mostly decode the CMbP sections in the firmware. I&#8217;m not sure yet what they represent, but I&#8217;m able to understand most of the information in the section.</p>
<p>First, lets look at the CMbP Section starting at offset 0&#215;518 in s14v101.bin. (I&#8217;m picking an easy one on purpose) You can use my parsebin.pl script to extract the section. I&#8217;ve copied the section here.</p>
<pre>0000:0510 | <span style="color: #c0c0c0;">45 46 41 55  4C 54 00 00</span>  <span style="color: #000080;">43 4D 62 50  00 00 01 00</span> | <span style="color: #c0c0c0;">EFAULT..</span><span style="color: #000080;">CMbP....</span>
0000:0520 | <span style="color: #000080;">B8 00 00 00  14 00 00 00  20 00 00 00  43 4F 4E 44</span> | <span style="color: #000080;">¸....... ...COND</span>
0000:0530 | <span style="color: #000080;">5F 52 45 53  00 00 00 00  06 00 00 00  58 00 00 00</span> | <span style="color: #000080;">_RES........X...</span>
0000:0540 | <span style="color: #000080;">00 00 00 00  09 00 00 00  14 00 00 00  18 00 00 00</span> | <span style="color: #000080;">................</span>
0000:0550 | <span style="color: #000080;">1F 00 00 00  24 00 00 00  2C 00 00 00  31 00 00 00</span> | <span style="color: #000080;">....$...,...1...</span>
0000:0560 | <span style="color: #000080;">39 00 00 00  3F 00 00 00  4F 00 00 00  57 00 00 00</span> | <span style="color: #000080;">9...?...O...W...</span>
0000:0570 | <span style="color: #000080;">56 61 72 69  61 62 6C 65  00 52 45 53  4F 4C 55 54</span> | <span style="color: #000080;">Variable.RESOLUT</span>
0000:0580 | <span style="color: #000080;">49 4F 4E 00  3D 48 49 00  52 45 53 5F  48 49 00 3D</span> | <span style="color: #000080;">ION.=HI.RES_HI.=</span>
0000:0590 | <span style="color: #000080;">4D 45 44 00  52 45 53 5F  4D 45 44 00  3D 4C 4F 57</span> | <span style="color: #000080;">MED.RES_MED.=LOW</span>
0000:05A0 | <span style="color: #000080;">00 52 45 53  5F 4C 4F 57  00 3D 46 55  4C 4C 00 52</span> | <span style="color: #000080;">.RES_LOW.=FULL.R</span>
0000:05B0 | <span style="color: #000080;">45 53 5F 48  49 20 52 45  53 5F 46 55  4C 4C 00 44</span> | <span style="color: #000080;">ES_HI RES_FULL.D</span>
0000:05C0 | <span style="color: #000080;">65 66 61 75  6C 74 00 52  45 53 5F 48  49 00 31 30</span> | <span style="color: #000080;">efault.RES_HI.10</span></pre>
<p>From parsebin.pl, we can see that the section is supposed to be 0xB8 bytes long. Just taking a quick look, we see the section starts with the following:</p>
<pre>0000:0518 | <span style="color: #000080;">43 4D 62 50</span>  <span style="color: #339966;">00 00 01 00</span>  <span style="color: #ff0000;">B8 00 00 00</span> 14 00 00 00 | <span style="color: #000080;">CMbP</span><span style="color: #339966;">....</span><span style="color: #ff0000;">¸...</span>....</pre>
<p>There is the Section Identifier (<span style="color: #000080;">CMbP</span>), some value (<span style="color: #339966;">0&#215;00010000</span>) and then <span style="color: #ff0000;">0&#215;000000B8</span> - Our section length! We&#8217;ve got our first couple pieces of concrete information on the section, the section identifier and the length.</p>
<p>We don&#8217;t know what the 0&#215;00010000 is yet. And the next byte, 0&#215;00000020 is also unknown at this point. We see a string next however with a value of &#8220;COND_RES.&#8221; Next are a bunch of WORDS (4 bytes) then more strings. The strings start with &#8220;Variable&#8221; and &#8220;Resolution&#8221; and then what look like pairs of strings follow after that. For example, the string pair would be &#8220;=HI&#8221; and &#8220;RES_HI&#8221; followed by &#8220;=MED&#8221; and &#8220;RES_MED&#8221; The strings appear to be related, hence I&#8217;m calling them pairs for now untill I figure things out better. We can see this, but lets try to figure out how it is decoded.</p>
<p>First, start off with &#8220;COND_RES&#8221; It ends on a 4 byte boundary, but this might be coincidence. Especially considering most strings are usually null terminated (e.g. end with 0&#215;00). Also, thinking logically, why would a string have to be a  multiple of 4? This would be required if it were to end on a 4 byte boundary. My suspicion is that the string ends with the WORD which is null terminated, so this string would have an additional 0&#215;00000000. Lets confirm by looking at the equivalent string in the first two  CMbP sections (at offsets 0&#215;26C and 0&#215;2B0)</p>
<pre>0000:0280 | <span style="color: #000080;">52 65 71 75  69 72 65 64  48 61 72 64  77 61 72 65</span> | <span style="color: #000080;">RequiredHardware</span>
0000:0290 | <span style="color: #000080;">00 00 00 00</span>  01 00 00 00  38 00 00 00  00 00 00 00 | <span style="color: #000080;">....</span>....8.......</pre>
<pre>...</pre>
<pre>0000:02C0 | 24 00 00 00  <span style="color: #000080;">53 68 6F 6F  74 69 6E 67  4D 6F 64 65</span> | $...ShootingMode
0000:02D0 | <span style="color: #000080;">73 00 00 00</span>  01 00 00 00  34 00 00 00  00 00 00 00 | s.......4.......</pre>
<p>Hm. &#8220;RequiredHardware&#8221; also appears to end on a 4 byte boundry. But, &#8220;ShootingModes&#8221; does not - it ends with 0&#215;73000000.Lets look at one more section, at 0&#215;300:</p>
<pre>0000:0310 | 24 00 00 00  <span style="color: #000080;">43 4F 4E 44  5F 45 56 41  4C 5F 53 54</span> | $...<span style="color: #000080;">COND_EVAL_ST</span>
0000:0320 | <span style="color: #000080;">41 54 45 00</span>  03 00 00 00  44 00 00 00  00 00 00 00 | <span style="color: #000080;">ATE.</span>....D.......</pre>
<p>Ah, the string &#8220;COND_EVAL_STATE&#8221; also ends in 0&#215;00 on a 4 byte boundry. You can confrim with the rest of the CMbP sections that this string will always end on 0&#215;00, padded with 0&#215;00s to the next 4 byte boundry. So, we&#8217;ve got something akin to a section title now.</p>
<p>Next up are those string pairs we discussed earlier. Before we get to that however, we should take a look at the WORDS that separate our section title from these string pairs. Here they are (Hex : Decimal):</p>
<ul>
<li>0&#215;00 : 0</li>
<li>0&#215;06 : 6</li>
<li>0&#215;58 : 88</li>
<li>0&#215;00 : 0</li>
<li>0&#215;09 : 9</li>
<li>0&#215;14 : 20</li>
<li>0&#215;18 : 24</li>
<li>0&#215;1F : 31</li>
<li>0&#215;24 : 36</li>
<li>0&#215;2C : 44</li>
<li>0&#215;31 : 49</li>
<li>0&#215;39 : 57</li>
<li>0&#215;3F : 63</li>
<li>0&#215;4F : 79</li>
<li>0&#215;57 : 87</li>
</ul>
<p>Interesting. Starting at 0&#215;09, the numbers are all increasing. Remember the first string in this next group is &#8220;Variable?&#8221; Counting the NULL (0&#215;00), &#8220;Variable&#8221; is 9 bytes long. The next value is 0&#215;14 or 20 bytes long. The next string is &#8220;RESOLUTION&#8221; - counting the NULL that is 11 bytes long, not 20. But! 20 - 9 = 11. In other words, the string &#8220;RESOLUTION&#8221; ends 20 bytes after the beginning the the string group. The next number is 0&#215;18 or 24 in decimal. Sure enough, the string &#8220;=HI&#8221; ends at an offset of 0&#215;18 from the start of the string group.</p>
<p>There we have it, most of the information in the CMbP section has been decoded. The following is a summary of the section structure:</p>
<blockquote><p>Length    Description<br />
0&#215;04        Section Identifier (= CMbP)<br />
0&#215;04        Unknown (Section Version? =0&#215;00 01 00 00 could be minor/major)<br />
0&#215;04        Section Length<br />
0&#215;04        Unknown<br />
0&#215;04         Unknown<br />
Variable    Section Title (length multiples of 0&#215;4, must end in 0&#215;00)<br />
0&#215;04        Unknown<br />
0&#215;04        Unknown<br />
0&#215;04        Unknown (all 0&#215;00&#8217;s)<br />
Variable   String Ending offset (must start with 0&#215;00, each has length of 0&#215;4)<br />
Variable    Strings.</p></blockquote>
<p>I&#8217;ve updated the parsebin.pl script to decode and store the CMbP sections. I&#8217;m going to clean the script up a bit and post the output and script a bit later on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmerry.com/blog/2009/01/10/cmbp-sections-decoded/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
