<?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>ReversingLabs &#124; Blog &#187; Developer</title>
	<atom:link href="http://blog.reversinglabs.com/tag/developer/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.reversinglabs.com</link>
	<description>Everything in reverse...</description>
	<lastBuildDate>Sat, 02 Jul 2011 10:53:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Ask a developer Monday</title>
		<link>http://blog.reversinglabs.com/2010/03/ask-a-developer-monday-2/</link>
		<comments>http://blog.reversinglabs.com/2010/03/ask-a-developer-monday-2/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 18:39:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Reversing]]></category>
		<category><![CDATA[TitanEngine]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Questions]]></category>

		<guid isPermaLink="false">http://blog.reversinglabs.com/?p=365</guid>
		<description><![CDATA[This is the second "Ask a developer Monday," in which we answer the most common question we've received recently. The current No. 1 question is: "Why is the entry point after unpacking located in the section named UPX0?" This is a more complex question than you might think, because it requires understanding the memory models [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">This is the second "<em>Ask a developer Monday</em>," in which we answer  the most common question we've received recently. The current No. 1 question is: "<em>Why is the entry point after unpacking located in the section named UPX0?</em>"</p>
<p style="text-align: justify;">This is a more complex question than you might think, because it requires understanding the memory models used by software packers, which makes it a perfect question for "Ask a developer Monday"! To answer it we must explore the memory models used, and the possible results that an unpacker could produce.</p>
<p style="text-align: justify;">The first memory model is the one  typically used by software packers. Its main characteristic is a greatly reduced number of portable executable sections - lowered to only two or three, depending on the packer solution itself. With this model, all sections in the file before packing are merged into a single section that is always the first section in the packed file. Most commonly this first section in the packed file holds no data and it is used just as a slot to reserve memory which will be filled after the packer stub finishes the decompression. The virtual size of this first packed file section is equal to the <em>SizeOfImage </em>of the file before it was packed. This gives the packers a powerful option for compressing all code and data in one pass as a single compressed data stream. It also speeds up the time needed to decompress the entire packed content and lowers the compressed file's size because it needs only a single decompression dictionary. The compressed data is commonly stored in the packer section which is either in the second or the third section of the packed file. Since resources must be aligned to <em>SectionAlignment, </em>they commonly get their own section - usually the last section of the file packed  using this memory model.</p>
<p style="text-align: justify;">Although the first model brings faster decompression and smaller files to the table, it has the disadvantage of slightly increasing the memory usage for the packed file. Since memory usage is only increased by the size of the compressed content <em>if that content is displaced from its original location</em> and moved to the packer section, the problem can be avoided by  using a packer that uses a memory model in which the compressed data is stored at its original location. This kind of packer individually compresses the portable executable sections and stores the compressed data inside the same section. With this model, the packer preserves the  section layout the file had prior to packing. Commonly, only one section is added to the original file layout, and that section only contains the packer stub. Compression here is achieved by reducing the physical size of the individual sections. There is a hybrid approach which combines these two memory models, but there isn't a software compression solution that uses it.</p>
<p style="text-align: justify;">Now how does this apply to dynamic unpackers? Since a dynamic unpacker executes the file until it reaches its original entry point and performs a memory dump once that point is reached, it has no impact whatsoever on the memory model used by the packer. That means that the file section layout before and after unpacking will remain the same, with exception of the sections added to the file by the unpacker. These new sections contain the import and relocation data, while the old sections hold the decompressed code, resources and data. There is no way to restore the memory model to its original layout if that kind of data isn't preserved in the packer stub. Since that data isn't commonly preserved by any software packers, a dynamic unpacker can't restore the original memory model layout. And since UPX uses the first memory model as its entry point after the file is unpacked, it will be moved from the section UPX1 to UPX0.  The thing to remember is that section names are not important, what is important is that the data and the code itself are decompressed and this is achieved by the dynamic unpackers.</p>
<ul>
<li>Examples for the fist memory model are: UPX, FSG, RLPack, etc.</li>
<li>Examples for the second memory model are: PackMan, ASPack, AlexProtector, etc.</li>
</ul>
<p>That is it for this weeks Q&amp;A, until next time...</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.reversinglabs.com%2F2010%2F03%2Fask-a-developer-monday-2%2F&amp;title=Ask%20a%20developer%20Monday" id="wpa2a_2"><img src="http://blog.reversinglabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.reversinglabs.com/2010/03/ask-a-developer-monday-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ask a developer Monday</title>
		<link>http://blog.reversinglabs.com/2009/11/ask-a-developer-monday/</link>
		<comments>http://blog.reversinglabs.com/2009/11/ask-a-developer-monday/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 13:33:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TitanEngine]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Questions]]></category>

		<guid isPermaLink="false">http://blog.reversinglabs.com/?p=129</guid>
		<description><![CDATA[This is the first "Ask a developer Monday" in which we try answer the number one question we received in the past weeks. And that question is: "How can I use TitanEngine as a static library?" Even though the TitanEngine is  mostly been used as a dynamic library in our sample unpackers it can also [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">This is the first "<em>Ask a developer Monday</em>" in which we try answer the number one question we received in the past weeks. And that question is: "How can I use <em>TitanEngine </em>as a static library?"</p>
<p style="text-align: justify;">Even though the <em>TitanEngine </em>is  mostly been used as a dynamic library in our sample unpackers it can also be used as a static library. First sample that uses our engine a static library we made is <em><a href="http://blog.reversinglabs.com/2009/10/titaniumoverlay/" target="_blank">TitaniumOverlay</a></em> whose source will be available with the next update. Here is how we did it...</p>
<p style="text-align: justify;">First step is to create new library files which contains the actual <em>TitanEngine </em>code so that the functions you use can be linked directly into your code. To do this open TitanEngine project with <a href="http://www.microsoft.com/" target="_blank"><em>Visual Studio</em></a> and go to Project -&gt; TitanEngine properties (Or just hit ALT+F7). In the Configuration Properties -&gt; General -&gt; Configuration type select Static Library (.lib).</p>
<p><a href="http://blog.reversinglabs.com/wp-content/uploads/2009/11/StaticLib.png" rel="lightbox[129]"><img class="aligncenter size-medium wp-image-128" title="StaticLib" src="http://blog.reversinglabs.com/wp-content/uploads/2009/11/StaticLib-300x216.png" alt="StaticLib" width="300" height="216" /></a></p>
<p style="text-align: justify;">Once you select this setting next compile will generate a new .lib file inside the release folder which will be used as a substitute for existing .lib file you used in the past. For your new project copy SDK.h and this new TitanEngine.lib to your project folder and include them in the usual way. One thing to worry about is that in your project you can't use the same function names which have already been used in the TitanEngine. So the only problem you can have is if you are creating a new DLL project you can't use function named DllMain. That can be resolved by renaming DllMain to any other name and setting the option Linker -&gt; General -&gt; EntryPoint to that function name.</p>
<p style="text-align: justify;">Until next time and next ask a developer Monday...</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.reversinglabs.com%2F2009%2F11%2Fask-a-developer-monday%2F&amp;title=Ask%20a%20developer%20Monday" id="wpa2a_4"><img src="http://blog.reversinglabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.reversinglabs.com/2009/11/ask-a-developer-monday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

