Creative Round-Tripping

Creative Round-Tripping

Simple two-step round-tripping, involving only disassembly and reassembly, is not very interesting, unless you are testing the round-tripping capabilities of the IL assembler and disassembler. A more creative scheme involves three steps: disassembly, tinkering with the ILAsm source code, and reassembly.

Generally speaking, you can alter the ILAsm source code during this creative round-tripping in only three ways:

  • You can change the code emitted by a high-level compiler or a tool in a way the compiler (the tool) would not allow you to do. From the section “Thunks and Wrappers” in Chapter 15, “Managed and Unmanaged Code Interoperation,” you might recall mention of the “manual intervention” necessary to correct the interop assemblies produced by the Tlbimp.exe tool. Other scenarios can also call for editing original code. For example, let’s suppose that you don’t believe me when I say that the common language runtime does not permit overriding the final virtual methods. You write a test program in Microsoft Visual Basic .NET, only to discover that the compiler will not let you explicitly override a final method. Without explicit overriding, the compiler automatically sets the newslot flag of the overriding method, and, alas, there goes your experiment. Then you recall that the ILAsm compiler doesn’t have such inhibitions. You disassemble your test application, remove the newslot flag, reassemble the test application, run it, and find out that I was right. As another example, let’s suppose that you have a nice assembly written in Microsoft Visual C# .NET that can do a lot of nice things, but your retrograde colleagues insist that in order to be useful your assembly must expose its functionality to the unmanaged legacy components. And those components are so far on the legacy side that they don’t even use COM. Then you recall that ILAsm allows you to export the managed methods as unmanaged entry points, and I don’t think I need to continue.

  • You can add the items written in ILAsm to extend your application’s functionality beyond the capabilities of a high-level compiler.

  • Finally, you can disassemble several modules and reassemble them into one module.



Inside Microsoft. NET IL Assembler
Inside Microsoft .NET IL Assembler
ISBN: 0735615470
EAN: 2147483647
Year: 2005
Pages: 147
Authors: SERGE LIDIN

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net