iL DISASSEMBLER

One of the many handy tools that ships with Visual Studio is the IL Disassembler (ildasm.exe). It can be used to navigate the metadata within a module, including the types the module exposes, as well as their properties and methods. The IL Disassembler can also be used to display the IL contained within a module.

You can find the IL Disassembler under your installation directory for Visual Studio 2010; the default path is C:\ Program Files\Microsoft SDKs\Windows\v7.0A\Bin\ lLDasm.exe. Once the IL Disassembler has been started, select File O Open. Open mscorlib.dll, which is located in your system directory with a default path of C:\windows\ Microsoft.NET\Framework\V4-0.21006\mscorlib.dll. Once mscorlib.dll has been loaded, ILDasm will display a set of folders for each namespace in this assembly. Expand the System namespace, then the ValueType namespace, and finally double-click the Equals method. A window similar to the one shown in Figure 4-3 will be displayed.

Figure 4-3 shows the IL for the Equals method. Notice how the Reflection API is used to navigate through the instance of the value type's fields in order to determine whether the values of the two objects being compared are equal.

The IL Disassembler is a useful tool for learning how a particular module is implemented, but it could jeopardize your company's proprietary logic. After all, what's to prevent someone from using it to reverse engineer your code? Fortunately, Visual Studio 2010, like previous versions of Visual Studio, ships with a third-party tool called an obfuscator. The role of the obfuscator is to ensure that the IL Disassembler cannot build a meaningful representation of your application logic.

A complete discussion of the obfuscator that ships with Visual Studio 2010 is beyond the scope of this chapter, but to access this tool, select the Tools menu and choose Dotfuscator Community Edition. The obfuscator runs against your compiled application, taking your IL file and stripping out many of the items that are embedded by default during the compilation process.

0 0

Post a comment

  • Receive news updates via email from this site