<?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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Abort, Retry, Hack? &#187; Hacks</title>
	<atom:link href="http://marcansoft.com/blog/category/hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://marcansoft.com/blog</link>
	<description>[ marcan&#039;s blog ]</description>
	<lastBuildDate>Tue, 22 Dec 2009 16:26:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Enabling Intel VT on the Aspire 8930G (and other InsydeH2O-based laptops)</title>
		<link>http://marcansoft.com/blog/2009/06/enabling-intel-vt-on-the-aspire-8930g/</link>
		<comments>http://marcansoft.com/blog/2009/06/enabling-intel-vt-on-the-aspire-8930g/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 16:30:49 +0000</pubDate>
		<dc:creator>marcan</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[acer]]></category>
		<category><![CDATA[bios]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[intelvt]]></category>
		<category><![CDATA[reveng]]></category>

		<guid isPermaLink="false">http://marcansoft.com/blog/?p=71</guid>
		<description><![CDATA[It seems the ongoing trend for laptops is to integrate and hide as much as possible from the user. We&#8217;re all used to minimalistic crappy BIOS setups with two or three configuration options. However, things go way too far when OEMs remove options related to features that the hardware is capable of but which are [...]]]></description>
			<content:encoded><![CDATA[<p>It seems the ongoing trend for laptops is to integrate and hide as much as possible from the user. We&#8217;re all used to minimalistic crappy BIOS setups with two or three configuration options. However, things go way too far when OEMs remove options related to features that the hardware is capable of but which are disabled by default. This happens with Intel VT on many laptops &#8211; even if the CPU supports it, you may not be able to find the BIOS setup option to turn it on. </p>
<p>I certainly wanted to use a feature that I <b>paid for</b>, so I started investigating the BIOS and here&#8217;s what I found out.<br />
<span id="more-71"></span></p>
<h3>Under the hood</h3>
<p>The InsydeH2O BIOS is no ordinary old-style BIOS. Instead, it&#8217;s based around the <a href="http://www.uefi.org/">UEFI</a> platform. This goes way beyond the old BIOS paradigm and turns system firmware into practically its own separate OS, that even runs in full 64-bit mode on 64-bit machines. Unfortunately, they make no effort to expose any of this to the user. The firmware has support for booting EFI executables, there&#8217;s an EFI shell, there&#8217;s an EFI boot manager&#8230; but I haven&#8217;t been able to figure out how to access any of this.</p>
<p>If you want to reverse engineer EFI stuff, downloading <a href="https://www.tianocore.org/">TianoCore&#8217;s EDK2</a> is a must. It contains source code for a lot of Intel&#8217;s framework, which is what most vendors use as a base for their EFI support. A lot of the code is exactly the same as what&#8217;s in the Insyde BIOS (read the spec <a href="http://download.intel.com/technology/framework/docs/HII_9_2.pdf">here</a>). </p>
<p>As for the Setup tool, it does indeed have a huge Advanced menu with even more options than your average desktop. There&#8217;s also a hidden Power menu. EFI defines a &#8220;form browser&#8221; protocol and formats for user input, which is what Insyde uses for their setup utility (spec <a href="http://download.intel.com/technology/framework/docs/HII_9_2.pdf">here</a>). I found these tables when disassembling the Setup binary and wrote a little dump utility to turn them into text. The result is a complete dump of the Setup hierarchy, including the Advanced menu, which also includes the offsets in the non-volatile storage corresponding to each setting. Insyde stores this configuration blob into an EFI variable named <code>Setup</code>. <a href="/uploads/insydehacks/setup.txt">Here&#8217;s</a> my dump: the first part is the hierarchy, while at the end I added a rough auto-calculated mapping from configuration offsets to setting names (grep for <code>[0xOFFSET</code> in the top section for better context - the format is <code>[0xOFFSET&lt;FIELD_WIDTH&gt;]</code> for all references to the storage blob). You&#8217;ll find the tools I used <a href="/uploads/insydehacks">here</a>, if you&#8217;re interested, but they&#8217;re rough and need quite a bit of manual help too.</p>
<p>I wasn&#8217;t able to find out how to enable the hidden menus, other than that their form Subclass is 5 instead of 0 (but I haven&#8217;t found what, if anything, checks for this and whether its behavior can be altered). However, manually enabling VT support in the <code>Setup</code> variable is easy enough, now that we have the offset of the VT Enable byte.</p>
<h3>Enabling Intel VT</h3>
<p>The easiest way to enable the setting as far as I can see is to dump out the entire BIOS, patch the setting into the Setup variable (which is part of the data storage section &#8211; we aren&#8217;t modifying any actual BIOS code, as this is the equivalent of changing a CMOS setting on other BIOSes), and then flash the resulting image. These laptops use a weird flash-behind-EC hardware solution for which there is no open flasher, so instead we can just use the normal BIOS flashing tool. In short, we&#8217;ll flash the existing BIOS back on, but in the process also modify a Setup setting.</p>
<p><b>FAIR WARNING:</b> This might apply to other similar laptops, or it might not. It might work, it might do nothing, or it might brick your expensive laptop. Even if you own an Aspire 8930G, I take no responsiblity if your laptop dies, turns into an expensive brick, melts into a pool of slag, blows up, flicks you off, develops self-awareness, or becomes Skynet. You have been warned. I have only tested this on an Aspire 8930G with BIOS Version 1.10. If you want to try this on another system or BIOS you should make sure you understand EXACTLY what is going on and are prepared to spot any problems or fix things yourself.</p>
<p>First, dump the exiting BIOS out. It resides at the top of the 32-bit address space, and is 2MB in size. You can use dd to dump it out of /dev/mem:</p>
<pre>$ dd if=/dev/mem of=original_bios.fd bs=1024 count=2048 skip=4192256</pre>
<p>It is a <i>very</i> good idea to back up this BIOS somewhere safe outside the laptop. Note that it not only contains your existing BIOS code, but also all your settings and manufacturer data (serial number, software license if you run an OEM version of Vista, etc).</p>
<p>Next, run <a href="/uploads/insydehacks/vtenable.py">vtenable.py</a>. This will attempt to locate the <b>Setup</b> EFI variable on the non-volatile storage section and patch the VT byte to one.</p>
<pre>$ python vtenable.py original_bios.fd vt_bios.fd</pre>
<p>You can edit the source code to make other changes to the variable, but make sure you know what you&#8217;re doing. It&#8217;s worth reiterating that <b>this does not patch your BIOS code</b>. It only makes a setting change, just as if you&#8217;d turned on the VT option in the BIOS had it been there. In fact, there are two variables: <code>Setup</code> and <code>Custom</code>, and <code>Setup</code> is the one that changes are committed to when you use the setup utility. Restoring defaults should turn VT back off (untested). It also appears that <code>Custom</code> is probably what the setup defaults are, so changing that should semi-permanently enable VT.</p>
<p>I highly recommend performing a sanity diff between the original and modified images using vbindiff:</p>
<pre>$ vbindiff original_bios.fd vt_bios.fd</pre>
<p>Only two or three bytes should change: one or two adjacent bytes for the checksum (they should be decremented by one when you look at them as a 16-bit unsigned integer), and the VT enable byte should change from <code>00</code> to <code>01</code>. Right after the checksum bytes you should be able to see the <code>Setup</code> name in UTF-16 (something like <code>S.e.t.u.p.</code>).</p>
<p>Finally, flash <code>vt_bios.fd</code> using the vendor-supplied flash utility. I use the DOS version (<code>FLASHIT.EXE</code>) with FreeDOS and a grub menu option so I don&#8217;t need to mess around with external media. Grab a base image <a href="/uploads/insydehacks/freedos_flashit.img.bz2">here</a>, then you can use <a href="http://mtools.linux.lu/">mtools</a> to copy the bios into it:</p>
<pre>$ bunzip2 freedos_flashit.img.bz2
$ mcopy -i freedos_flashit.img vt_bios.fd ::/vt_bios.fd</pre>
<p>To boot it using GRUB, get <a href="http://syslinux.zytor.com/wiki/index.php/MEMDISK">MEMDISK</a>, part of <a href="http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project">SYSLINUX</a>, and put something like this in your grub.conf:</p>
<pre>title=BIOS Update
root (hd0,0)
kernel (hd0,0)/boot/memdisk
initrd (hd0,0)/boot/freedos_flashit.img</pre>
<p>Of course, copy memdisk and the boot image to your boot partition, and change <code>(hd0,0)</code> to your boot (or root) partition everywhere and remove the <code>/boot</code> part if you have a dedicated boot partition.</p>
<p>Once you&#8217;re in FreeDOS, just type <code>FLASHIT vt&lt;tab&gt;</code> and be happy that FreeDOS supports tab-completion <img src='http://marcansoft.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Caveat: by doing this, you&#8217;re flashing the entire BIOS image. The flash tool makes no attempt to flash only the parts that changed, and the &#8220;flash only variables&#8221; commandline option seems to have no effect. You&#8217;re effectively reflashing your entire BIOS back on, so the usual BIOS flashing caveats apply: don&#8217;t turn the power off, etc. This could be accomplished a lot more cleanly if we had drivers for the flash chip / EC, since then we could use the normal EFI variable store procedure to atomically update the variable, which is completely safe.</p>
<p>You can use the <a href="http://www.linux-kvm.org/page/Enable_VT-X_on_Mac_Pro_(Early_2008)">MSR Magic</a> tool to check whether VT is indeed enabled on your CPU.</p>
<p><b>Update</b>: Several people are working on improved, more general tools to perform this hack across a broader range of InsydeH2O-based BIOSes. Read the comments and check them out, they&#8217;ve done some very good work.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcansoft.com/blog/2009/06/enabling-intel-vt-on-the-aspire-8930g/feed/</wfw:commentRss>
		<slash:comments>387</slash:comments>
		</item>
		<item>
		<title>More SPMP goodness: now with pseudo-3D</title>
		<link>http://marcansoft.com/blog/2009/06/more-spmp-goodness-now-with-pseudo-3d/</link>
		<comments>http://marcansoft.com/blog/2009/06/more-spmp-goodness-now-with-pseudo-3d/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 01:06:28 +0000</pubDate>
		<dc:creator>marcan</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[reveng]]></category>
		<category><![CDATA[spmp]]></category>
		<category><![CDATA[sunplus]]></category>

		<guid isPermaLink="false">http://marcansoft.com/blog/?p=52</guid>
		<description><![CDATA[After a few days of reading very, very weird disassembled code and poking registers, the odd 2D hardware finally works (for the most part). It can draw lines, so I threw in a software 3D transform. Here&#8217;s the Stanford Bunny in a glorious 448 vertices and 1416 lines of jaggy wireframe awesomeness. The chip has [...]]]></description>
			<content:encoded><![CDATA[<p>After a few days of reading very, very weird disassembled code and poking registers, the odd 2D hardware finally works (for the most part). It can draw lines, so I threw in a software 3D transform. Here&#8217;s the <a href="http://en.wikipedia.org/wiki/Stanford_Bunny">Stanford Bunny</a> in a glorious 448 vertices and 1416 lines of jaggy wireframe awesomeness.</p>
<p><object type="application/x-shockwave-flash" style="width:425px; height:350px;" data="http://www.youtube.com/v/3tg7KSSUl8Q&#038;hl=es&#038;fs=1&#038;"><param name="movie" value="http://www.youtube.com/v/3tg7KSSUl8Q&#038;hl=es&#038;fs=1&#038;" /><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<span id="more-52"></span><br />
The chip has hardware line styling (stippling), and you can see 4 different settings (solid, &#8220;10&#8243; dashed, &#8220;100&#8243; dashed, &#8220;1000&#8243; dashed) in sequence. At the higher setting it starts to look more like a point cloud with many more points than it has real vertices.</p>
<p>Also of note: I&#8217;m working inside a framework that drives operation of the SPMP from the PC. While the entire bunny transformation and rendering is happening inside the SPMP, the PC sends it the rotation matrix and tells it to go each frame (and also when to switch stippling and whatnot). So it&#8217;s slower than it would be in pure standalone hardware, because there&#8217;s still at least two serial port ping-pong commands each frame (one memory download for the matrix and one command to tell it to render the bunny with it).</p>
<p>You can grab the (ugly as hell) code in the <a href="http://git.marcansoft.com/?p=spmp.git;a=summary">Git repo</a>.</p>
<p>Fun stuff: the projection is orthographic, so there&#8217;s no depth information rendered. This makes the rotation ambiguous. Do you see it rotating clockwise or anticlockwise (looking at it from above)? Can you make your brain switch between them?</p>
]]></content:encoded>
			<wfw:commentRss>http://marcansoft.com/blog/2009/06/more-spmp-goodness-now-with-pseudo-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sunplus SPMP305x media player hacking</title>
		<link>http://marcansoft.com/blog/2009/06/sunplus-spmp305x-media-player-hacking/</link>
		<comments>http://marcansoft.com/blog/2009/06/sunplus-spmp305x-media-player-hacking/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 03:23:59 +0000</pubDate>
		<dc:creator>marcan</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[reveng]]></category>
		<category><![CDATA[spmp]]></category>
		<category><![CDATA[sunplus]]></category>

		<guid isPermaLink="false">http://marcansoft.com/blog/2009/06/sunplus-spmp305x-media-player-hacking/</guid>
		<description><![CDATA[I&#8217;ve joined a bunch of friends in a quest to reverse engineer and write custom software for Sunplus SPMP305x chips. These chips are inside all sorts of chinese media players, particularly the fairly powerful kind with a camera, video playback, etc. The chip is based around an ARM926EJ-S core, but the peripherals around it are [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve joined a bunch of friends in a quest to reverse engineer and write custom software for Sunplus SPMP305x chips. These chips are inside <a href="http://spmp305x.spritesserver.nl/wiki/index.php/List_of_units">all sorts of chinese media players</a>, particularly the fairly powerful kind with a camera, video playback, etc. The chip is based around an ARM926EJ-S core, but the peripherals around it are completely custom &#8211; check out the <a href="http://www.sunplusmm.com/products/dsc/spmp.asp">marketing blurb</a>. Most current work is on reverse engineering the hardware interface so we can completely replace the default firmware.</p>
<p>If you&#8217;re interested and you have one of these or don&#8217;t mind spending <a href="http://www.dealextreme.com/details.dx/sku.21968">$33</a> to get an interesting ARM machine, check out the <a href="http://spmp305x.spritesserver.nl/wiki/index.php">wiki</a>, <a href="http://code.google.com/p/libspmp3050/">Google Code project</a> for the Prex port and other stuff, and my <a href="http://git.marcansoft.com/?p=spmp.git;a=summary">Git repository</a> with a port of MINI and a bunch of client utilities for reverse engineering and testing the hardware stuff. Most importantly, however, come visit us at #spmpdev on the EFNet network! Most of the work and chitchat happens in the IRC channel.</p>
<p><img src="http://marcansoft.com/uploads/spmp/spmp_lcd.jpg" alt="sunplus test image" /></p>
]]></content:encoded>
			<wfw:commentRss>http://marcansoft.com/blog/2009/06/sunplus-spmp305x-media-player-hacking/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Amarok and other iTunesDB compatible software with the iPhone 2.x</title>
		<link>http://marcansoft.com/blog/2009/01/using-amarok-and-other-itunesdb-compatible-software-with-the-iphone-2x/</link>
		<comments>http://marcansoft.com/blog/2009/01/using-amarok-and-other-itunesdb-compatible-software-with-the-iphone-2x/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 19:52:31 +0000</pubDate>
		<dc:creator>marcan</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[iPhone on Linux]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[fairplay]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[stupid]]></category>

		<guid isPermaLink="false">http://marcansoft.com/blog/?p=22</guid>
		<description><![CDATA[With newer iPods and the iPhone 2.x firmware, Apple decided to implement a new hash scheme for iTunesDB to prevent third-party apps from managing the iPod database. Stupid. They decided to make it part of the FairPlay codebase, including its obfuscation. Very Stupid. But just in case that weren&#8217;t enough, then they went ahead and [...]]]></description>
			<content:encoded><![CDATA[<p>With newer iPods and the iPhone 2.x firmware, Apple decided to implement a new hash scheme for iTunesDB to prevent third-party apps from managing the iPod database. Stupid. They decided to make it part of the FairPlay codebase, including its obfuscation. Very Stupid. But just in case that weren&#8217;t enough, then they went ahead and tried to take down the <a href="http://bluwiki.com/go/Ipodhash">iPodHash</a> project which was attempting to reverse engineer the (annoyingly obfuscated) algorithm. Completely Stupid.</p>
<p>I had previously patched the check out in the MusicLibrary binary, and forgot to write it up. However, I just looked at it again, and it turns out that you can get it to work just by changing a simple XML file. I guess they didn&#8217;t really care if jailbroken iPhone users used third-party software.<br />
<span id="more-22"></span><br />
Here&#8217;s how: Edit <b>/System/Library/Lockdown/Checkpoint.xml</b>, find the <b>DBVersion</b> key, and change its value from <b>4</b> to <b>2</b>. Save and reboot. Voila! I haven&#8217;t tested this extensively, but it seems to work at least on 2.1 and 2.2. You can then use Amarok or any other libgpod app to transfer data to the device (using the usual sshfs mount trick which is documented elsewhere for 1.x iPhones)</p>
<p><b>Update</b>: abu from <a href="http://forums.winamp.com/forumdisplay.php?forumid=69">ml_ipod</a> pointed out that DBVersion 3 also works. This version includes the old hash which was already present in older versions. I have tested this to work on version 2.1 of the iPhone software.<br />
<b>Update 2</b>: DBVersion 3 works only on some devices, better stick with DBVersion 2.</p>
<div class="wp-caption aligncenter" style="width: 330px"><img alt="MobileMusicPlayer synced via Amarok" src="http://marcansoft.com/uploads/images/iphone-musicdb.png" title="MobileMusicPlayer synced via Amarok" width="320" height="480" /><p class="wp-caption-text">MobileMusicPlayer synced via Amarok</p></div>
]]></content:encoded>
			<wfw:commentRss>http://marcansoft.com/blog/2009/01/using-amarok-and-other-itunesdb-compatible-software-with-the-iphone-2x/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
	</channel>
</rss>
