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 in the SDK installation directory for Visual Studio 2012; the default path is C:Program Files (x86)Microsoft SDKsWindowsv8.0AinNETFX 4.0 Tools. Note there is a 64-bit version in a sub folder of this location. When you start the application a window similar to the one shown in Figure 2.3 will be displayed.

Figure 2.3 ILDasm window

2.3

Within this window, select File ⇒ Open. Open mscorlib.dll, which should be located in your system directory with a default path of C:WindowsMicrosoft.NETFrameworkv4.0.30319mscorlib.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.

Figure 2.4 IL code for method Equals

2.4

Figure 2.4 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 2012, 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 2012 is beyond the scope of this chapter, but to access this tool, select the Tools menu and choose PreEmptive Dotfuscator and Analytics. 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset