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

  1. What is AsmLocator? — the problem it solves and when to use it.
  2. Concepts — assemblies, metadata and CIL in plain language.
  3. Getting started — install, load a file, run your first query.
  4. Tutorial: your first patch — explore, search, edit, save and verify a real assembly.

Intermediate

  1. Specifications — describing what you want.
  2. String matching — exact, wildcard, regex and custom matching.
  3. Find, Get and Edit — the rules every lookup method follows.
  4. Searching members — types, fields, properties, events, methods, parameters and locals.
  5. Searching CIL instructions — single instructions and instruction patterns.
  6. Editing assemblies — changing method bodies and metadata safely.

Advanced

  1. Cookbook — complete, copy-ready recipes.
  2. Advanced topics — performance, custom predicates, obfuscated code, testing your patches.
  3. Troubleshooting — error messages and what they mean.

Reference

The core workflow in five lines

  1. Load a module with AssemblyLocator.FromFile or AssemblyLocator.FromBytes.
  2. Describe what you want with specification objects (TypeSpec, MethodSpec, ...).
  3. Ask with FindX (first or null), FindXs (all) or GetX (exactly one).
  4. Inspect or edit the returned AsmResolver objects.
  5. Save to a new file and verify it.