The AssemblyPatcher is under active development. The aim is to create a tool, which allows easy .NET assembly modification without IL code struggling.
Write a query with some easy macro instructions to target the method or field, which should be replaced, deleted or add a whole new method to an existing type with plain C# which is compiled by Roslyn.
At the moment only an early version of the .NET library exists, which is the core for the later macro tool. At the moment it could help your to weaving .NET assemblys without purchasing expensive tools for this job ;-)
Here we replace the Main method of an assembly with some new code:
var inspector = new AssemblyInspector("HelloWorld.exe");
inspector.Method(x => x.FindMethod("HelloWorld.Program", "Main"))
.Replace("System.Console.WriteLine(\"This is a patched Hello World!\");");
inspector.SaveAs("HelloWorld.Patched.exe");
Here we delete a method from an assembly:
var inspector = new AssemblyInspector("HelloWorld.exe");
inspector.Method(x => x.FindMethod("HelloWorld.Program", "GenerateHelloWorld")).Remove();
inspector.SaveAs("HelloWorld.Patched.exe");
- Query Assemblies
- Save modified assemblies
- Methods
- Add Methods
- Delete Methods
- Replace Method Body with C# Code
- Call Methods of an external assembly
- Call Methods of same assembly
- Call Methods of same class
- Reference a field
- Static and instance support
- Support for Generics
- Properties
- Add Properties
- Delete Properties
- Replace Property Body
- Replace Get Method
- Replace Set Method
- Fields
- Add Fields
- Delete Fields
- Replace Field Value