AsmLocator documentation
AsmLocator is a .NET library for finding, inspecting and editing parts of compiled .NET assemblies — types, fields, properties, events, methods, parameters, local variables and individual CIL instructions — by describing what you are looking for instead of writing nested loops.
It is built on top of AsmResolver, so everything AsmLocator returns is a normal AsmResolver object that you can keep working with.
using AsmLocator;
var locator = AssemblyLocator.FromFile("Sample.dll");
// "Which calls to Console.WriteLine are inside Greeter.Greet?"
var calls = locator.FindInstructions(
TypeSpec.ByFullName("Sample.Greeter"),
MethodSpec.ByName("Greet"),
InstructionSpec.Call("*Console::WriteLine*"));
foreach (var call in calls)
Console.WriteLine($"IL_{call.Instruction.Offset:X4}: {call.Instruction}");
Where do I start?
Pick the path that matches your experience. Every page builds on the one before it, so you can also simply read them top to bottom.
| You are... | Read this |
|---|---|
| New to .NET assemblies and IL | What is AsmLocator? → Concepts → Getting started → Tutorial |
| Comfortable with C#, new to AsmLocator | Getting started → Tutorial → Specifications |
| Looking for a specific task | Cookbook |
| Hitting an error | Troubleshooting |
| Looking for exact property and method names | Specification reference, Locator reference, API reference |
The learning path
Beginner
- What is AsmLocator? — the problem it solves and when to use it.
- Concepts — assemblies, metadata and CIL in plain language.
- Getting started — install, load a file, run your first query.
- Tutorial: your first patch — explore, search, edit, save and verify a real assembly.
Intermediate
- Specifications — describing what you want.
- String matching — exact, wildcard, regex and custom matching.
- Find, Get and Edit — the rules every lookup method follows.
- Searching members — types, fields, properties, events, methods, parameters and locals.
- Searching CIL instructions — single instructions and instruction patterns.
- Editing assemblies — changing method bodies and metadata safely.
Advanced
- Cookbook — complete, copy-ready recipes.
- Advanced topics — performance, custom predicates, obfuscated code, testing your patches.
- Troubleshooting — error messages and what they mean.
Reference
The core workflow in five lines
- Load a module with
AssemblyLocator.FromFileorAssemblyLocator.FromBytes. - Describe what you want with specification objects (
TypeSpec,MethodSpec, ...). - Ask with
FindX(first ornull),FindXs(all) orGetX(exactly one). - Inspect or edit the returned AsmResolver objects.
Saveto a new file and verify it.