In my previous post, I mentioned the new home for CLRProfiler, where you can find its latest version, 4.5: http://clrprofiler.codeplex.com/. On the same CodePlex site you can also find a new sample, ILRewrite. ILRewrite contains sample code demonstrating the following:
Click on the ILRewrite10Source download from the Downloads tab. You can find some basic documentation on the Documentation tab, and more detailed documentation in the readme.txt distributed as part of the source.