Rewriting IL - Part 4 - Token Replacement and Signature Rewriting

In the last post we talked about signatures and compression and we expanded on Metadata in general. Now we need to talk about the idea of replacing tokens inside of IL and inside of signatures. Being able to do this gives you a tremendous amount of power and flexibility when you start down the path of rewriting IL. Let’s take a look at some examples and look at some sample code to replace tokens in a signature and lay the ground work for injecting arbitrary IL.

Rewriting IL - Part 3 - Signatures and Compression

In the last post we talked about tokens and how they are like handles to types, methods, signatures, and really just about everything else. They are the currency that the CLR deals with. Today we talk about signatures, these guys are the biggest consumers of tokens outside of IL.

Rewriting IL - Part 2 - Tokens

In the last post we talked about getting the metadata interfaces. This allows us to read (import) and even fiddle (emit) with our precious metadata. What can we do with this? Right now tools like Just Decompile, ILSpy, ILDASM and others use these to read the files off disk and chew through the data to produce a decompiled version. What are we going to do with it? We’re going to merge in arbitrary .NET code into existing libraries. In order to do that we have to have correct tokens.

Rewriting IL - Part 1 - Metadata Interfaces

I think it goes without saying that rewriting IL is no trivial thing. However, I’ll just go ahead and say it again, rewriting IL is no trivial thing. If you jump on Code Project you’ll find a ton of resources that span the years. In fact when I started my project I turned to these very same articles. I found a couple of them that rely on using an injection library but are somewhat of a hack—very brilliant hacks mind you. So, in order to be above board I started down the path of using a profiler to inject IL. Let’s find out why this is not a trivial thing.

Simple Beginnings - ChainsAPM

In my last post I prattle on about the normal hang ups that any software developer has. I don’t have time for this, I would rather be doing that… Now that, that’s over I can get back to doing what I enjoy doing. Breaking things and making really terrible design decisions. Today I’m going to bore you with some background of my pet project ChainsAPM.