Friday, November 14, 2008

Does Dotfuscator Community Edition work with Compact Framework?

Dotfuscator Community Edition is the obfuscator that ships with Visual Studio 2008 (and previous versions) for free. It is a cut down version of the Professional tool from the manufacturer. Since I am working on a project that will need obfuscating, I wondered whether this built in version is supposed to work with Compact Framework projects. A google search revealed a tantalizing answer "yes, but with 'issues'" from a newsgroup posting by Simon Hart. Since it wasn't easy to find a definitive answer, I thought I would try and find out myself, specifically to see what these issues were and if they had since gone away in the latest versions of both Visual Studio and Dotfuscator CE.

BTW, Simon's blog entry can be found here.

First, I ran the project through the version of Dotfuscator CE installed with Visual Studio 2008. That version was not fully integrated with Visual Studio but it was still relatively easy to get an obfuscated output for testing. After resolving some expected issues caused by renaming the symbols, the project had shrunk in size and ran well.... or so I thought....

Later testing revealed one very obscure bug in the obfuscated version of the application. Fortunately, the bug was easy to track down to a single override of a virtual function that was not being called resulting in the strange behavior.

Of course, renaming the symbols had probably caused this and tracing through the renamed symbols found that to be the case; the function was part of a chain of overrides and had been renamed higher up in the chain. I installed a later version of the Dotfuscator CE (the one that is integrated with Visual Studio) to see if this changed the obfuscator's behavior. The problem remained (BTW, the integration with the new version is much nicer).

To investigate further, I created a simple project, for the desktop and smart device frameworks, that had the same override hierarchy. Although renaming occurred the same way, the obfuscated code ran OK on the desktop, yet failed to be called properly on the smart device.

Unfortunately, then, I had to conclude that the way Dotfuscator CE renames overrides is not compatible with the compact framework execution model. There may, of course, be other problems but I didn't find any (or haven't yet!) in a moderately complicated application.

Specifically, if you have a hierarchy A > B > C, where A is the base and comes from a library so cannot be renamed. A declares a virtual function. B overrides it. C also overrides it. Dotfuscator CE will rename the virtual function in C only. On the desktop, this works. On the compact framework, it does not. Beware!

There may be workarounds. For example, it might be possible to specify an attribute to stop the obfuscator renaming all overrides to be safe and sure. Of course, you can also upgrade to the Professional version of Dotfuscator which claims 'Comprehensive Support' for compact framework - and there are other obfusctors out there...

Wednesday, March 12, 2008

MIX08 - Silverlight for Windows Mobile

I had the fortune to be invited to MIX08 this year and one of the most interesting topics for me was Microsoft's plans for Silverlight on mobile devices. I have not followed the Silverlight story until now, but for those of you not aquainted with it, Silverlight is a presentation technology, not unlike Flash, for building rich content applications, typically published on websites as an alternative to standard web pages (written in HTML) or their dynamic cousins (HTML + AJAX).

Flash has been available on mobile platforms for a while now. It is available as a full implementation of desktop Flash on some Windows Mobile platforms. There is also a special version of it, called Flash Lite, available for a wider range of mobile platforms including the Windows Mobile family, Windows CE and Nokia Series 60.

Silverlight v1.0 for Windows Mobile was launched last week at MIX08 and is the first implementation of Silverlight for mobile devices. It is based on v1.0 of the technology (a beta v2.0 of 'desktop' Silverlight was also much discussed at the conference) and implemented as a plug-in to Internet Explorer on Windows Mobile 6.0.

My own interest in both Flash and Silverlight is to evaluate them for use as a rich application development environment on our own platform (a device running Windows CE 5.0 with 'mobile characteristics' including a 240x320 screen and keypad data entry).

Unfortunately, since it looks like Silverlight for Windows Mobile will only work through Internet Explorer and on Windows Mobile 6.0, it currently rules out using Silverlight on our platform which does not include Internet Explorer and is based on Windows CE, not Windows Mobile.

Oh well, maybe Microsoft (or a 3rd party) will expand support later and maybe de-couple the Silverlight engine from Internet Explorer so it can be used for standalone applications.

I did see an impressive demo of the engine in use on a Windows Mobile device and it will be interesting to see if, and how, this takes hold in the mobile space.

You can find the slides and a video of the presentation here:
http://sessions.visitmix.com/?selectedSearch=T12