<?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>Ticklish Techs &#187; codeveil</title>
	<atom:link href="http://www.ticklishtechs.net/tag/codeveil/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ticklishtechs.net</link>
	<description>a mostly .NET but also some other cool techs blog</description>
	<lastBuildDate>Fri, 23 Jul 2010 06:07:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Even CodeVeil has bugs</title>
		<link>http://www.ticklishtechs.net/2008/07/14/even-codeveil-has-bugs/</link>
		<comments>http://www.ticklishtechs.net/2008/07/14/even-codeveil-has-bugs/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 20:48:22 +0000</pubDate>
		<dc:creator>Wolfram Bernhardt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[codeveil]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.ticklishtechs.net/2008/07/14/even-codeveil-has-bugs/</guid>
		<description><![CDATA[I love CodeVeil. From my point of view CodeVeil is simply the best tool to protect .NET assemblies from being reflectored, decompiled or whatever. It is very powerful, offers a wide range of protection aspects and still comes with a handy gui. So far I haven&#8217;t seen a method to crack veiled assemblies and that&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I love CodeVeil. From my point of view CodeVeil is simply the best tool to protect .NET assemblies from being reflectored, decompiled or whatever. It is very powerful, offers a wide range of protection aspects and still comes with a handy gui. So far I haven&#8217;t seen a method to crack veiled assemblies and that&#8217;s why I really rely on it for my commercial products.</p>
<p>You don&#8217;t find bugs in CodeVeil when you try to find them, but half a year ago we found this one by chance. CodeVeil veils well, but the resulting code throws a mighty exception.</p>
<p>You don&#8217;t need spectacular code to lure the bug out of it&#8217;s hole &#8211; here is the prelude:</p>
<pre class="code"><span style="color: blue">private static void </span>Main(<span style="color: blue">string</span>[] args)
{
    <span style="color: green">// Get list and fill it with values
    </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;&gt; l = <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;&gt;();
    l.Add(<span style="color: blue">new </span><span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;(23));
    l.Add(<span style="color: blue">new </span><span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;(42));

    <span style="color: green">// Have it sorted
    </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt;&gt; l2 = GetSortedReturnList(l);

    <span style="color: green">// Show result
    </span><span style="color: blue">foreach </span>(<span style="color: #2b91af">Capsule</span>&lt;<span style="color: blue">int</span>&gt; ci <span style="color: blue">in </span>l2)
        <span style="color: #2b91af">Console</span>.WriteLine(ci.Item);

    <span style="color: #2b91af">Console</span>.ReadLine();
}</pre>
<p>A simple list of two <code>ints </code>that are encapsulated in a generic type. The generic type just makes sure that two items can be compared:</p>
<pre class="code"><span style="color: blue">internal class </span><span style="color: #2b91af">Capsule</span>&lt;T&gt; : <span style="color: #2b91af">IComparable</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;T&gt;&gt;
{
    <span style="color: blue">public </span>T Item;

    <span style="color: blue">public </span>Capsule(T i)
    {
        Item = i;
    }

    <span style="color: blue">public int </span>CompareTo(<span style="color: #2b91af">Capsule</span>&lt;T&gt; other)
    {
        <span style="color: blue">return </span>Item.ToString().CompareTo(other.Item.ToString());
    }
}
</pre>
<p>And this code causes the exception when being executed by the veiled assembly:</p>
<pre class="code"><span style="color: blue">private static </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;T&gt;&gt; </pre>
<pre class="code">    GetSortedReturnList&lt;T&gt;(<span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Capsule</span>&lt;T&gt;&gt; list)
{
    <span style="color: blue">int </span><strong>sortOrder</strong> = 1;
    list.Sort(
        <span style="color: blue">delegate</span>(<span style="color: #2b91af">Capsule</span>&lt;T&gt; a, <span style="color: #2b91af">Capsule</span>&lt;T&gt; b) </pre>
<pre class="code">          { <span style="color: blue">return </span><strong>sortOrder</strong> * a.CompareTo(b); });

    <span style="color: blue">return </span>(list);
}
</pre>
<p>The sore point is the <code>sortOrder</code> variable being multiplied with the result of a.CompareTo(b) used in an anonymous method. Okay, you wouldn&#8217;t expect this code from a beginner, but it&#8217;s not rocket-science either. So we were very astonished and it took us quite some time to track this down and to believe our eyes. Maybe the problem with CodeVeil is related to the internal representation of anonymous method. When you use a constant instead of a variable</p>
<p><code>const int sortOrder = 1;</code></p>
<p>the problem disappears. I guess the compiler eliminates the constant and CodeVeil will not see it. But it remains, when you use a Linq-notation here:</p>
<pre class="code">list.Sort((a, b) =&gt; a.CompareTo(b)*sortOrder);
</pre>
<p>As said before we found this bug half a year ago. We contacted Xheo and received a very quick and friendly reply, but no solution. Seasons went by and several new versions of CodeVeil were released; but this bug is still present. At least in the stand-alone version.</p>
<p>But there is hope: The new beta preview of the DeployLX suite contains an obviously new version of CodeVeil and the bug <u>is finally gone</u>. And &#8211; by the way &#8211; this new version seems to offer a nice package of new feature and improved power! So, please, Mr. Xheo, release a new stand-alone-version of CodeVeil based on the new beta preview!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ticklishtechs.net/2008/07/14/even-codeveil-has-bugs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
