Skip to navigation
Real World Computing

Almost ADSL

Posted on 2 Jul 2002 at 17:04

Dave Jewell awaits his ADSL installation with both fear and excitement, and shows how to access the Shell32 COM objects from C#

The .Net SDK already includes a utility called ILDASM, which can be used to disassemble a .Net executable or assembly, dumping out its code as a series of IL instructions, but what sets Exemplar apart is the fact that it gives you the output back in the form of C# source code. Listing One shows a small part of the DataGridCaption class contained inside the System.WinForms assembly. I'm hoping that Microsoft doesn't mind me showing a chunk of reverse-engineered code here, but bearing in mind that the company has given us ILDASM I can't see much basis for any objection. The only changes I made to this code were to adjust the formatting so things would fit better on the printed page. Other than that, this is the unretouched output of Exemplar, and I think that's impressive for a version 0.1 decompiler.

You'll notice that the decompiler has listed all the private field names, making it easier to understand the resulting code. Admittedly, the frequent references to this are superfluous, but this is a minor point. Note also that the decompiler has correctly identified and listed the 'getter' and 'setter' routines associated with the two properties shown. Naturally, a lot more code than this was produced; this snippet is intended to give you a flavour. It also handles all the common language control structures including while loops, for loops, and so forth. It's all very impressive, although I should warn you that the Exemplar source code isn't for the faint-hearted.

If you're familiar with MSIL, the Microsoft IL Assembler, you'll know that it has a special command-line switch, /owner, which is designed to prevent ILDASM from disassembling the instruction stream. Thus, you might use the switch like this:

ILASM mysource.il /owner=SecretSquirrel

Once you've done this, ILDASM can't disassemble the resulting code unless you supply 'SecretSquirrel' as the owner name. Needless to say, this simple-minded protection mechanism is ignored by Exemplar, which decompiles it regardless. What's the point of all this? Simply that if you're planning to release anything that runs under .Net you may as well give your source code away. Fortunately, there's a simple solution. If you're prepared to pre-JIT your code before distribution - in other words, release binaries that are already precompiled for the x86 processor family - your code will be no easier to reverse-engineer than that created with any traditional development system. Sure, you'll lose some portability, but you'll gain a lot in terms of peace of mind.

1 2 3 4
Subscribe to PC Pro magazine. We'll give you 3 issues for £1 plus a free gift - click here

From around the web

Be the first to comment this article

You need to Login or Register to comment.

(optional)

advertisement

Latest Real World Computing
Latest Blog Posts Subscribe to our RSS Feeds
Latest News Stories Subscribe to our RSS Feeds
Latest ReviewsSubscribe to our RSS Feeds

advertisement

Sponsored Links
 
SEARCH
SIGN UP

Your email:

Your password:

remember me

advertisement


Hitwise Top 10 Website 2010
 
 

PCPro-Computing in the Real World Printed from www.pcpro.co.uk

Register to receive our regular email newsletter at http://www.pcpro.co.uk/registration.

The newsletter contains links to our latest PC news, product reviews, features and how-to guides, plus special offers and competitions.