What can we really do with RAIL?
n//Create the RAssemblyDef instance for the Teste3.exe assembly
nRAssemblyDef rAssembly = RAssemblyDef.LoadAssembly("Teste3.exe");
n//Get the RType object of the FooBar type
nRType rtd = rAssembly.RModuleDef.GetType("FooBar");
n//Create an array of RParameter objects
nRParameter [] paramsz = new RParameter[1];
n//Set the first element of the array
nparamsz[0] = new RParameter(0,rAssembly.GetType("System.String"));
n//Get the method which code is to be inserted at the start of the method
nRMethodDef rmd0 = (RMethodDef)rtd.GetMethod("WriteToScreenBefore",rAssembly.GetType("System.Void"),paramsz);
n//Get the method which code is to be inserted at the end of the method
nRMethodDef rmd1 = (RMethodDef)rtd.GetMethod("WriteToScreenAfter",rAssembly.GetType("System.Void"),paramsz);
n//Get the method to instrument
nRMethodDef rmd2 = (RMethodDef)rtd.GetMethod("MyMethod",rAssembly.GetType("System.Void"),paramsz);
n//Create the CodeTransformer object
nCodeTransformer cc = new CodeTransformer();
n//Set the transformations to make in the code
ncc.InsertAtMethodStart(rmd0);
ncc.InsertAtMethodEnd(rmd1);
n//Apply the change to the code
nrmd2.Accept(cc);
n//Save the new assembly
nrAssembly.SaveAssembly("Teste3.exe");
n
Add epilogues and prologues to methods